mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
renamed the plugin
This commit is contained in:
parent
944e4b025c
commit
c366b45e16
12 changed files with 125 additions and 100 deletions
|
|
@ -54,7 +54,7 @@ class AnvilEventListener : Listener {
|
|||
|
||||
// Should find player
|
||||
val player = event.view.player
|
||||
if(!player.hasPermission(UnsafeEnchants.unsafePermission)) return
|
||||
if(!player.hasPermission(CustomAnvil.unsafePermission)) return
|
||||
|
||||
// Test rename lonely item
|
||||
if(second == null){
|
||||
|
|
@ -150,7 +150,7 @@ class AnvilEventListener : Listener {
|
|||
@EventHandler(ignoreCancelled = true)
|
||||
fun anvilExtractionCheck(event: InventoryClickEvent) {
|
||||
val player = event.whoClicked as? Player ?: return
|
||||
if(!player.hasPermission(UnsafeEnchants.unsafePermission)) return
|
||||
if(!player.hasPermission(CustomAnvil.unsafePermission)) return
|
||||
val inventory = event.inventory as? AnvilInventory ?: return
|
||||
if (event.rawSlot != ANVIL_OUTPUT_SLOT) { return }
|
||||
val output = inventory.getItem(ANVIL_OUTPUT_SLOT) ?: return
|
||||
|
|
@ -291,7 +291,7 @@ class AnvilEventListener : Listener {
|
|||
result.itemMeta = it
|
||||
}
|
||||
|
||||
UnsafeEnchants.log("Calculated penalty: " +
|
||||
CustomAnvil.log("Calculated penalty: " +
|
||||
"leftPenalty: $leftPenalty, " +
|
||||
"rightPenalty: $rightPenalty, " +
|
||||
"result penalty: ${(result.itemMeta as? Repairable)?.repairCost ?: "none"}")
|
||||
|
|
@ -316,7 +316,7 @@ class AnvilEventListener : Listener {
|
|||
// count enchant as illegal enchant if it conflicts with another enchant or not in result
|
||||
if((enchantment.key !in resultEnchsKeys)){
|
||||
resultEnchsKeys.add(enchantment.key)
|
||||
val conflictType = UnsafeEnchants.conflictManager.isConflicting(resultEnchsKeys,result.type,enchantment.key)
|
||||
val conflictType = CustomAnvil.conflictManager.isConflicting(resultEnchsKeys,result.type,enchantment.key)
|
||||
resultEnchsKeys.remove(enchantment.key)
|
||||
|
||||
if(ConflictType.BIG_CONFLICT == conflictType){
|
||||
|
|
@ -329,11 +329,11 @@ class AnvilEventListener : Listener {
|
|||
|
||||
val enchantmentMultiplier = ConfigOptions.enchantmentValue(enchantment.key, rightIsFormBook)
|
||||
val value = resultLevel * enchantmentMultiplier
|
||||
UnsafeEnchants.log("Value for ${enchantment.key.enchantmentName} level ${enchantment.value} is $value")
|
||||
CustomAnvil.log("Value for ${enchantment.key.enchantmentName} level ${enchantment.value} is $value")
|
||||
rightValue += value
|
||||
|
||||
}
|
||||
UnsafeEnchants.log("Calculated right values: " +
|
||||
CustomAnvil.log("Calculated right values: " +
|
||||
"rightValue: $rightValue, " +
|
||||
"illegalPenalty: $illegalPenalty")
|
||||
|
||||
|
|
@ -351,10 +351,10 @@ class AnvilEventListener : Listener {
|
|||
/* Because Minecraft likes to have the final say in the repair cost displayed
|
||||
* we need to wait for the event to end before overriding it, this ensures that
|
||||
* we have the final say in the process. */
|
||||
UnsafeEnchants.instance
|
||||
CustomAnvil.instance
|
||||
.server
|
||||
.scheduler
|
||||
.runTask(UnsafeEnchants.instance, Runnable {
|
||||
.runTask(CustomAnvil.instance, Runnable {
|
||||
if (ConfigOptions.removeRepairLimit) {
|
||||
inventory.maximumRepairCost = Int.MAX_VALUE
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,23 +16,23 @@ import java.io.FileReader
|
|||
* Bukkit/Spigot/Paper plugin to alter enchantment max
|
||||
* levels and allow unsafe enchantment combinations
|
||||
*/
|
||||
class UnsafeEnchants : JavaPlugin() {
|
||||
class CustomAnvil : JavaPlugin() {
|
||||
|
||||
companion object {
|
||||
// bstats plugin id
|
||||
private const val bstatsPluginId = 20923
|
||||
|
||||
// Permission string required to use the plugin's features
|
||||
const val unsafePermission = "ue.unsafe"
|
||||
const val unsafePermission = "ca.unsafe"
|
||||
// Permission string required to bypass enchantment conflicts test
|
||||
const val bypassFusePermission = "ue.bypass.fuse"
|
||||
const val bypassFusePermission = "ca.bypass.fuse"
|
||||
// Permission string required to bypass enchantment conflicts test
|
||||
const val bypassLevelPermission = "ue.bypass.level"
|
||||
const val bypassLevelPermission = "ca.bypass.level"
|
||||
// Permission string required to reload the config
|
||||
const val commandReloadPermission = "ue.command.reload"
|
||||
const val commandReloadPermission = "ca.command.reload"
|
||||
|
||||
// Command Name to reload the config
|
||||
const val commandReloadName = "reloadunsafeenchants"
|
||||
const val commandReloadName = "anvilconfigreload"
|
||||
|
||||
// Item Grouping Configuration file name
|
||||
const val itemGroupingConfigFilePath = "item_groups.yml"
|
||||
|
|
@ -42,7 +42,7 @@ class UnsafeEnchants : JavaPlugin() {
|
|||
const val unitRepairFilePath = "unit_repair_item.yml"
|
||||
|
||||
// Current plugin instance
|
||||
lateinit var instance: UnsafeEnchants
|
||||
lateinit var instance: CustomAnvil
|
||||
// Current item grouping configuration instance
|
||||
lateinit var conflictManager: EnchantConflictManager
|
||||
|
||||
|
|
@ -65,6 +65,14 @@ class UnsafeEnchants : JavaPlugin() {
|
|||
override fun onEnable() {
|
||||
instance = this
|
||||
|
||||
// Disable old plugin name if exist
|
||||
val potentialPlugin = Bukkit.getPluginManager().getPlugin("UnsafeEnchantsPlus")
|
||||
if(potentialPlugin != null){
|
||||
Bukkit.getPluginManager().disablePlugin(potentialPlugin)
|
||||
logger.warning("An old version of this plugin was detected")
|
||||
logger.warning("Please note CustomAnvil is a more recent version of UnsafeEnchantsPlus")
|
||||
}
|
||||
|
||||
reloadAllConfigs()
|
||||
// Load metrics
|
||||
val metric = Metrics(this, bstatsPluginId)
|
||||
|
|
@ -78,7 +86,6 @@ class UnsafeEnchants : JavaPlugin() {
|
|||
AnvilEventListener(),
|
||||
this
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
fun reloadAllConfigs(){
|
||||
|
|
@ -100,8 +107,8 @@ class UnsafeEnchants : JavaPlugin() {
|
|||
val unitRepairConfig = reloadResource(unitRepairFilePath) ?: return
|
||||
|
||||
// Set the global variable
|
||||
UnsafeEnchants.conflictManager = conflictManager
|
||||
UnsafeEnchants.unitRepairConfig = unitRepairConfig
|
||||
CustomAnvil.conflictManager = conflictManager
|
||||
CustomAnvil.unitRepairConfig = unitRepairConfig
|
||||
|
||||
// Test if default config
|
||||
MetricsUtil.testIfConfigIsDefault(config, itemGroupConfig, conflictConfig, unitRepairConfig)
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package io.delilaheve.util
|
||||
|
||||
import io.delilaheve.UnsafeEnchants
|
||||
import io.delilaheve.CustomAnvil
|
||||
import io.delilaheve.util.EnchantmentUtil.enchantmentName
|
||||
import org.bukkit.enchantments.Enchantment
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ object ConfigOptions {
|
|||
*/
|
||||
private val defaultEnchantLimit: Int
|
||||
get() {
|
||||
return UnsafeEnchants.instance
|
||||
return CustomAnvil.instance
|
||||
.config
|
||||
.getInt(DEFAULT_LIMIT_PATH, DEFAULT_ENCHANT_LIMIT)
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ object ConfigOptions {
|
|||
*/
|
||||
val limitRepairCost: Boolean
|
||||
get() {
|
||||
return UnsafeEnchants.instance
|
||||
return CustomAnvil.instance
|
||||
.config
|
||||
.getBoolean(LIMIT_REPAIR_COST, DEFAULT_LIMIT_REPAIR)
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ object ConfigOptions {
|
|||
*/
|
||||
val limitRepairValue: Int
|
||||
get() {
|
||||
return UnsafeEnchants.instance
|
||||
return CustomAnvil.instance
|
||||
.config
|
||||
.getInt(LIMIT_REPAIR_VALUE, DEFAULT_LIMIT_REPAIR_VALUE)
|
||||
.takeIf { it in REPAIR_LIMIT_RANGE }
|
||||
|
|
@ -103,7 +103,7 @@ object ConfigOptions {
|
|||
*/
|
||||
val itemRepairCost: Int
|
||||
get() {
|
||||
return UnsafeEnchants.instance
|
||||
return CustomAnvil.instance
|
||||
.config
|
||||
.getInt(ITEM_REPAIR_COST, DEFAULT_ITEM_REPAIR_COST)
|
||||
.takeIf { it in REPAIR_COST_RANGE }
|
||||
|
|
@ -115,7 +115,7 @@ object ConfigOptions {
|
|||
*/
|
||||
val unitRepairCost: Int
|
||||
get() {
|
||||
return UnsafeEnchants.instance
|
||||
return CustomAnvil.instance
|
||||
.config
|
||||
.getInt(UNIT_REPAIR_COST, DEFAULT_UNIT_REPAIR_COST)
|
||||
.takeIf { it in REPAIR_COST_RANGE }
|
||||
|
|
@ -127,7 +127,7 @@ object ConfigOptions {
|
|||
*/
|
||||
val itemRenameCost: Int
|
||||
get() {
|
||||
return UnsafeEnchants.instance
|
||||
return CustomAnvil.instance
|
||||
.config
|
||||
.getInt(ITEM_RENAME_COST, DEFAULT_ITEM_RENAME_COST)
|
||||
.takeIf { it in ITEM_RENAME_COST_RANGE }
|
||||
|
|
@ -139,7 +139,7 @@ object ConfigOptions {
|
|||
*/
|
||||
val sacrificeIllegalCost: Int
|
||||
get() {
|
||||
return UnsafeEnchants.instance
|
||||
return CustomAnvil.instance
|
||||
.config
|
||||
.getInt(SACRIFICE_ILLEGAL_COST, DEFAULT_SACRIFICE_ILLEGAL_COST)
|
||||
.takeIf { it in SACRIFICE_ILLEGAL_COST_RANGE }
|
||||
|
|
@ -150,7 +150,7 @@ object ConfigOptions {
|
|||
*/
|
||||
val removeRepairLimit: Boolean
|
||||
get() {
|
||||
return UnsafeEnchants.instance
|
||||
return CustomAnvil.instance
|
||||
.config
|
||||
.getBoolean(REMOVE_REPAIR_LIMIT, DEFAULT_REMOVE_LIMIT)
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ object ConfigOptions {
|
|||
*/
|
||||
val debugLog: Boolean
|
||||
get() {
|
||||
return UnsafeEnchants.instance
|
||||
return CustomAnvil.instance
|
||||
.config
|
||||
.getBoolean(DEBUG_LOGGING, DEFAULT_DEBUG_LOG)
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ object ConfigOptions {
|
|||
*/
|
||||
fun enchantLimit(enchantment: Enchantment): Int {
|
||||
val path = "${ENCHANT_LIMIT_ROOT}.${enchantment.enchantmentName}"
|
||||
return UnsafeEnchants.instance
|
||||
return CustomAnvil.instance
|
||||
.config
|
||||
.getInt(path, defaultEnchantLimit)
|
||||
.takeIf { it in ENCHANT_LIMIT_RANGE }
|
||||
|
|
@ -187,7 +187,7 @@ object ConfigOptions {
|
|||
): Int {
|
||||
val typeKey = if (isFromBook) KEY_BOOK else KEY_ITEM
|
||||
val path = "${ENCHANT_VALUES_ROOT}.${enchantment.enchantmentName}.$typeKey"
|
||||
return UnsafeEnchants.instance
|
||||
return CustomAnvil.instance
|
||||
.config
|
||||
.getInt(path, DEFAULT_ENCHANT_VALUE)
|
||||
.takeIf { it >= DEFAULT_ENCHANT_VALUE }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package io.delilaheve.util
|
||||
|
||||
import io.delilaheve.UnsafeEnchants
|
||||
import io.delilaheve.CustomAnvil
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.enchantments.Enchantment
|
||||
import org.bukkit.entity.HumanEntity
|
||||
|
|
@ -33,8 +33,8 @@ object EnchantmentUtil {
|
|||
if (!containsKey(enchantment)) {
|
||||
// Add the enchantment if it doesn't have conflicts, or, if player is allowed to bypass enchantment restrictions
|
||||
this[enchantment] = level
|
||||
if(!player.hasPermission(UnsafeEnchants.bypassFusePermission) &&
|
||||
(UnsafeEnchants.conflictManager.isConflicting(this.keys,mat,enchantment) != ConflictType.NO_CONFLICT)){
|
||||
if(!player.hasPermission(CustomAnvil.bypassFusePermission) &&
|
||||
(CustomAnvil.conflictManager.isConflicting(this.keys,mat,enchantment) != ConflictType.NO_CONFLICT)){
|
||||
this.remove(enchantment)
|
||||
}
|
||||
|
||||
|
|
@ -42,8 +42,8 @@ object EnchantmentUtil {
|
|||
// Enchantment already in result list
|
||||
else{
|
||||
// ... and they are conflicting
|
||||
if((UnsafeEnchants.conflictManager.isConflicting(this.keys,mat,enchantment) != ConflictType.NO_CONFLICT)
|
||||
&& !player.hasPermission(UnsafeEnchants.bypassFusePermission)){
|
||||
if((CustomAnvil.conflictManager.isConflicting(this.keys,mat,enchantment) != ConflictType.NO_CONFLICT)
|
||||
&& !player.hasPermission(CustomAnvil.bypassFusePermission)){
|
||||
return@forEach
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ object EnchantmentUtil {
|
|||
// try to increase the enchantment level by 1
|
||||
var newLevel = this[enchantment]!! +1
|
||||
// Get max level or 255 if player can bypass
|
||||
val maxLevel = if(player.hasPermission(UnsafeEnchants.bypassLevelPermission)){
|
||||
val maxLevel = if(player.hasPermission(CustomAnvil.bypassLevelPermission)){
|
||||
255
|
||||
}else{
|
||||
ConfigOptions.enchantLimit(enchantment)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package io.delilaheve.util
|
||||
|
||||
import io.delilaheve.UnsafeEnchants
|
||||
import io.delilaheve.CustomAnvil
|
||||
import org.bukkit.Material.ENCHANTED_BOOK
|
||||
import org.bukkit.enchantments.Enchantment
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
|
@ -59,7 +59,7 @@ object ItemUtil {
|
|||
}
|
||||
enchantments.forEach { (enchant, level) ->
|
||||
val added = addStoredEnchant(enchant, level, true)
|
||||
UnsafeEnchants.log("${enchant.key} added to item? $added")
|
||||
CustomAnvil.log("${enchant.key} added to item? $added")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue