mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Compare commits
23 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8447233b1e | |||
| eb2e7b3abb | |||
| 7f7f049b7b | |||
| 37e8ca7da9 | |||
| 95d3cf3228 | |||
| 178b372255 | |||
| 106cd53b02 | |||
| 950bad2168 | |||
| bc9cbe0b44 | |||
| 9d616d2fd0 | |||
| f82ccfa07e | |||
| cff94a2c5a | |||
| 4b5133c872 | |||
| 98d359f59f | |||
| 96754fd260 | |||
| b92b762551 | |||
| c064e4b1e1 | |||
| fc33b6fbd5 | |||
| 29e08fe29b | |||
| 151666fd21 | |||
| 593527241a | |||
| 3578322686 | |||
| 12ec4e1f54 |
20 changed files with 125 additions and 137 deletions
2
.github/workflows/gradle.yml
vendored
2
.github/workflows/gradle.yml
vendored
|
|
@ -26,7 +26,7 @@ jobs:
|
|||
contents: write
|
||||
|
||||
env:
|
||||
MODRINTH_VERSIONS: '["1.18.x", "1.19.x", "1.20.x", "1.21.x", "26.1.x"]'
|
||||
MODRINTH_VERSIONS: '["1.18.x", "1.19.x", "1.20.x", "1.21.x", "26.1.x", "26.2.x"]'
|
||||
MODRINTH_PLATFORMS: '["spigot", "paper", "purpur", "folia"]'
|
||||
|
||||
steps:
|
||||
|
|
|
|||
|
|
@ -6,54 +6,55 @@ This is cannot be fixed on geyser or my side.
|
|||
Here is various plugins that had issues with CustomAnvil
|
||||
where efforts was made for compatibility and should be working right:
|
||||
|
||||
some of them are cool I recommend checking them out !
|
||||
some if not all of them are cool ! I recommend checking them out !
|
||||
|
||||
## Supported By CustomAnvil
|
||||
These plugins have compatibility handled by custom anvil. seek help on custom anvil and do not bother these developers
|
||||
|
||||
#### Enchantment Plugins
|
||||
- [ExcellentEnchants](https://www.spigotmc.org/resources/excellentenchants-%E2%AD%90-75-vanilla-like-enchantments.61693/):
|
||||
Use ExcellentEnchants item type
|
||||
- [ExcellentEnchants](https://www.spigotmc.org/resources/excellentenchants-%E2%AD%90-75-vanilla-like-enchantments.61693/) by NightExpress:
|
||||
Use ExcellentEnchants item type \
|
||||
Also use ExcellentEnchant max enchant limit
|
||||
|
||||
- [EcoEnchant](https://www.spigotmc.org/resources/ecoenchants-%E2%AD%95-250-enchantments-%E2%9C%85-create-custom-enchants-%E2%9C%A8-essentials-cmi-support.79573/):
|
||||
- [EcoEnchant](https://www.spigotmc.org/resources/ecoenchants-%E2%AD%95-250-enchantments-%E2%9C%85-create-custom-enchants-%E2%9C%A8-essentials-cmi-support.79573/) by Auxilor:
|
||||
Need to use /anvilconfigreload or a server restart to add newly added enchantment.
|
||||
Use EcoEnchant restriction system but new restriction can be added in custom anvil
|
||||
|
||||
- [Enchantment²](https://www.spigotmc.org/resources/enchants-squared-the-enchantsplus-rewrite-custom-enchantments-that-act-like-vanilla-ones.86747/):
|
||||
- [Enchantment²](https://www.spigotmc.org/resources/enchants-squared-the-enchantsplus-rewrite-custom-enchantments-that-act-like-vanilla-ones.86747/) by Athlaeos:
|
||||
Support by Custom Anvil but still experimental. Automatic configuration. Plugin is not actively developed anymore
|
||||
|
||||
- [SuperEnchants](https://modrinth.com/plugin/superenchants)
|
||||
- [SuperEnchants](https://modrinth.com/plugin/superenchants) by Aznos:
|
||||
Use SuperEnchant restrictions system but new restriction can be added in custom anvil
|
||||
|
||||
|
||||
#### Custom Items Plugins
|
||||
Custom Items support is considered unstable. If you find issue please report it !
|
||||
|
||||
- [EcoItem](https://www.spigotmc.org/resources/30-sale%E2%8F%B3-ecoitems-%E2%AD%95-create-custom-items-%E2%9C%85-weapons-armors-tools-charms-%E2%9C%A8-item-levels-rarities.94601/)
|
||||
- [EcoItem](https://www.spigotmc.org/resources/30-sale%E2%8F%B3-ecoitems-%E2%AD%95-create-custom-items-%E2%9C%85-weapons-armors-tools-charms-%E2%9C%A8-item-levels-rarities.94601/) by Exanthiax:
|
||||
May have some issue. but should partially work I hope
|
||||
|
||||
- [ItemAdder](https://www.spigotmc.org/resources/%E2%9C%A8itemsadder%E2%AD%90emotes-mobs-items-armors-hud-gui-emojis-blocks-wings-hats-liquids.73355/)
|
||||
- [ItemAdder](https://www.spigotmc.org/resources/%E2%9C%A8itemsadder%E2%AD%90emotes-mobs-items-armors-hud-gui-emojis-blocks-wings-hats-liquids.73355/) by LoneDev:
|
||||
Need to fix unit item not working completly correctly as in can't have twice same base item
|
||||
|
||||
#### Anvil Mechanics Plugins
|
||||
- [Disenchantment](https://www.spigotmc.org/resources/disenchantment-1-21-1-1-20-6-new-book-splitting-mechanics.110741/)
|
||||
- [Disenchantment](https://www.spigotmc.org/resources/disenchantment-1-21-1-1-20-6-new-book-splitting-mechanics.110741/) by H7KZ
|
||||
Partially use Custom Anvil maximum XP settings (>= 6.1.5)
|
||||
|
||||
- [HavenBags](https://www.spigotmc.org/resources/havenbags-shulker-like-player-bound-bags-1-17-1-21-4.110420/)
|
||||
- [HavenBags](https://www.spigotmc.org/resources/havenbags-shulker-like-player-bound-bags-1-17-1-21-4.110420/) by hyperdefined
|
||||
For bag upgrade and skin via anvil. (version >= 1.31.0)
|
||||
|
||||
- [AxPlayerWarp](https://modrinth.com/project/QDJHDKvi)
|
||||
- [AxPlayerWarp](https://modrinth.com/project/QDJHDKvi) by ArtillexStudios
|
||||
For its anvil inventory usage
|
||||
|
||||
- [ToolsStats](https://modrinth.com/project/oBZj9E15)
|
||||
- [ToolsStats](https://modrinth.com/project/oBZj9E15) by Valorless
|
||||
For token application using anvil
|
||||
|
||||
### Known Partially Incompatible
|
||||
- [UberEnchant](https://modrinth.com/plugin/uberenchant)
|
||||
- [UberEnchant](https://modrinth.com/plugin/uberenchant) by coltonj96
|
||||
Anvil handling as they are doing something similar to CustomAnvil.
|
||||
It is by no mean there faults and I recomend checking them out
|
||||
It is by no mean there faults and I recommend checking them out especially if custom anvil do not work for your use case !
|
||||
|
||||
- [AdvencedEnchantments](https://ae.advancedplugins.net/)
|
||||
- [AdvencedEnchantments](https://ae.advancedplugins.net/) by Advanced Plugins
|
||||
Paid plugin I do not own as I did not get commissioned for support.
|
||||
may be able to use api but cannot test on my side
|
||||
|
||||
|
|
|
|||
21
CREDITS.md
21
CREDITS.md
|
|
@ -5,7 +5,7 @@ Thanks for all the contributors of bukkit, spigot, the paper team and the advent
|
|||
Thanks JetBrain for making IntelliJ
|
||||
|
||||
### Dependencies
|
||||
Here dependencies are used by custom anvil
|
||||
These dependencies (or a modified version of) are used by custom anvil
|
||||
- [IF](https://github.com/stefvanschie/IF) an inventory framework by stefvanschie
|
||||
- [Mockbukkit](https://github.com/MockBukkit/MockBukkit) for unit testing
|
||||
- [CentralPortalPlus](https://github.com/lalakii/central-portal-plus) by lalakii
|
||||
|
|
@ -17,23 +17,18 @@ Here dependencies are used by custom anvil
|
|||
- [ModrinthUpdateChecker](https://github.com/Clickism/ModrinthUpdateChecker) by Clickism and thanks to the modrinth team
|
||||
|
||||
### Compatibility
|
||||
Here is to credits all the author of plugins
|
||||
It partially repeat the the [Compatibility list](https://github.com/alexcrea/CustomAnvil/blob/v1.x.x/COMPATIBILITY.md)
|
||||
- Big Thanks for H7KZ for [Disenchantment](https://github.com/H7KZ/Disenchantment)
|
||||
- [Enchantment²](https://www.spigotmc.org/resources/enchants-squared-the-enchantsplus-rewrite-custom-enchantments-that-act-like-vanilla-ones.86747/) by Athlaeos
|
||||
- [EcoEnchant](https://www.spigotmc.org/resources/ecoenchants-%E2%AD%95-250-enchantments-%E2%9C%85-create-custom-enchants-%E2%9C%A8-essentials-cmi-support.79573/) by Auxilor
|
||||
- [ExcellentEnchants](https://www.spigotmc.org/resources/excellentenchants-%E2%AD%90-75-vanilla-like-enchantments.61693/) by NightExpress
|
||||
- [HavenBags](https://www.spigotmc.org/resources/havenbags-shulker-like-player-bound-bags-1-17-1-21-4.110420/) by hyperdefined
|
||||
- [AxPlayerWarp](https://modrinth.com/project/QDJHDKvi) by ArtillexStudios
|
||||
- [ToolsStats](https://modrinth.com/project/oBZj9E15) by Valorless
|
||||
Thanks to all the cool creator making the minecraft plugin's ecosystem works ! \
|
||||
See [Compatibility list](https://github.com/alexcrea/CustomAnvil/blob/v1.x.x/COMPATIBILITY.md) for details
|
||||
|
||||
but especially, Big Thanks for H7KZ maker of [Disenchantment](https://github.com/H7KZ/Disenchantment)
|
||||
|
||||
### Special Thanks
|
||||
|
||||
Thanks for Microsoft leading me into using a better operating system \
|
||||
Thanks for all the users trying my plugin for these niche use cases
|
||||
and for reporting issues and giving ideas !
|
||||
, reporting issues and giving ideas !
|
||||
|
||||
Thanks coltonj96 for [UberEnchant](https://modrinth.com/plugin/uberenchant).
|
||||
we may be incompatible with the anvil, but I do think it is a good alternative ! \
|
||||
I wish one day to work on cross compatibiltiy
|
||||
I wish one day to work on cross compatibiltiy \
|
||||
* If custom anvil do not work well for you or your use case give it a try ! *
|
||||
|
||||
|
|
|
|||
31
README.md
31
README.md
|
|
@ -1,8 +1,6 @@
|
|||
# Custom Anvil
|
||||
|
||||
**Custom Anvil** is a plugin that allows server administrators to customize every aspect of the anvil's mechanics.
|
||||
It is expected to work on 1.18 to 1.21.7 minecraft servers running spigot or paper.
|
||||
(the plugin support of 1.16.5 to 1.17.1 is experimental and may encounter issues)
|
||||
|
||||
### Download Locations:
|
||||
|
||||
|
|
@ -16,7 +14,7 @@ the plugin can be downloaded on
|
|||
- Vanilla like default configuration.
|
||||
- Custom enchantment level limit.
|
||||
- Custom anvil recipes.
|
||||
- Custom enchant restrictions (allow unsafe enchantment only for a group of item or create new restriction).
|
||||
- Custom enchant restrictions (allows unsafe enchantment only for a group of item or create new restriction).
|
||||
- Custom items of unit repairs (repair damaged with unit of "material", for example the repair of diamond sword by diamonds).
|
||||
- Custom XP cost for every aspect of the anvil.
|
||||
- Permissions to bypass level limit or enchantment restriction.
|
||||
|
|
@ -25,8 +23,14 @@ the plugin can be downloaded on
|
|||
- Gui to configure the plugin in game.
|
||||
- Support use of color code, hexadecimal color and minimessage for color/decoration
|
||||
- (Experimental) Folia support (gui do not work)
|
||||
- (Experimental) Dialog rename (allows longer rename)
|
||||
- (Experimental) Anvil with monetary cost (using vault) (require dialog rename)
|
||||
|
||||
And more !
|
||||
|
||||
---
|
||||
### Permissions:
|
||||
Note that for most of them you also need to enable feature and in most case enable use of permission for the specfic feature (indicated with `(toggleable)`)
|
||||
```yml
|
||||
# Generic and bypass permissions
|
||||
ca.affected: Player with this permission will be affected by the plugin
|
||||
|
|
@ -44,17 +48,22 @@ ca.config.edit: Allow administrator to edit the plugin's config in game
|
|||
# -----------------------------------------------------------------------------
|
||||
# Permissions related to use of color and minimessage
|
||||
ca.color.code: Allow player to use color code on rename if enabled (toggleable)
|
||||
ca.color.code.[thecode] (for example ca.color.code.a): Allows usage of only certain color code (toggleable)
|
||||
ca.color.hex: Allow player to use hexadecimal color on rename if enabled (toggleable)
|
||||
ca.rename.minimessage: Allow player to use minimessage formating on rename if enabled (toggleable) (only legacy compatible at the time)
|
||||
ca.rename.minimessage: Allow player to use minimessage formating on rename if enabled (toggleable)
|
||||
|
||||
# Permissions related to edition of the lore
|
||||
ca.lore_edit.book: Allow player to edit lore via book and quil if enabled (toggleable)
|
||||
ca.lore_edit.paper: Allow player to edit lore via paper if enabled (toggleable)
|
||||
|
||||
# Others
|
||||
ca.rename.dialog: Allow player to use the rename dialog (toggleable)
|
||||
```
|
||||
|
||||
### Commands
|
||||
|
||||
run `customanvil help` to get information about available commands (need permissions to use them)
|
||||
run `/customanvil help` to get information about available commands \
|
||||
this only show subcommands you have permission for
|
||||
|
||||
### Supported Plugins
|
||||
See the [Compatibility list](https://github.com/alexcrea/CustomAnvil/blob/v1.x.x/COMPATIBILITY.md)
|
||||
|
|
@ -63,13 +72,10 @@ See the [Compatibility list](https://github.com/alexcrea/CustomAnvil/blob/v1.x.x
|
|||
|
||||
One of the configurations allow displaying price about 40 and removing Too Expensive. \
|
||||
By how the minecraft client work: price above 40 can only be displayed green, even if the player does not own enough experience level.
|
||||
Minecraft version 1.18 to latest marked as supported do not need any ProtocoLib dependency. \
|
||||
spigot version 1.18 to 1.21.11 do not need any ProtocoLib dependency. (26.1.0 or above requires it) \
|
||||
Any recent paper version also are supported for this feature.
|
||||
But you should wait for update for new version containing new enchantable item or new enchantments.
|
||||
Other version need ProtocoLib enabled on your server for this feature. \
|
||||
You can also wait for an update of the plugin to support a newer version.
|
||||
|
||||
Please note that 1.16.5 to 1.17.1 are not officially supported. Run at your own risk.
|
||||
But you should wait for update for new version containing new enchantable item or new enchantments if any of this got added.
|
||||
Else it is, likely, fine to use the current version you are ussing on a new paper version
|
||||
|
||||
### For custom enchantment plugin developers
|
||||
For information about the API, please refer to [the Wiki](https://github.com/alexcrea/CustomAnvil/wiki) \
|
||||
|
|
@ -100,3 +106,6 @@ Credits and thanks can be seen [here](https://github.com/alexcrea/CustomAnvil/bl
|
|||
|
||||
### Known issue:
|
||||
Most unknown registered enchantments (by unsupported custom enchantment plugin & datapacks) will not have restriction by default. Planned but no eta.
|
||||
|
||||
### Do you need help with the plugin, or have any issue or suggestion?
|
||||
You can ask on the discussion page, create a [GitHub issue](https://github.com/alexcrea/CustomAnvil/issues) or join my [discord](https://discord.gg/KHUNsUfRYJ)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "xyz.alexcrea"
|
||||
version = "1.17.0"
|
||||
version = "1.17.5"
|
||||
|
||||
val isDevBuild = System.getenv("SMALL_COMMIT_HASH") != null
|
||||
val isPreRelease = System.getenv("IS_GITHUB_PRERELEASE") == "true"
|
||||
|
|
@ -58,7 +58,7 @@ dependencies {
|
|||
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
|
||||
|
||||
// fast stats
|
||||
implementation("dev.faststats.metrics:bukkit:0.25.1")
|
||||
implementation("dev.faststats.metrics:bukkit:0.27.0")
|
||||
|
||||
// minimessage
|
||||
implementation("net.kyori:adventure-text-minimessage:4.25.0")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
### Default Plugin's Configurations
|
||||
From 1.18 to 1.20.6 use [1.18 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.18) \
|
||||
From 1.21 to 1.21.8 use [1.21 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21)
|
||||
From 1.21.9 to 1.21.10 use [1.21.9 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21.9)
|
||||
From 1.21 to 1.21.8 use [1.21 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21) \
|
||||
From 1.21.9 to 1.21.10 use [1.21.9 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21.9) \
|
||||
From 1.21.11 use [1.21.11 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21.11)
|
||||
|
|
@ -9,5 +9,5 @@ kotlin.daemon.jvmargs=-Xmx8G
|
|||
subprojects.reobfnms=v1_17R1,v1_18R1,v1_18R2,v1_19R1,v1_19R2,v1_19R3,v1_20R1,v1_20R2,v1_20R3,v1_20R4,v1_21R1,v1_21R2,v1_21R3,v1_21R4,v1_21R5,v1_21R6,v1_21R7
|
||||
|
||||
# list of version for hangar release
|
||||
paperVersion=1.18-26.1.2
|
||||
paperVersion=1.18-26.2
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
// Excellent Enchant
|
||||
compileOnly("su.nightexpress.excellentenchants:Core:5.4.1")
|
||||
compileOnly("su.nightexpress.nightcore:main:2.14.1")
|
||||
compileOnly("su.nightexpress.excellentenchants:Core:5.4.3")
|
||||
compileOnly("su.nightexpress.nightcore:main:2.16.2")
|
||||
}
|
||||
|
|
@ -24,8 +24,8 @@ class PaperPacketManager : PacketManagerBase(), PacketManager {
|
|||
sendedAbilities.mayfly = playerAbilities.mayfly
|
||||
sendedAbilities.instabuild = instantBuild
|
||||
sendedAbilities.mayBuild = playerAbilities.mayBuild
|
||||
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
|
||||
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
|
||||
sendedAbilities.setFlyingSpeed(playerAbilities.getFlyingSpeed())
|
||||
sendedAbilities.setWalkingSpeed(playerAbilities.getWalkingSpeed())
|
||||
}
|
||||
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
|
||||
nmsPlayer.connection.send(packet)
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
package xyz.alexcrea.cuanvil.util
|
||||
|
||||
import org.bukkit.event.inventory.PrepareAnvilEvent
|
||||
import org.bukkit.inventory.InventoryView
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.inventory.view.AnvilView
|
||||
|
||||
object ModernPrepareAnvilCreator {
|
||||
fun createPrepareAnvil(view: InventoryView, item: ItemStack?): PrepareAnvilEvent {
|
||||
return PrepareAnvilEvent(view as AnvilView, item)
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import com.maddoxh.superEnchants.enchants.EnchantManager;
|
|||
import com.maddoxh.superEnchants.items.EnchantApplicator;
|
||||
import com.maddoxh.superEnchants.items.EnchantReader;
|
||||
import com.maddoxh.superEnchants.util.ConflictChecker;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
|
@ -68,6 +69,8 @@ public class CASuperEnchantEnchantment extends CAEnchantmentBase implements Addi
|
|||
|
||||
@Override
|
||||
public boolean isItemConflict(@NotNull Map<CAEnchantment, Integer> enchantments, @NotNull NamespacedKey itemType, @NotNull ItemStack item) {
|
||||
if(Material.ENCHANTED_BOOK.equals(item.getType())) return false;
|
||||
|
||||
return !enchant.canApplyTo(item.getType());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -283,15 +283,9 @@ public class BasicConfigGui extends ChestGui implements ValueUpdatableGui {
|
|||
lore.add("§7If the player do not have the required xp level, the action will not be completable.");
|
||||
|
||||
if(!this.packetManager.getCanSetInstantBuild()){
|
||||
if(MinecraftVersionUtil.INSTANCE.isTooNewForSpigot()){
|
||||
lore.add("");
|
||||
lore.add("§4/!\\§cCaution§4/!\\ §cYou need ProtocoLib installed and working or a paper server.");
|
||||
lore.add("§cCurrently ProtocoLib is not detected.");
|
||||
} else {
|
||||
lore.add("");
|
||||
lore.add("§4/!\\§cCaution§4/!\\ §cYou need ProtocoLib installed and working or a newer version of this plugin for this to work.");
|
||||
lore.add("§cCurrently ProtocoLib is not detected.");
|
||||
}
|
||||
}
|
||||
|
||||
String[] loreAsArray = new String[lore.size()];
|
||||
|
|
|
|||
|
|
@ -15,22 +15,6 @@ public class UpdateUtils {
|
|||
return Version.fromString(versionString);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static int[] currentMinecraftVersionArray() {
|
||||
String versionString = Bukkit.getServer().getBukkitVersion().split("-")[0];
|
||||
return UpdateUtils.readVersionFromString(versionString);
|
||||
}
|
||||
|
||||
public static int[] readVersionFromString(String versionString) {
|
||||
String[] partialVersion = versionString.split("\\.");
|
||||
int[] versionParts = new int[]{0, 0, 0};
|
||||
|
||||
for (int i = 0; i < Math.min(3, partialVersion.length); i++) {
|
||||
versionParts[i] = Integer.parseInt(partialVersion[i]);
|
||||
}
|
||||
return versionParts;
|
||||
}
|
||||
|
||||
public static void addToStringList(FileConfiguration config, String path, String... toAdd) {
|
||||
List<String> groups = new ArrayList<>(config.getStringList(path));
|
||||
groups.addAll(Arrays.asList(toAdd));
|
||||
|
|
|
|||
|
|
@ -21,7 +21,11 @@ public record Version(int major, int minor, int patch) {
|
|||
int[] versionParts = new int[]{0, 0, 0};
|
||||
|
||||
for (int i = 0; i < Math.min(3, partialVersion.length); i++) {
|
||||
try {
|
||||
versionParts[i] = Integer.parseInt(partialVersion[i]);
|
||||
} catch (NumberFormatException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new Version(versionParts[0], versionParts[1], versionParts[2]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package xyz.alexcrea.cuanvil.anvil
|
||||
|
||||
import io.delilaheve.util.ConfigOptions
|
||||
import java.math.BigDecimal
|
||||
import kotlin.math.min
|
||||
import io.delilaheve.util.ConfigOptions.getMonetaryMultiplier as moneyMultiplier
|
||||
|
||||
open class AnvilCost {
|
||||
|
|
@ -30,6 +32,21 @@ open class AnvilCost {
|
|||
return generic + enchantment + repair + rename + lore + illegalPenalty + workPenalty + recipe
|
||||
}
|
||||
|
||||
fun filteredXpCost(ignoreRules: Boolean = false): Int {
|
||||
val original = asXpCost()
|
||||
|
||||
// Test repair cost limit
|
||||
return if (
|
||||
!ignoreRules &&
|
||||
!ConfigOptions.doRemoveCostLimit &&
|
||||
ConfigOptions.doCapCost
|
||||
) {
|
||||
min(original, ConfigOptions.maxAnvilCost)
|
||||
} else {
|
||||
original
|
||||
}
|
||||
}
|
||||
|
||||
open fun asMonetaryCost(): BigDecimal {
|
||||
// multiply by per use type multipliers
|
||||
return BigDecimal(generic)
|
||||
|
|
|
|||
|
|
@ -6,29 +6,29 @@ object MinecraftVersionUtil {
|
|||
|
||||
val craftbukkitVersion: String?
|
||||
get() {
|
||||
val versionParts = UpdateUtils.currentMinecraftVersionArray()
|
||||
if (versionParts[0] != 1) return null
|
||||
val version = UpdateUtils.currentMinecraftVersion()
|
||||
if (version.major != 1) return null
|
||||
|
||||
return when (versionParts[1]) {
|
||||
17 -> when (versionParts[2]) {
|
||||
return when (version.minor) {
|
||||
17 -> when (version.patch) {
|
||||
0, 1 -> "1_17R1"
|
||||
else -> null
|
||||
}
|
||||
|
||||
18 -> when (versionParts[2]) {
|
||||
18 -> when (version.patch) {
|
||||
0, 1 -> "1_18R1"
|
||||
2 -> "1_18R2"
|
||||
else -> null
|
||||
}
|
||||
|
||||
19 -> when (versionParts[2]) {
|
||||
19 -> when (version.patch) {
|
||||
0, 1, 2 -> "1_19R1"
|
||||
3 -> "1_19R2"
|
||||
4 -> "1_19R3"
|
||||
else -> null
|
||||
}
|
||||
|
||||
20 -> when (versionParts[2]) {
|
||||
20 -> when (version.patch) {
|
||||
0, 1 -> "1_20R1"
|
||||
2 -> "1_20R2"
|
||||
3, 4 -> "1_20R3"
|
||||
|
|
@ -36,7 +36,7 @@ object MinecraftVersionUtil {
|
|||
else -> null
|
||||
}
|
||||
|
||||
21 -> when (versionParts[2]) {
|
||||
21 -> when (version.patch) {
|
||||
0, 1 -> "1_21R1"
|
||||
2, 3 -> "1_21R2"
|
||||
4 -> "1_21R3"
|
||||
|
|
@ -52,8 +52,7 @@ object MinecraftVersionUtil {
|
|||
}
|
||||
|
||||
val isTooNewForSpigot: Boolean get() {
|
||||
val versionParts = UpdateUtils.currentMinecraftVersionArray()
|
||||
return versionParts[0] != 1
|
||||
return UpdateUtils.currentMinecraftVersion().major != 1
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -38,8 +38,8 @@ object PacketManagerSelector {
|
|||
// Reobfuscated packet manager for spigot or paper as it remap
|
||||
private val reobfPacketManager: PacketManagerBase?
|
||||
get() {
|
||||
val versionParts = UpdateUtils.currentMinecraftVersionArray()
|
||||
if (versionParts[0] != 1) return null
|
||||
val versionParts = UpdateUtils.currentMinecraftVersion()
|
||||
if (versionParts.major != 1) return null
|
||||
|
||||
try {
|
||||
val clazz = Class.forName("xyz.alexcrea.cuanvil.dependency.packet.versions." +
|
||||
|
|
@ -47,7 +47,7 @@ object PacketManagerSelector {
|
|||
|
||||
val manager = clazz.getConstructor().newInstance()
|
||||
return manager as PacketManagerBase
|
||||
} catch (e: ClassNotFoundException) {
|
||||
} catch (_: ClassNotFoundException) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEPreV5Enchantment
|
|||
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEV5Enchantment
|
||||
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEV5_4Enchantment
|
||||
import xyz.alexcrea.cuanvil.enchant.wrapped.CALegacyEEEnchantment
|
||||
import xyz.alexcrea.cuanvil.util.ModernPrepareAnvilCreator
|
||||
import java.lang.reflect.Constructor
|
||||
import java.lang.reflect.Method
|
||||
import su.nightexpress.excellentenchants.api.EnchantRegistry as V5EnchantRegistry
|
||||
import su.nightexpress.excellentenchants.enchantment.impl.universal.CurseOfFragilityEnchant as LegacyCurseOfFragilityEnchant
|
||||
|
|
@ -118,6 +118,8 @@ class ExcellentEnchantsDependency {
|
|||
private lateinit var handleRechargeMethod: Method
|
||||
private lateinit var handleCombineMethod: Method
|
||||
|
||||
private val prepareAnvilConstructor = PrepareAnvilEvent::class.java.constructors.first() as Constructor<PrepareAnvilEvent>
|
||||
|
||||
fun redirectListeners() {
|
||||
val toUnregister = ArrayList<RegisteredListener>()
|
||||
// get required PrepareAnvilEvent listener
|
||||
|
|
@ -224,12 +226,8 @@ class ExcellentEnchantsDependency {
|
|||
|
||||
val first: ItemStack = treatInput(event.leftItem)
|
||||
val second: ItemStack = treatInput(event.rightItem)
|
||||
val fakeEvent: PrepareAnvilEvent = try {
|
||||
//TODO remove this on legacy removal
|
||||
PrepareAnvilEvent(event.view, result)
|
||||
} catch (_: NoSuchMethodError) {
|
||||
ModernPrepareAnvilCreator.createPrepareAnvil(event.view, result)
|
||||
}
|
||||
val fakeEvent = prepareAnvilConstructor.newInstance(event.view, result)
|
||||
|
||||
handleCombineMethod.invoke(this.usedAnvilListener, fakeEvent, first, second, result)
|
||||
|
||||
event.result = fakeEvent.result
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ class AnvilResultListener : Listener {
|
|||
view, inventory, player,
|
||||
leftItem, rightItem
|
||||
)
|
||||
if (unitRepairResult.isEmpty()) {
|
||||
if (!unitRepairResult.isEmpty()) {
|
||||
onUnitRepairExtract(
|
||||
rightItem, event, player, inventory,
|
||||
unitRepairResult
|
||||
|
|
@ -270,13 +270,19 @@ class AnvilResultListener : Listener {
|
|||
|
||||
}
|
||||
|
||||
private fun tryRemoveCost(player: Player, cost: AnvilCost): Boolean {
|
||||
private fun tryRemoveCost(player: Player, result: AnvilResult): Boolean {
|
||||
if (player.gameMode == GameMode.CREATIVE) return true
|
||||
|
||||
val cost = result.cost
|
||||
if (cost.isMonetary) {
|
||||
val result = EconomyManager.economy!!.remove(player, cost.asMonetaryCost())
|
||||
if (!result) return false
|
||||
} else {
|
||||
player.level -= cost.asXpCost()
|
||||
val xpCost = cost.filteredXpCost()
|
||||
if (xpCost > AnvilXpUtil.maximumXpCost(result.ignoreXpRules)) return false
|
||||
if (player.level < xpCost) return false
|
||||
|
||||
player.level -= xpCost
|
||||
}
|
||||
|
||||
return true
|
||||
|
|
@ -308,7 +314,7 @@ class AnvilResultListener : Listener {
|
|||
|
||||
// If not creative middle click...
|
||||
if (event.click != ClickType.MIDDLE) {
|
||||
if (!tryRemoveCost(player, cost)) return false
|
||||
if (!tryRemoveCost(player, result)) return false
|
||||
|
||||
// We remove what should be removed
|
||||
if (leftItem != null) leftItem.amount -= leftRemoveCount
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import xyz.alexcrea.cuanvil.dependency.economy.EconomyManager
|
|||
import xyz.alexcrea.cuanvil.group.ConflictType
|
||||
import xyz.alexcrea.cuanvil.util.AnvilTitleUtil
|
||||
import xyz.alexcrea.cuanvil.util.dialog.AnvilRenameDialogUtil
|
||||
import kotlin.math.min
|
||||
|
||||
object AnvilXpUtil {
|
||||
|
||||
|
|
@ -42,7 +41,15 @@ object AnvilXpUtil {
|
|||
cost.isMonetary = true
|
||||
setAnvilPrice(inventory, view, player, cost)
|
||||
} else
|
||||
setAnvilInvXp(inventory, view, player, cost.asXpCost(), ignoreRules)
|
||||
setAnvilInvXp(inventory, view, player, cost.filteredXpCost(ignoreRules), ignoreRules)
|
||||
}
|
||||
|
||||
fun maximumXpCost(ignoreRules: Boolean = false): Int {
|
||||
return if (ConfigOptions.doRemoveCostLimit || ignoreRules) {
|
||||
Int.MAX_VALUE
|
||||
} else {
|
||||
ConfigOptions.maxAnvilCost + 1
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -55,28 +62,11 @@ object AnvilXpUtil {
|
|||
anvilCost: Int,
|
||||
ignoreRules: Boolean = false
|
||||
) {
|
||||
|
||||
// Test repair cost limit
|
||||
val finalAnvilCost = if (
|
||||
!ignoreRules &&
|
||||
!ConfigOptions.doRemoveCostLimit &&
|
||||
ConfigOptions.doCapCost
|
||||
) {
|
||||
min(anvilCost, ConfigOptions.maxAnvilCost)
|
||||
} else {
|
||||
anvilCost
|
||||
}
|
||||
|
||||
val maximumRepairCost =
|
||||
if (ConfigOptions.doRemoveCostLimit || ignoreRules) {
|
||||
Int.MAX_VALUE
|
||||
} else {
|
||||
ConfigOptions.maxAnvilCost + 1
|
||||
}
|
||||
val maximumRepairCost = maximumXpCost(ignoreRules)
|
||||
|
||||
// Try first just in case another plugin, or the test need this
|
||||
inventory.maximumRepairCost = maximumRepairCost
|
||||
inventory.repairCost = finalAnvilCost
|
||||
inventory.repairCost = anvilCost
|
||||
// TODO for 2.x.x use anvil view & set directly there
|
||||
|
||||
/* Because Minecraft likes to have the final say in the repair cost displayed
|
||||
|
|
@ -87,15 +77,15 @@ object AnvilXpUtil {
|
|||
) {
|
||||
// retry after a tick
|
||||
inventory.maximumRepairCost = maximumRepairCost
|
||||
inventory.repairCost = finalAnvilCost
|
||||
inventory.repairCost = anvilCost
|
||||
// TODO for 2.x.x use anvil view & set directly there
|
||||
|
||||
if (player !is Player) return@scheduleOnEntity
|
||||
|
||||
if (player.gameMode != GameMode.CREATIVE) {
|
||||
val bypassToExpensive = (ConfigOptions.doReplaceTooExpensive) &&
|
||||
(finalAnvilCost >= 40) &&
|
||||
finalAnvilCost < inventory.maximumRepairCost
|
||||
(anvilCost >= 40) &&
|
||||
anvilCost < inventory.maximumRepairCost
|
||||
|
||||
DependencyManager.packetManager.setInstantBuild(player, bypassToExpensive)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue