Initial commit: port from svn

master
ALI Hamza 2021-01-06 07:01:19 +07:00
commit a3588c2956
Signed by: hamza
GPG Key ID: 22473A32291F8CB6
136 changed files with 2385 additions and 0 deletions

@ -0,0 +1 @@
mvn package && start ../speak.vbs

@ -0,0 +1,5 @@
#!/usr/bin/env bash
mvn package
#mv ./target/VagueEnchants-1.0.0.jar ~/server/plugins/
say up

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pw.hamzantal</groupId>
<artifactId>VagueEnchants</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>VagueEnchants</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>1.3.71</kotlin.version>
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
<kotlin.code.style>official</kotlin.code.style>
<junit.version>4.12</junit.version>
</properties>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>okkero</id>
<url>http://nexus.okkero.com/repository/maven-releases/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.udojava</groupId>
<artifactId>EvalEx</artifactId>
<version>2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.hazae41</groupId>
<artifactId>mc-kutils</artifactId>
<version>master-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.okkero.skedule</groupId>
<artifactId>skedule</artifactId>
<version>1.2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.10.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/craftbukkit-1.10.2.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard-api</artifactId>
<version>6.1.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/worldguard-6.1.2.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit-api</artifactId>
<version>6.1.3</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/worldedit-bukkit-6.1.3.jar</systemPath>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -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<String>) {
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)
}

@ -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<String>()
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)
}
}

@ -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 <T> Iterable<T>.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()

@ -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, String>): 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, String>): 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, String>): 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)
}
}
}

@ -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
}

@ -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<String, Long>()
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)
}

@ -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<Material>, 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<ItemStack> {
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) } }
}
}

@ -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)
}

@ -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<Enchantment>()
}
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)
}
}

@ -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<String>) {
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")
}
}

@ -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<String>) {
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.")
}
}

@ -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<String>)
}

@ -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<String>) {
if (conn != null) {
sender.msg("&cConnection has been successfully established")
} else {
sender.msg("&aThe connection is not established")
}
}
}

@ -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<String>) {
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")
}
}

@ -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<String>) {
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")
}
}

@ -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 <command>"
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<String>) {
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")
}
}

@ -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 <enchantment>"
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<String>) {
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------------------")
}
}
}

@ -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<String>) {
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")
}
}

@ -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<String>) {
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
}
}

@ -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<String>) {
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())
}
}

@ -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<String>) {
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<String>) {
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
}

@ -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] <level>"
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<String>) {
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")
}
}

@ -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<String, String>) {
msg(Msgs.error(msg, *placeholder))
}
fun CommandSender.general(msg: String, vararg placeholder: Pair<String, String>) {
msg(Msgs.general(msg, *placeholder))
}
fun CommandSender.success(msg: String, vararg placeholder: Pair<String, String>) {
msg(Msgs.success(msg, *placeholder))
}

@ -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<out String>
): MutableList<String> {
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<String>.has(me: String): MutableList<String> =
listOf(
sorted().filter { it.startsWith(me, ignoreCase = true) },
sorted().filter { it.contains(me, ignoreCase = true) })
.flatten()
.distinct()
.toMutableList()

@ -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<Player, Long>()
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
}
}

@ -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<Int, String>().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
}

@ -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<Player>()
private val cooldowns = hashMapOf<Player, Long>()
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<Location> {
val radius = r.toInt()
val locs = mutableListOf<Location>()
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
}
}

@ -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
}
}

@ -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<Player, Pair<BigDecimal, Long>>()
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
}
}

@ -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
}
}

@ -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<Player>()
private val cooldowns = hashMapOf<Player, Long>()
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
}
}

@ -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
}
}

@ -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<Player, Pair<Pair<Int, Int>, 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
}

@ -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% <amount>" #NOTE: This supports PAPI, but <amount> 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"

@ -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."

@ -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]

Binary file not shown.

@ -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% <amount>" #NOTE: This supports PAPI, but <amount> 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"

@ -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."

@ -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]

Some files were not shown because too many files have changed in this diff Show More