mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Add custom_item_support config file to optionally disable repair/salvage on items with custom models
This commit is contained in:
parent
0363ee2e90
commit
ffc6061f8b
@ -1,3 +1,15 @@
|
||||
Version 2.2.006
|
||||
Added new config custom_item_support.yml
|
||||
Added setting to disable repair on items with custom models, this is not on by default
|
||||
Added new locale entry 'Anvil.Repair.Reject.CustomModelData'
|
||||
Added new locale entry 'Anvil.Salvage.Reject.CustomModelData'
|
||||
|
||||
NOTES:
|
||||
Let me know in detail what kind of support you'd like to see in mcMMO regarding custom items, I'm open to suggestions.
|
||||
This update adds a new config file to allow server owners to disable repair or salvage on items with custom models,
|
||||
This prevention mechanism is not enabled by default, change the settings in custom_item_support.yml if you want to enable it.
|
||||
This feature is off by default for now to keep compatibility with existing servers, but it may be enabled by default in the future if feedback suggests it should be.
|
||||
|
||||
Version 2.2.005
|
||||
Fixed a bug where certain skills such as Dodge/Arrow Deflect had no skill cap and would continue improving forever
|
||||
Reduced messages on startup for SQL DB
|
||||
|
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.2.005</version>
|
||||
<version>2.2.006-SNAPSHOT</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<scm>
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CustomItemSupportConfig extends BukkitConfig {
|
||||
public CustomItemSupportConfig(File dataFolder) {
|
||||
super("custom_item_support.yml", dataFolder);
|
||||
validate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isCustomRepairAllowed() {
|
||||
return config.getBoolean("Custom_Item_Support.Repair.Allow_Repair_On_Items_With_Custom_Model_Data", true);
|
||||
}
|
||||
|
||||
public boolean isCustomSalvageAllowed() {
|
||||
return config.getBoolean("Custom_Item_Support.Salvage.Allow_Salvage_On_Items_With_Custom_Model_Data", true);
|
||||
}
|
||||
}
|
@ -140,6 +140,7 @@ public class mcMMO extends JavaPlugin {
|
||||
private GeneralConfig generalConfig;
|
||||
private AdvancedConfig advancedConfig;
|
||||
private PartyConfig partyConfig;
|
||||
private CustomItemSupportConfig customItemSupportConfig;
|
||||
|
||||
private FoliaLib foliaLib;
|
||||
private PartyManager partyManager;
|
||||
@ -185,6 +186,7 @@ public class mcMMO extends JavaPlugin {
|
||||
//Init configs
|
||||
advancedConfig = new AdvancedConfig(getDataFolder());
|
||||
partyConfig = new PartyConfig(getDataFolder());
|
||||
customItemSupportConfig = new CustomItemSupportConfig(getDataFolder());
|
||||
|
||||
//Store this value so other plugins can check it
|
||||
isRetroModeEnabled = generalConfig.getIsRetroMode();
|
||||
@ -806,6 +808,10 @@ public class mcMMO extends JavaPlugin {
|
||||
return partyManager;
|
||||
}
|
||||
|
||||
public CustomItemSupportConfig getCustomItemSupportConfig() {
|
||||
return customItemSupportConfig;
|
||||
}
|
||||
|
||||
public @NotNull FoliaLib getFoliaLib() {
|
||||
return foliaLib;
|
||||
}
|
||||
|
@ -65,10 +65,19 @@ public class RepairManager extends SkillManager {
|
||||
public void handleRepair(ItemStack item) {
|
||||
Player player = getPlayer();
|
||||
Repairable repairable = mcMMO.getRepairableManager().getRepairable(item.getType());
|
||||
if (item.getItemMeta() != null) {
|
||||
if(item.getItemMeta().hasCustomModelData()) {
|
||||
if(!mcMMO.p.getCustomItemSupportConfig().isCustomRepairAllowed()) {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED,
|
||||
"Anvil.Repair.Reject.CustomModelData");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getItemMeta().isUnbreakable()) {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Unbreakable");
|
||||
return;
|
||||
if (item.getItemMeta().isUnbreakable()) {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Unbreakable");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Permissions checks on material and item types
|
||||
|
@ -62,14 +62,19 @@ public class SalvageManager extends SkillManager {
|
||||
}
|
||||
|
||||
public void handleSalvage(Location location, ItemStack item) {
|
||||
Player player = getPlayer();
|
||||
final Player player = getPlayer();
|
||||
|
||||
Salvageable salvageable = mcMMO.getSalvageableManager().getSalvageable(item.getType());
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
if (meta != null && meta.isUnbreakable()) {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Unbreakable");
|
||||
return;
|
||||
final Salvageable salvageable = mcMMO.getSalvageableManager().getSalvageable(item.getType());
|
||||
final ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
if (meta.hasCustomModelData() && !mcMMO.p.getCustomItemSupportConfig().isCustomSalvageAllowed()) {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Salvage.Reject.CustomModelData");
|
||||
return;
|
||||
}
|
||||
if (meta.isUnbreakable()) {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Unbreakable");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Permissions checks on material and item types
|
||||
@ -190,30 +195,6 @@ public class SalvageManager extends SkillManager {
|
||||
return RankUtils.getRank(getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE);
|
||||
}
|
||||
|
||||
/*public double getExtractFullEnchantChance() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getExtractFullEnchantChance();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getExtractPartialEnchantChance() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getExtractPartialEnchantChance();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
public double getExtractFullEnchantChance() {
|
||||
if(Permissions.hasSalvageEnchantBypassPerk(getPlayer()))
|
||||
return 100.0D;
|
||||
|
11
src/main/resources/custom_item_support.yml
Normal file
11
src/main/resources/custom_item_support.yml
Normal file
@ -0,0 +1,11 @@
|
||||
# This is meant to be a general config for allowing mcMMO to allow interaction with custom items.
|
||||
# In the future, I would like to add configs to be specific about certain custom items.
|
||||
# For now, support is generalized to whether the custom item has a custom model.
|
||||
# This is an easy solution to implement for now, but not the most ideal.
|
||||
Custom_Item_Support:
|
||||
Repair:
|
||||
# Turn this off to disable repair on any items with custom model data
|
||||
Allow_Repair_On_Items_With_Custom_Model_Data: true
|
||||
Salvage:
|
||||
# Turn this off to disable salvage on any items with custom model data
|
||||
Allow_Salvage_On_Items_With_Custom_Model_Data: true
|
@ -423,6 +423,8 @@ Salvage.Skills.Lottery.Perfect=&a&lPerfect!&r&6 You salvaged &3{1}&6 effortlessl
|
||||
Salvage.Skills.Lottery.Untrained=&7You aren't properly trained in salvaging. You were only able to recover &c{0}&7 materials from &a{1}&7.
|
||||
#Anvil (Shared between SALVAGE and REPAIR)
|
||||
Anvil.Unbreakable=This item is unbreakable!
|
||||
Anvil.Repair.Reject.CustomModelData=A mysterious force prevents you from repairing this item...
|
||||
Anvil.Salvage.Reject.CustomModelData=A mysterious force prevents you from salvaging this item...
|
||||
#CROSSBOWS
|
||||
Crossbows.SkillName=CROSSBOWS
|
||||
Crossbows.Ability.Lower=&7You lower your crossbow.
|
||||
|
Loading…
Reference in New Issue
Block a user