From 0b0408ef984b6f55e6af9a10a6eb5e0406433ee6 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 6 Jun 2019 21:42:12 -0700 Subject: [PATCH 01/21] 2.1.70 dev mode --- Changelog.txt | 3 +++ pom.xml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 7d8858c51..521d87312 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.1.70 + + Version 2.1.69 Fixed a few places where mcMMO would not save player data immediately which may cause players to lose a few minutes of progress diff --git a/pom.xml b/pom.xml index 313aa80ed..1061a649f 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.69 + 2.1.70-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO From 7679afd3e0792cdd2b3157cdb42a0ac0c327d7fd Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 6 Jun 2019 23:15:18 -0700 Subject: [PATCH 02/21] Add new DatabaseAPI --- Changelog.txt | 2 +- .../com/gmail/nossr50/api/DatabaseAPI.java | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gmail/nossr50/api/DatabaseAPI.java diff --git a/Changelog.txt b/Changelog.txt index 521d87312..a60346e2c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,5 @@ Version 2.1.70 - + Added new DatabaseAPI to the API package, has features relating to database operations Version 2.1.69 Fixed a few places where mcMMO would not save player data immediately which may cause players to lose a few minutes of progress diff --git a/src/main/java/com/gmail/nossr50/api/DatabaseAPI.java b/src/main/java/com/gmail/nossr50/api/DatabaseAPI.java new file mode 100644 index 000000000..76caad65b --- /dev/null +++ b/src/main/java/com/gmail/nossr50/api/DatabaseAPI.java @@ -0,0 +1,33 @@ +package com.gmail.nossr50.api; + +import com.gmail.nossr50.datatypes.player.PlayerProfile; +import com.gmail.nossr50.mcMMO; + +import java.util.UUID; + +public class DatabaseAPI { + + /** + * Checks if a player exists in the mcMMO Database + * @param uuid player UUID + * @return true if the player exists in the DB, false if they do not + */ + public boolean doesPlayerExistInDB(String uuid) { + return doesPlayerExistInDB(UUID.fromString(uuid)); + } + + /** + * Checks if a player exists in the mcMMO Database + * @param uuid player UUID + * @return true if the player exists in the DB, false if they do not + */ + public boolean doesPlayerExistInDB(UUID uuid) { + PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid); + + if(playerProfile.isLoaded()) + return true; + else + return false; + } + +} From 00bee601515b9e64d93fb9a02fe7d381f415e369 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 7 Jun 2019 05:13:37 -0700 Subject: [PATCH 03/21] Prevent tool ready messages on shulker boxes --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/util/MaterialMapStore.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index a60346e2c..c042d3b7b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,6 @@ Version 2.1.70 Added new DatabaseAPI to the API package, has features relating to database operations + Fixed a bug where shulker boxes (without colors) would activate tool ready messages Version 2.1.69 Fixed a few places where mcMMO would not save player data immediately which may cause players to lose a few minutes of progress diff --git a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java index 16860e252..b301b517d 100644 --- a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java +++ b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java @@ -282,6 +282,7 @@ public class MaterialMapStore { abilityBlackList.add("light_gray_shulker_box"); abilityBlackList.add("white_shulker_box"); abilityBlackList.add("yellow_shulker_box"); + abilityBlackList.add("shulker_box"); abilityBlackList.add("wall_sign"); //1.13 and lower? abilityBlackList.add("sign"); //1.13 and lower? } @@ -372,6 +373,7 @@ public class MaterialMapStore { toolBlackList.add("light_gray_shulker_box"); toolBlackList.add("white_shulker_box"); toolBlackList.add("yellow_shulker_box"); + toolBlackList.add("shulker_box"); toolBlackList.add("acacia_sign"); toolBlackList.add("acacia_wall_sign"); toolBlackList.add("birch_sign"); From e37820d25e565575ef8982eada1d8695024d229e Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 7 Jun 2019 05:14:51 -0700 Subject: [PATCH 04/21] 2.1.70 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1061a649f..87d1a18ec 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.70-SNAPSHOT + 2.1.70 mcMMO https://github.com/mcMMO-Dev/mcMMO From 77fbf7f51e65513f05e7415c4b3bcae51bd563be Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 7 Jun 2019 10:26:49 -0700 Subject: [PATCH 05/21] Salvage always asks for confirmation before breaking an item --- Changelog.txt | 3 +++ pom.xml | 2 +- src/main/java/com/gmail/nossr50/listeners/PlayerListener.java | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index c042d3b7b..b00c14c53 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.1.71 + Salvage will now always ask for confirmation before breaking your items (instead of only asking for enchanted items) + Version 2.1.70 Added new DatabaseAPI to the API package, has features relating to database operations Fixed a bug where shulker boxes (without colors) would activate tool ready messages diff --git a/pom.xml b/pom.xml index 87d1a18ec..f2f38ed21 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.70 + 2.1.71-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 6b29f41e8..97622535f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -619,7 +619,7 @@ public class PlayerListener implements Listener { event.setCancelled(true); // Make sure the player knows what he's doing when trying to salvage an enchanted item - if (!(heldItem.getEnchantments().size() > 0) || salvageManager.checkConfirmation(true)) { + if (salvageManager.checkConfirmation(true)) { SkillUtils.handleAbilitySpeedDecrease(player); salvageManager.handleSalvage(block.getLocation(), heldItem); player.updateInventory(); From 549ef5734ecffd11b6fc98d759f7a0b98d150c01 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 7 Jun 2019 10:32:55 -0700 Subject: [PATCH 06/21] Repair now always requires confirmation --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/listeners/PlayerListener.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index b00c14c53..c2268bc04 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,6 @@ Version 2.1.71 Salvage will now always ask for confirmation before breaking your items (instead of only asking for enchanted items) + Repair will now always ask for confirmation before repairing items (instead of only asking for enchanted items) Version 2.1.70 Added new DatabaseAPI to the API package, has features relating to database operations diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 97622535f..bb4cee868 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -608,7 +608,7 @@ public class PlayerListener implements Listener { event.setCancelled(true); // Make sure the player knows what he's doing when trying to repair an enchanted item - if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(true)) { + if (repairManager.checkConfirmation(true)) { repairManager.handleRepair(heldItem); player.updateInventory(); } From a1321725072de9175c443eeef7c0469cebefb294 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 8 Jun 2019 10:20:22 -0700 Subject: [PATCH 07/21] You can no longer repair/salvage item stacks with more than one item --- Changelog.txt | 4 ++++ .../com/gmail/nossr50/listeners/PlayerListener.java | 10 ++++++++-- .../java/com/gmail/nossr50/util/MaterialMapStore.java | 2 ++ src/main/resources/locale/locale_en_US.properties | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index c2268bc04..8b76c4e00 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,10 @@ Version 2.1.71 Salvage will now always ask for confirmation before breaking your items (instead of only asking for enchanted items) Repair will now always ask for confirmation before repairing items (instead of only asking for enchanted items) + Gold & Iron Blocks will no longer trigger tool ready messages + Salvage & Repair anvils will no longer work on multi-item stacks + + NOTES: You can still turn the confirmation off in config.yml Version 2.1.70 Added new DatabaseAPI to the API package, has features relating to database operations diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index bb4cee868..ca67ab155 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -603,7 +603,10 @@ public class PlayerListener implements Listener { if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) { /* REPAIR CHECKS */ - if (type == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) { + if (type == Repair.anvilMaterial + && PrimarySkillType.REPAIR.getPermissions(player) + && mcMMO.getRepairableManager().isRepairable(heldItem) + && heldItem.getAmount() <= 1) { RepairManager repairManager = mcMMOPlayer.getRepairManager(); event.setCancelled(true); @@ -614,7 +617,10 @@ public class PlayerListener implements Listener { } } /* SALVAGE CHECKS */ - else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) { + else if (type == Salvage.anvilMaterial + && PrimarySkillType.SALVAGE.getPermissions(player) + && mcMMO.getSalvageableManager().isSalvageable(heldItem) + && heldItem.getAmount() <= 1) { SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager(); event.setCancelled(true); diff --git a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java index b301b517d..c46c2e66e 100644 --- a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java +++ b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java @@ -410,6 +410,8 @@ public class MaterialMapStore { toolBlackList.add("oak_wood"); toolBlackList.add("spruce_log"); toolBlackList.add("spruce_wood"); + toolBlackList.add("iron_block"); + toolBlackList.add("gold_block"); } private void addToHashSet(String string, HashSet stringHashSet) diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index fbdcb09d9..47215d079 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -54,6 +54,7 @@ JSON.Notification.SuperAbility={0} #These are the JSON Strings used for SubSkills JSON.Acrobatics.Roll.Interaction.Activated=Test [[RED]]Rolled Test JSON.Acrobatics.SubSkill.Roll.Details.Tips=If you hold sneak while falling you can prevent up to twice the damage that you would normally take! +Anvil.SingleItemStack=[[RED]]You cannot salvage or repair item stacks that have more than one item, split the stack first. #DO NOT USE COLOR CODES IN THE JSON KEYS #COLORS ARE DEFINED IN advanced.yml IF YOU WISH TO CHANGE THEM From 1d7919c050d2e1165d8b16f7e87f9cec49db9629 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 8 Jun 2019 10:21:12 -0700 Subject: [PATCH 08/21] 2.1.71 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f2f38ed21..1db7c0f88 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.71-SNAPSHOT + 2.1.71 mcMMO https://github.com/mcMMO-Dev/mcMMO From a677450d504ba01898f35f6feef0cffc95a978d9 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 9 Jun 2019 05:07:34 -0700 Subject: [PATCH 09/21] Fix NPE on server shutdown with no user data --- Changelog.txt | 3 +++ pom.xml | 2 +- src/main/java/com/gmail/nossr50/util/player/UserManager.java | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 8b76c4e00..1f59bcc75 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.1.72 + Fixed a NPE if a server shutdown with no player data needing to be saved (the error is harmless but spammy) + Version 2.1.71 Salvage will now always ask for confirmation before breaking your items (instead of only asking for enchanted items) Repair will now always ask for confirmation before repairing items (instead of only asking for enchanted items) diff --git a/pom.xml b/pom.xml index 1db7c0f88..d4673e8c5 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.71 + 2.1.72-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/util/player/UserManager.java b/src/main/java/com/gmail/nossr50/util/player/UserManager.java index c635300c5..ffb898086 100644 --- a/src/main/java/com/gmail/nossr50/util/player/UserManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/UserManager.java @@ -66,6 +66,9 @@ public final class UserManager { * Save all users ON THIS THREAD. */ public static void saveAll() { + if(playerDataSet == null) + return; + ImmutableList trackedSyncData = ImmutableList.copyOf(playerDataSet); mcMMO.p.getLogger().info("Saving mcMMOPlayers... (" + trackedSyncData.size() + ")"); From 2be67bae197d0af11a69da4d1091875c00f78847 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 9 Jun 2019 05:10:30 -0700 Subject: [PATCH 10/21] Fixed a NPE that could occur if Roll was disabled in coreskills.yml --- Changelog.txt | 1 + .../nossr50/listeners/InteractionManager.java | 14 ++++++++------ src/main/java/com/gmail/nossr50/mcMMO.java | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 1f59bcc75..c45766a61 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,6 @@ Version 2.1.72 Fixed a NPE if a server shutdown with no player data needing to be saved (the error is harmless but spammy) + Fixed a NPE that could occur if Roll was disabled in coreskills.yml Version 2.1.71 Salvage will now always ask for confirmation before breaking your items (instead of only asking for enchanted items) diff --git a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java index a2b1dd01d..a07792a90 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java +++ b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java @@ -15,12 +15,7 @@ public class InteractionManager { private static HashMap subSkillNameMap; //Used for mmoinfo optimization private static ArrayList subSkillList; - /** - * Registers subskills with the Interaction registration - * @param abstractSubSkill the target subskill to register - */ - public static void registerSubSkill(AbstractSubSkill abstractSubSkill) - { + public static void initMaps() { /* INIT MAPS */ if(interactRegister == null) interactRegister = new HashMap<>(); @@ -30,7 +25,14 @@ public class InteractionManager { if(subSkillNameMap == null) subSkillNameMap = new HashMap<>(); + } + /** + * Registers subskills with the Interaction registration + * @param abstractSubSkill the target subskill to register + */ + public static void registerSubSkill(AbstractSubSkill abstractSubSkill) + { //Store a unique copy of each subskill if(!subSkillList.contains(abstractSubSkill)) subSkillList.add(abstractSubSkill); diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 3e20e8f15..a0a525804 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -216,6 +216,8 @@ public class mcMMO extends JavaPlugin { Permissions.generateWorldTeleportPermissions(); } + InteractionManager.initMaps(); //Init maps before populating ranks + //Populate Ranked Skill Maps (DO THIS LAST) RankUtils.populateRanks(); } From caec01e9fa6503e6456f5caeb5c38e3964ea7de7 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 9 Jun 2019 05:12:56 -0700 Subject: [PATCH 11/21] 2.1.72 --- pom.xml | 2 +- src/main/java/com/gmail/nossr50/mcMMO.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index d4673e8c5..0c782ce92 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.72-SNAPSHOT + 2.1.72 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index a0a525804..1c9e415d2 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -216,8 +216,6 @@ public class mcMMO extends JavaPlugin { Permissions.generateWorldTeleportPermissions(); } - InteractionManager.initMaps(); //Init maps before populating ranks - //Populate Ranked Skill Maps (DO THIS LAST) RankUtils.populateRanks(); } @@ -577,6 +575,7 @@ public class mcMMO extends JavaPlugin { //TODO: Should do this differently Roll roll = new Roll(); CoreSkillsConfig.getInstance().isSkillEnabled(roll); + InteractionManager.initMaps(); InteractionManager.registerSubSkill(new Roll()); } } From 83b55db4f8fbfffb2680d382b70dbb46b87a202a Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 9 Jun 2019 05:53:39 -0700 Subject: [PATCH 12/21] 2.1.73 --- Changelog.txt | 3 +++ pom.xml | 2 +- src/main/java/com/gmail/nossr50/mcMMO.java | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index c45766a61..3953b678a 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.1.73 + Fixed a NPE that could occur if an entire skill was disabled in coreskills.yml + Version 2.1.72 Fixed a NPE if a server shutdown with no player data needing to be saved (the error is harmless but spammy) Fixed a NPE that could occur if Roll was disabled in coreskills.yml diff --git a/pom.xml b/pom.xml index 0c782ce92..079409501 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.72 + 2.1.73 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 1c9e415d2..1778f5737 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -568,6 +568,8 @@ public class mcMMO extends JavaPlugin { * Acrobatics skills */ + InteractionManager.initMaps(); //Init maps + if(CoreSkillsConfig.getInstance().isPrimarySkillEnabled(PrimarySkillType.ACROBATICS)) { System.out.println("[mcMMO]" + " enabling Acrobatics Skills"); @@ -575,7 +577,6 @@ public class mcMMO extends JavaPlugin { //TODO: Should do this differently Roll roll = new Roll(); CoreSkillsConfig.getInstance().isSkillEnabled(roll); - InteractionManager.initMaps(); InteractionManager.registerSubSkill(new Roll()); } } From 1297b45ef8c50f331eb5b41d9cb770822e1e1451 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 9 Jun 2019 07:08:26 -0700 Subject: [PATCH 13/21] 2.1.74 --- Changelog.txt | 3 +++ pom.xml | 2 +- .../java/com/gmail/nossr50/listeners/InteractionManager.java | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 3953b678a..0c2a607a2 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.1.74 + Fixed a NPE that could occur during certain events if a skill was disabled in coreskills.yml (Sorry!) + Version 2.1.73 Fixed a NPE that could occur if an entire skill was disabled in coreskills.yml diff --git a/pom.xml b/pom.xml index 079409501..cfcf23d48 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.73 + 2.1.74 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java index a07792a90..56cf1b5e3 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java +++ b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java @@ -75,6 +75,9 @@ public class InteractionManager { */ public static void processEvent(Event event, mcMMO plugin, InteractType curInteractType) { + if(interactRegister.get(curInteractType) == null) + return; + for(Interaction interaction : interactRegister.get(curInteractType)) { interaction.doInteraction(event, plugin); From 77bde61f4b1fda38b1586f67ea0af4e65fef8389 Mon Sep 17 00:00:00 2001 From: 89009332 <42133875+89009332@users.noreply.github.com> Date: Mon, 10 Jun 2019 09:17:07 +0800 Subject: [PATCH 14/21] Update locale_zh_CN.properties --- src/main/resources/locale/locale_zh_CN.properties | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/resources/locale/locale_zh_CN.properties b/src/main/resources/locale/locale_zh_CN.properties index f487f1d5d..32a9c59da 100644 --- a/src/main/resources/locale/locale_zh_CN.properties +++ b/src/main/resources/locale/locale_zh_CN.properties @@ -54,6 +54,7 @@ JSON.Notification.SuperAbility={0} #These are the JSON Strings used for SubSkills JSON.Acrobatics.Roll.Interaction.Activated=\u6d4b\u8bd5 [[RED]]\u7ffb\u6eda\u6d4b\u8bd5 JSON.Acrobatics.SubSkill.Roll.Details.Tips=\u5982\u679c\u4f60\u5728\u6454\u843d\u65f6\u6309\u4e0b\u6f5c\u884c\u952e,\u4f60\u5c06\u89e6\u53d1\u4e24\u500d\u7ffb\u6eda\u6548\u679c +Anvil.SingleItemStack=[[RED]]\u4f60\u4e0d\u80fd\u5206\u89e3\u8d27\u4fee\u590d\u6709\u591a\u4e2a\u7269\u54c1\u7684\u7269\u54c1\u5806, \u8bf7\u62c6\u5206\u540e\u518d\u4f7f\u7528. #DO NOT USE COLOR CODES IN THE JSON KEYS #COLORS ARE DEFINED IN advanced.yml IF YOU WISH TO CHANGE THEM @@ -103,6 +104,8 @@ Commands.Party.Header=[[RED]]-----[][[GREEN]]\u961f\u4f0d[[RED]][]----- Commands.Party.Features.Header=[[RED]]-----[][[GREEN]]FEATURES[[RED]][]----- # XP BAR Allows for the following variables -- {0} = Skill Level, {1} Current XP, {2} XP Needed for next level, {3} Power Level, {4} Percentage of Level # Make sure you turn on Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained if you want the XP bar title to update every time a player gains XP! +XPBar.Template={0} +XPBar.Template.EarlyGameBoost=[[GOLD]]\u6b63\u5728\u5b66\u4e60\u65b0\u6280\u80fd... XPBar.Acrobatics=\u6742\u6280 Lv.[[GOLD]]{0} XPBar.Alchemy=\u70bc\u91d1 Lv.[[GOLD]]{0} XPBar.Archery=\u7bad\u672f Lv.[[GOLD]]{0} @@ -512,7 +515,6 @@ Unarmed.Skills.Berserk.On=[[GREEN]]**\u72c2\u66b4\u6fc0\u6d3b** Unarmed.Skills.Berserk.Other.Off=\u72c2\u66b4[[GREEN]] \u7ed3\u675f\u4e86,\u8fdb\u5165\u51b7\u5374 [[YELLOW]]{0} Unarmed.Skills.Berserk.Other.On=[[GREEN]]{0}[[DARK_GREEN]] \u4f7f\u7528\u4e86 [[RED]]\u72c2\u66b4! Unarmed.Skills.Berserk.Refresh=[[GREEN]]\u4f60\u7684 [[YELLOW]]\u72c2\u66b4 [[GREEN]]\u6280\u80fd\u53ef\u4ee5\u4f7f\u7528\u4e86! - #WOODCUTTING Woodcutting.Ability.0=\u79cb\u98ce\u626b\u843d\u53f6 Woodcutting.Ability.1=\u626b\u9664\u6811\u53f6 @@ -827,6 +829,17 @@ Commands.Event.Start=[[GREEN]]mcMMO[[GOLD]] \u4e8b\u4ef6! Commands.Event.Stop=[[GREEN]]mcMMO[[DARK_AQUA]] \u4e8b\u4ef6\u7ed3\u675f! Commands.Event.Stop.Subtitle=[[GREEN]]\u6211\u5e0c\u671b\u4f60\u73a9\u7684\u5f00\u5fc3! Commands.Event.XP=[[DARK_AQUA]]\u591a\u500d\u7ecf\u9a8c\u901f\u7387\u4e3a [[GOLD]]{0}[[DARK_AQUA]] \u500d + +# Admin Notifications +Server.ConsoleName=[[YELLOW]][Server] +Notifications.Admin.XPRate.Start.Self=[[GRAY]]\u4f60\u5df2\u5c06\u5168\u5c40\u591a\u500d\u7ecf\u9a8c\u8bbe\u7f6e\u4e3a [[GOLD]]{0} \u500d +Notifications.Admin.XPRate.End.Self=[[GRAY]]\u4f60\u7ed3\u675f\u4e86\u591a\u500d\u7ecf\u9a8c\u4e8b\u4ef6. +Notifications.Admin.XPRate.End.Others={0} [[GRAY]]\u7ed3\u675f\u4e86\u591a\u500d\u7ecf\u9a8c\u4e8b\u4ef6 +Notifications.Admin.XPRate.Start.Others={0} [[GRAY]]\u5df2\u542f\u52a8\u6216\u4fee\u6539\u5177\u6709\u5168\u5c40 {1} \u500d\u7684\u591a\u500d\u7ecf\u9a8c\u4e8b\u4ef6 +Notifications.Admin.Format.Others=[[GOLD]]([[GREEN]]mcMMO [[DARK_AQUA]]Admin[[GOLD]]) [[GRAY]]{0} +Notifications.Admin.Format.Self=[[GOLD]]([[GREEN]]mcMMO[[GOLD]]) [[GRAY]]{0} + +# Event XPRate.Event= [[GOLD]]mcMMO \u73b0\u5728\u6b63\u5904\u4e8e\u591a\u500d\u7ecf\u9a8c\u4e8b\u4ef6\u9636\u6bb5! \u7ecf\u9a8c\u83b7\u53d6\u7387\u4e3a {0}\u500d! #GUIDES From f5f4182a9043b88d613ae29abb5cfab152bd67e9 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 10 Jun 2019 16:14:24 -0700 Subject: [PATCH 15/21] 2.1.75 --- Changelog.txt | 3 +++ pom.xml | 2 +- src/main/java/com/gmail/nossr50/listeners/BlockListener.java | 5 +++-- .../java/com/gmail/nossr50/skills/mining/MiningManager.java | 2 -- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 0c2a607a2..741ebd72e 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.1.75 + Fixed a bug that prevented Fortune from working correctly if a Double Drop was triggered + Version 2.1.74 Fixed a NPE that could occur during certain events if a skill was disabled in coreskills.yml (Sorry!) diff --git a/pom.xml b/pom.xml index cfcf23d48..70d2fdafb 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.74 + 2.1.75 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index eef643ec5..d9b8361cf 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -76,10 +76,11 @@ public class BlockListener implements Listener { for (int i = 0; i < bonusCount; i++) { event.getBlock().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is); } - - event.getBlock().removeMetadata(mcMMO.BONUS_DROPS_METAKEY, plugin); } } + + if(event.getBlock().hasMetadata(mcMMO.BONUS_DROPS_METAKEY)) + event.getBlock().removeMetadata(mcMMO.BONUS_DROPS_METAKEY, plugin); } /*@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 0ee620634..d5ddc13c7 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -73,8 +73,6 @@ public class MiningManager extends SkillManager { return; } - Material material = blockState.getType(); - if (mcMMOPlayer.getAbilityMode(skill.getAbility())) { SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage()); } From 46dee3c9b6c6854d97de54de4f1ff30ccc5f6435 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 10 Jun 2019 22:37:20 -0700 Subject: [PATCH 16/21] Numerous tweaks to salvage + fixing repair bugs --- Changelog.txt | 25 +++++++++++ pom.xml | 2 +- .../commands/skills/SalvageCommand.java | 12 +++--- .../config/mods/CustomArmorConfig.java | 11 +---- .../nossr50/config/mods/CustomToolConfig.java | 11 +---- .../config/skills/repair/RepairConfig.java | 15 +------ .../config/skills/salvage/SalvageConfig.java | 5 +-- .../interactions/NotificationType.java | 1 + .../datatypes/skills/PrimarySkillType.java | 2 +- .../datatypes/skills/SubSkillType.java | 2 +- .../nossr50/skills/repair/RepairManager.java | 18 +++----- .../skills/repair/repairables/Repairable.java | 10 +---- .../repair/repairables/RepairableFactory.java | 12 +++--- .../repair/repairables/SimpleRepairable.java | 23 ++++------ .../gmail/nossr50/skills/salvage/Salvage.java | 2 +- .../skills/salvage/SalvageManager.java | 37 ++++++++++++---- .../salvage/salvageables/Salvageable.java | 7 --- .../salvageables/SalvageableFactory.java | 8 ++-- .../salvageables/SimpleSalvageable.java | 9 +--- .../nossr50/util/TextComponentFactory.java | 5 +-- .../util/player/NotificationManager.java | 13 +++++- .../gmail/nossr50/util/skills/RankUtils.java | 7 +++ .../gmail/nossr50/util/skills/SkillUtils.java | 43 ++++++++++--------- .../resources/locale/locale_en_US.properties | 13 +++--- src/main/resources/repair.vanilla.yml | 4 -- src/main/resources/skillranks.yml | 20 +++++++-- 26 files changed, 166 insertions(+), 151 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 741ebd72e..3f9893eb5 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,28 @@ +Version 2.1.76 + Fixed a bug where Repair was repairing too much + Fixed a bug where Arcane Salvage was used to determine how many materials a player could salvage from an item + Removed the minimum quantity field from the repair config + Removed the item data (metadata) field from repair config as its not used anymore + Salvage will no longer return the max amount of materials possible, instead you are guaranteed one item and then some luck is involved on how many items are returned. + Advanced Salvage has been renamed to Scrap Collector + Updated Chinese locale (thanks to the user named 89009332 from github) + + New locale strings + Salvage.Skills.Lottery.Normal + Salvage.Skills.Lottery.Perfect + Salvage.Skills.Lottery.Untrained + Salvage.SubSkill.ScrapCollector.Name + Salvage.SubSkill.ScrapCollector.Description + Salvage.SubSkill.ScrapCollector.Stat + + (API) SALVAGE_ARCANE_SALVAGE in SubSkillTypes has been renamed to SALVAGE_SCRAP_COLLECTOR + + NOTES: + You do not need to update your configs for this update. + How Salvage works + If you have enough skill to gain up to 5 items from salvaging something, and that item has enough durability to yield up to 5 materials, salvage will play out like this + First off, you will be guaranteed 1 material, after this you have 80% chance to get the next material, if successful, another dice roll is conducted but lowers your odds by 20%, you chance to succeed will never fall below 33% + Version 2.1.75 Fixed a bug that prevented Fortune from working correctly if a Double Drop was triggered diff --git a/pom.xml b/pom.xml index 70d2fdafb..e30ac6d87 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.75 + 2.1.76-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java index 7577c4c54..1d10521e4 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java @@ -15,7 +15,7 @@ import java.util.ArrayList; import java.util.List; public class SalvageCommand extends SkillCommand { - private boolean canAdvancedSalvage; + private boolean canScrapCollector; private boolean canArcaneSalvage; public SalvageCommand() { @@ -30,7 +30,7 @@ public class SalvageCommand extends SkillCommand { @Override protected void permissionsCheck(Player player) { - canAdvancedSalvage = canUseSubskill(player, SubSkillType.SALVAGE_ADVANCED_SALVAGE); + canScrapCollector = canUseSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR); canArcaneSalvage = canUseSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE); } @@ -39,9 +39,11 @@ public class SalvageCommand extends SkillCommand { List messages = new ArrayList(); SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager(); - if (canAdvancedSalvage) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Ability.Bonus.0"), - LocaleLoader.getString("Salvage.Ability.Bonus.1", salvageManager.getSalvageableAmount()))); + if (canScrapCollector) { + messages.add(getStatMessage(false, true, + SubSkillType.SALVAGE_SCRAP_COLLECTOR, + String.valueOf(RankUtils.getRank(player, SubSkillType.REPAIR_ARCANE_FORGING)), + RankUtils.getHighestRankStr(SubSkillType.REPAIR_ARCANE_FORGING))); } if (canArcaneSalvage) { diff --git a/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java index 01a23f3ce..a32b497b5 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java @@ -5,10 +5,8 @@ import com.gmail.nossr50.datatypes.skills.ItemType; import com.gmail.nossr50.datatypes.skills.MaterialType; import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.skills.repair.repairables.RepairableFactory; -import com.gmail.nossr50.util.skills.SkillUtils; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.List; @@ -77,13 +75,6 @@ public class CustomArmorConfig extends ConfigLoader { } if (repairable) { - byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", -1); - int repairQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(armorMaterial), repairMaterial, repairData); - - if (repairQuantity == 0) { - repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 2); - } - String repairItemName = config.getString(armorType + "." + armorName + ".Repair_Material_Pretty_Name"); int repairMinimumLevel = config.getInt(armorType + "." + armorName + ".Repair_MinimumLevel", 0); double repairXpMultiplier = config.getDouble(armorType + "." + armorName + ".Repair_XpMultiplier", 1); @@ -94,7 +85,7 @@ public class CustomArmorConfig extends ConfigLoader { durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70); } - repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, repairItemName, repairMinimumLevel, repairQuantity, durability, ItemType.ARMOR, MaterialType.OTHER, repairXpMultiplier)); + repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairItemName, repairMinimumLevel, durability, ItemType.ARMOR, MaterialType.OTHER, repairXpMultiplier)); } materialList.add(armorMaterial); diff --git a/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java index 915face2b..dc47b6081 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java @@ -6,10 +6,8 @@ import com.gmail.nossr50.datatypes.skills.ItemType; import com.gmail.nossr50.datatypes.skills.MaterialType; import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.skills.repair.repairables.RepairableFactory; -import com.gmail.nossr50.util.skills.SkillUtils; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.HashMap; @@ -85,13 +83,6 @@ public class CustomToolConfig extends ConfigLoader { } if (repairable) { - byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", -1); - int repairQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(toolMaterial), repairMaterial, repairData); - - if (repairQuantity == 0) { - repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Quantity", 2); - } - String repairItemName = config.getString(toolType + "." + toolName + ".Repair_Material_Pretty_Name"); int repairMinimumLevel = config.getInt(toolType + "." + toolName + ".Repair_MinimumLevel", 0); double repairXpMultiplier = config.getDouble(toolType + "." + toolName + ".Repair_XpMultiplier", 1); @@ -102,7 +93,7 @@ public class CustomToolConfig extends ConfigLoader { durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60); } - repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, repairItemName, repairMinimumLevel, repairQuantity, durability, ItemType.TOOL, MaterialType.OTHER, repairXpMultiplier)); + repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairItemName, repairMinimumLevel, durability, ItemType.TOOL, MaterialType.OTHER, repairXpMultiplier)); } double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0); diff --git a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java index b7a85d197..0c88041d8 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.MaterialType; import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.skills.repair.repairables.RepairableFactory; import com.gmail.nossr50.util.ItemUtils; -import com.gmail.nossr50.util.skills.SkillUtils; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.ItemStack; @@ -126,7 +125,6 @@ public class RepairConfig extends ConfigLoader { } } - byte repairMetadata = (byte) config.getInt("Repairables." + key + ".RepairMaterialMetadata", -1); int minimumLevel = config.getInt("Repairables." + key + ".MinimumLevel"); double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1); @@ -134,19 +132,8 @@ public class RepairConfig extends ConfigLoader { reason.add(key + " has an invalid MinimumLevel of " + minimumLevel); } - // Minimum Quantity - int minimumQuantity = (itemMaterial != null ? SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), repairMaterial, repairMetadata) : config.getInt("Repairables." + key + ".MinimumQuantity", 2)); - - if (minimumQuantity <= 0 && itemMaterial != null) { - minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity", 2); - } - - if (minimumQuantity <= 0) { - reason.add("Minimum quantity of " + key + " must be greater than 0!"); - } - if (noErrorsInRepairable(reason)) { - Repairable repairable = RepairableFactory.getRepairable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); + Repairable repairable = RepairableFactory.getRepairable(itemMaterial, repairMaterial, minimumLevel, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); repairables.add(repairable); } } diff --git a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java index b9a137478..5400ca826 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java @@ -113,7 +113,6 @@ public class SalvageConfig extends ConfigLoader { } } - byte salvageMetadata = (byte) config.getInt("Salvageables." + key + ".SalvageMaterialMetadata", -1); int minimumLevel = config.getInt("Salvageables." + key + ".MinimumLevel"); double xpMultiplier = config.getDouble("Salvageables." + key + ".XpMultiplier", 1); @@ -122,7 +121,7 @@ public class SalvageConfig extends ConfigLoader { } // Maximum Quantity - int maximumQuantity = (itemMaterial != null ? SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), salvageMaterial, salvageMetadata) : config.getInt("Salvageables." + key + ".MaximumQuantity", 2)); + int maximumQuantity = (itemMaterial != null ? SkillUtils.getRepairAndSalvageQuantities(itemMaterial, salvageMaterial) : config.getInt("Salvageables." + key + ".MaximumQuantity", 2)); if (maximumQuantity <= 0 && itemMaterial != null) { maximumQuantity = config.getInt("Salvageables." + key + ".MaximumQuantity", 1); @@ -139,7 +138,7 @@ public class SalvageConfig extends ConfigLoader { } if (noErrorsInSalvageable(reason)) { - Salvageable salvageable = SalvageableFactory.getSalvageable(itemMaterial, salvageMaterial, salvageMetadata, minimumLevel, maximumQuantity, maximumDurability, salvageItemType, salvageMaterialType, xpMultiplier); + Salvageable salvageable = SalvageableFactory.getSalvageable(itemMaterial, salvageMaterial, minimumLevel, maximumQuantity, maximumDurability, salvageItemType, salvageMaterialType, xpMultiplier); salvageables.add(salvageable); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java b/src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java index 87787b8b2..339621547 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/interactions/NotificationType.java @@ -20,6 +20,7 @@ public enum NotificationType { SUPER_ABILITY("SuperAbilityInteraction"), SUPER_ABILITY_ALERT_OTHERS("SuperAbilityAlertOthers"), ITEM_MESSAGE("ItemMessage"), + CHAT_ONLY("ChatOnly"), PARTY_MESSAGE("PartyMessage"); final String niceName; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java index c756017bf..24d21e972 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java @@ -53,7 +53,7 @@ public enum PrimarySkillType { REPAIR(RepairManager.class, Color.SILVER, ImmutableList.of(SubSkillType.REPAIR_ARCANE_FORGING, SubSkillType.REPAIR_REPAIR_MASTERY, SubSkillType.REPAIR_SUPER_REPAIR)), SALVAGE(SalvageManager.class, Color.ORANGE, - ImmutableList.of(SubSkillType.SALVAGE_ADVANCED_SALVAGE, SubSkillType.SALVAGE_ARCANE_SALVAGE)), + ImmutableList.of(SubSkillType.SALVAGE_SCRAP_COLLECTOR, SubSkillType.SALVAGE_ARCANE_SALVAGE)), SMELTING(SmeltingManager.class, Color.YELLOW, ImmutableList.of(SubSkillType.SMELTING_UNDERSTANDING_THE_ART, /*SubSkillType.SMELTING_FLUX_MINING,*/ SubSkillType.SMELTING_FUEL_EFFICIENCY, SubSkillType.SMELTING_SECOND_SMELT)), SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), SuperAbilityType.SERRATED_STRIKES, ToolType.SWORD, diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java index 5495d5336..f87712d9c 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java @@ -61,7 +61,7 @@ public enum SubSkillType { REPAIR_SUPER_REPAIR(1), /* Salvage */ - SALVAGE_ADVANCED_SALVAGE(1), + SALVAGE_SCRAP_COLLECTOR(8), SALVAGE_ARCANE_SALVAGE(8), /* Smelting */ diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java index 9120f83f7..31d8c7e5f 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -94,7 +94,6 @@ public class RepairManager extends SkillManager { PlayerInventory inventory = player.getInventory(); Material repairMaterial = repairable.getRepairMaterial(); - byte repairMaterialMetadata = repairable.getRepairMaterialMetadata(); ItemStack toRemove = new ItemStack(repairMaterial); short startDurability = item.getDurability(); @@ -111,10 +110,6 @@ public class RepairManager extends SkillManager { String materialsNeeded = ""; - if (repairMaterialMetadata != (byte) -1 && !inventory.containsAtLeast(toRemove, 1)) { - materialsNeeded += ":" + repairMaterialMetadata; - } - NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Skills.NeedMore.Extra", prettyName, materialsNeeded); return; } @@ -130,7 +125,7 @@ public class RepairManager extends SkillManager { // Lets get down to business, // To defeat, the huns. - int baseRepairAmount = repairable.getBaseRepairDurability(); // Did they send me daughters? + int baseRepairAmount = repairable.getBaseRepairDurability(item); // Did they send me daughters? short newDurability = repairCalculate(startDurability, baseRepairAmount); // When I asked for sons? // Call event @@ -144,15 +139,16 @@ public class RepairManager extends SkillManager { } // Remove the item - if (repairMaterialMetadata == -1) { - toRemove = inventory.getItem(inventory.first(repairMaterial)).clone(); - toRemove.setAmount(1); - } + toRemove = inventory.getItem(inventory.first(repairMaterial)).clone(); + toRemove.setAmount(1); inventory.removeItem(toRemove); // Give out XP like candy - applyXpGain((float) ((getPercentageRepaired(startDurability, newDurability, repairable.getMaximumDurability()) * repairable.getXpMultiplier()) * ExperienceConfig.getInstance().getRepairXPBase() * ExperienceConfig.getInstance().getRepairXP(repairable.getRepairMaterialType())), XPGainReason.PVE); + applyXpGain((float) ((getPercentageRepaired(startDurability, newDurability, repairable.getMaximumDurability()) + * repairable.getXpMultiplier()) + * ExperienceConfig.getInstance().getRepairXPBase() + * ExperienceConfig.getInstance().getRepairXP(repairable.getRepairMaterialType())), XPGainReason.PVE); // BWONG BWONG BWONG if (Config.getInstance().getRepairAnvilUseSoundsEnabled()) { diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java index d58fb0ed1..24384872e 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.repair.repairables; import com.gmail.nossr50.datatypes.skills.ItemType; import com.gmail.nossr50.datatypes.skills.MaterialType; import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; public interface Repairable { @@ -20,13 +21,6 @@ public interface Repairable { */ public Material getRepairMaterial(); - /** - * Gets the metadata byte value of the material used to repair this item - * - * @return the byte metadata of the repair material - */ - public byte getRepairMaterialMetadata(); - /** * Gets the pretty name of the material used to repair this item * @@ -71,7 +65,7 @@ public interface Repairable { * * @return the base repair durability */ - public short getBaseRepairDurability(); + public short getBaseRepairDurability(ItemStack itemStack); /** * Gets the minimum repair level needed to repair this item diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java index adaa80ef8..df4b8718f 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java @@ -6,16 +6,16 @@ import org.bukkit.Material; public class RepairableFactory { - public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumQuantity, short maximumDurability) { - return getRepairable(itemMaterial, repairMaterial, repairMetadata, null, 0, minimumQuantity, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1); + public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, short maximumDurability) { + return getRepairable(itemMaterial, repairMaterial, null, 0, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1); } - public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { - return getRepairable(itemMaterial, repairMaterial, repairMetadata, null, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); + public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, int minimumLevel, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { + return getRepairable(itemMaterial, repairMaterial, null, minimumLevel, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); } - public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, String repairMaterialPrettyName, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { + public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, String repairMaterialPrettyName, int minimumLevel, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { // TODO: Add in loading from config what type of repairable we want. - return new SimpleRepairable(itemMaterial, repairMaterial, repairMetadata, repairMaterialPrettyName, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); + return new SimpleRepairable(itemMaterial, repairMaterial, repairMaterialPrettyName, minimumLevel, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java index 595a032cc..74a8544c5 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java @@ -2,30 +2,28 @@ package com.gmail.nossr50.skills.repair.repairables; import com.gmail.nossr50.datatypes.skills.ItemType; import com.gmail.nossr50.datatypes.skills.MaterialType; +import com.gmail.nossr50.util.skills.SkillUtils; import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; public class SimpleRepairable implements Repairable { private final Material itemMaterial, repairMaterial; - private final int minimumQuantity, minimumLevel; - private final short maximumDurability, baseRepairDurability; - private final byte repairMetadata; + private final int minimumLevel; + private final short maximumDurability; private String repairMaterialPrettyName; private final ItemType repairItemType; private final MaterialType repairMaterialType; private final double xpMultiplier; - protected SimpleRepairable(Material type, Material repairMaterial, byte repairMetadata, String repairMaterialPrettyName, int minimumLevel, int minimumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { + protected SimpleRepairable(Material type, Material repairMaterial, String repairMaterialPrettyName, int minimumLevel, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { this.itemMaterial = type; this.repairMaterial = repairMaterial; - this.repairMetadata = repairMetadata; this.repairMaterialPrettyName = repairMaterialPrettyName; this.repairItemType = repairItemType; this.repairMaterialType = repairMaterialType; this.minimumLevel = minimumLevel; - this.minimumQuantity = minimumQuantity; this.maximumDurability = maximumDurability; - this.baseRepairDurability = (short) (maximumDurability / minimumQuantity); this.xpMultiplier = xpMultiplier; } @@ -39,11 +37,6 @@ public class SimpleRepairable implements Repairable { return repairMaterial; } - @Override - public byte getRepairMaterialMetadata() { - return repairMetadata; - } - @Override public String getRepairMaterialPrettyName() { return repairMaterialPrettyName; @@ -61,7 +54,7 @@ public class SimpleRepairable implements Repairable { @Override public int getMinimumQuantity() { - return minimumQuantity; + return Math.max(SkillUtils.getRepairAndSalvageQuantities(itemMaterial, repairMaterial), 2); } @Override @@ -70,8 +63,8 @@ public class SimpleRepairable implements Repairable { } @Override - public short getBaseRepairDurability() { - return baseRepairDurability; + public short getBaseRepairDurability(ItemStack itemStack) { + return (short) (maximumDurability / getMinimumQuantity()); } @Override diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java b/src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java index 4eddcfb6e..dde4962c6 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java @@ -10,7 +10,7 @@ public class Salvage { /*public static int salvageMaxPercentageLevel = AdvancedConfig.getInstance().getSalvageMaxPercentageLevel(); public static double salvageMaxPercentage = AdvancedConfig.getInstance().getSalvageMaxPercentage(); - public static int advancedSalvageUnlockLevel = RankUtils.getRankUnlockLevel(SubSkillType.SALVAGE_ADVANCED_SALVAGE, 1);*/ + public static int advancedSalvageUnlockLevel = RankUtils.getRankUnlockLevel(SubSkillType.SALVAGE_SCRAP_COLLECTOR, 1);*/ public static boolean arcaneSalvageDowngrades = AdvancedConfig.getInstance().getArcaneSalvageEnchantDowngradeEnabled(); public static boolean arcaneSalvageEnchantLoss = AdvancedConfig.getInstance().getArcaneSalvageEnchantLossEnabled(); diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java index d343e77c1..df626872a 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -10,10 +10,7 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; -import com.gmail.nossr50.util.EventUtils; -import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.StringUtils; +import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceUtil; @@ -90,12 +87,14 @@ public class SalvageManager extends SkillManager { return; } - if (item.getDurability() != 0 && (!RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_ADVANCED_SALVAGE) || !Permissions.advancedSalvage(player))) { + if (item.getDurability() != 0 && (!RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR) || !Permissions.advancedSalvage(player))) { NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.Adept.Damaged"); return; } - int salvageableAmount = Salvage.calculateSalvageableAmount(item.getDurability(), salvageable.getMaximumDurability(), salvageable.getMaximumQuantity()); + int maxAmountSalvageable = Salvage.calculateSalvageableAmount(item.getDurability(), salvageable.getMaximumDurability(), salvageable.getMaximumQuantity()); + + int salvageableAmount = maxAmountSalvageable; if (salvageableAmount == 0) { NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.TooDamaged"); @@ -105,7 +104,6 @@ public class SalvageManager extends SkillManager { salvageableAmount = Math.min(salvageableAmount, getSalvageableAmount()); // Always get at least something back, if you're capable of salvaging it. - player.getInventory().setItemInMainHand(new ItemStack(Material.AIR)); location.add(0.5, 1, 0.5); @@ -116,7 +114,30 @@ public class SalvageManager extends SkillManager { enchantBook = arcaneSalvageCheck(enchants); } - ItemStack salvageResults = new ItemStack(salvageable.getSalvageMaterial(), salvageableAmount); + //Lottery on Salvageable Amount + + int lotteryResults = 1; + int chanceOfSuccess = 80; + + for(int x = 1; x < salvageableAmount-1; x++) { + + if(RandomChanceUtil.rollDice(chanceOfSuccess, 100)) { + chanceOfSuccess-=20; + Math.max(chanceOfSuccess, 33); + + lotteryResults+=1; + } + } + + if(lotteryResults == salvageableAmount) { + NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Perfect", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType())); + } else if(RankUtils.isPlayerMaxRankInSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) { + NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Normal", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType())); + } else { + NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Untrained", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType())); + } + + ItemStack salvageResults = new ItemStack(salvageable.getSalvageMaterial(), lotteryResults); //Call event if (EventUtils.callSalvageCheckEvent(player, item, salvageResults, enchantBook).isCancelled()) { diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/Salvageable.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/Salvageable.java index cb3459e26..07831d5ea 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/Salvageable.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/Salvageable.java @@ -19,13 +19,6 @@ public interface Salvageable { */ public Material getSalvageMaterial(); - /** - * Gets the metadata byte value of the items dropped when salvaging this item - * - * @return the byte metadata of the salvage drop - */ - public byte getSalvageMaterialMetadata(); - /** * Gets the ItemType value for this salvageable item * diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableFactory.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableFactory.java index 982b3b5e7..f22108157 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableFactory.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableFactory.java @@ -5,12 +5,12 @@ import com.gmail.nossr50.datatypes.skills.MaterialType; import org.bukkit.Material; public class SalvageableFactory { - public static Salvageable getSalvageable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int maximumQuantity, short maximumDurability) { - return getSalvageable(itemMaterial, repairMaterial, repairMetadata, 0, maximumQuantity, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1); + public static Salvageable getSalvageable(Material itemMaterial, Material recipeMaterial, int maximumQuantity, short maximumDurability) { + return getSalvageable(itemMaterial, recipeMaterial, 0, maximumQuantity, maximumDurability, ItemType.OTHER, MaterialType.OTHER, 1); } - public static Salvageable getSalvageable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumLevel, int maximumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { + public static Salvageable getSalvageable(Material itemMaterial, Material recipeMaterial, int minimumLevel, int maximumQuantity, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { // TODO: Add in loading from config what type of repairable we want. - return new SimpleSalvageable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, maximumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); + return new SimpleSalvageable(itemMaterial, recipeMaterial, minimumLevel, maximumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); } } diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageable.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageable.java index 6a6bce6b5..d7484425c 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageable.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageable.java @@ -9,15 +9,13 @@ public class SimpleSalvageable implements Salvageable { private final Material itemMaterial, salvageMaterial; private final int maximumQuantity, minimumLevel; private final short maximumDurability, baseSalvageDurability; - private final byte salvageMetadata; private final ItemType salvageItemType; private final MaterialType salvageMaterialType; private final double xpMultiplier; - protected SimpleSalvageable(Material type, Material salvageMaterial, byte salvageMetadata, int minimumLevel, int maximumQuantity, short maximumDurability, ItemType salvageItemType, MaterialType salvageMaterialType, double xpMultiplier) { + protected SimpleSalvageable(Material type, Material salvageMaterial, int minimumLevel, int maximumQuantity, short maximumDurability, ItemType salvageItemType, MaterialType salvageMaterialType, double xpMultiplier) { this.itemMaterial = type; this.salvageMaterial = salvageMaterial; - this.salvageMetadata = salvageMetadata; this.salvageItemType = salvageItemType; this.salvageMaterialType = salvageMaterialType; this.minimumLevel = minimumLevel; @@ -37,11 +35,6 @@ public class SimpleSalvageable implements Salvageable { return salvageMaterial; } - @Override - public byte getSalvageMaterialMetadata() { - return salvageMetadata; - } - @Override public ItemType getSalvageItemType() { return salvageItemType; diff --git a/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java b/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java index 31192c431..e63dc1bdb 100644 --- a/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java +++ b/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java @@ -27,18 +27,17 @@ public class TextComponentFactory { /** * Makes a text component using strings from a locale and supports passing an undefined number of variables to the LocaleLoader * @param localeKey target locale string address - * @param notificationType type of notification * @param values vars to be passed to the locale loader * @return */ - public static TextComponent getNotificationMultipleValues(String localeKey, NotificationType notificationType, String... values) + public static TextComponent getNotificationMultipleValues(String localeKey, String... values) { String preColoredString = LocaleLoader.getString(localeKey, (Object[]) values); TextComponent msg = new TextComponent(preColoredString); return new TextComponent(msg); } - public static TextComponent getNotificationTextComponentFromLocale(String localeKey, NotificationType notificationType) + public static TextComponent getNotificationTextComponentFromLocale(String localeKey) { return getNotificationTextComponent(LocaleLoader.getString(localeKey)); } diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java index cc5a60202..f33432d05 100644 --- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -38,7 +38,7 @@ public class NotificationManager { ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; - TextComponent message = TextComponentFactory.getNotificationTextComponentFromLocale(key, notificationType); + TextComponent message = TextComponentFactory.getNotificationTextComponentFromLocale(key); McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message); sendNotification(player, customEvent); @@ -67,6 +67,15 @@ public class NotificationManager { sendPlayerInformation(targetPlayer, notificationType, key, values); } + public static void sendPlayerInformationChatOnly(Player player, String key, String... values) + { + if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications()) + return; + + String preColoredString = LocaleLoader.getString(key, (Object[]) values); + player.sendMessage(preColoredString); + } + public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values) { if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications()) @@ -74,7 +83,7 @@ public class NotificationManager { ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM; - TextComponent message = TextComponentFactory.getNotificationMultipleValues(key, notificationType, values); + TextComponent message = TextComponentFactory.getNotificationMultipleValues(key, values); McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message); sendNotification(player, customEvent); diff --git a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java index e854b1874..60d54250f 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java @@ -358,4 +358,11 @@ public class RankUtils { { return getRankUnlockLevel(superAbilityType.getSubSkillTypeDefinition(), 1); } + + public static boolean isPlayerMaxRankInSubSkill(Player player, SubSkillType subSkillType) { + int playerRank = getRank(player, subSkillType); + int highestRank = getHighestRank(subSkillType); + + return playerRank == highestRank; + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index 326d6d6f0..20760452c 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -17,6 +17,7 @@ import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.UserManager; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -30,6 +31,7 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; public class SkillUtils { @@ -290,34 +292,33 @@ public class SkillUtils { } public static int getRepairAndSalvageQuantities(ItemStack item) { - return getRepairAndSalvageQuantities(item, getRepairAndSalvageItem(item), (byte) -1); + return getRepairAndSalvageQuantities(item.getType(), getRepairAndSalvageItem(item)); } - public static int getRepairAndSalvageQuantities(ItemStack item, Material repairMaterial, byte repairMetadata) { - // Workaround for Bukkit bug where damaged items would not return any recipes - item = item.clone(); - item.setDurability((short) 0); - + public static int getRepairAndSalvageQuantities(Material itemMaterial, Material recipeMaterial) { int quantity = 0; - List recipes = mcMMO.p.getServer().getRecipesFor(item); - if (recipes.isEmpty()) { - return quantity; - } + for(Iterator recipeIterator = Bukkit.getServer().recipeIterator(); recipeIterator.hasNext();) { + Recipe bukkitRecipe = recipeIterator.next(); - Recipe recipe = recipes.get(0); + if(bukkitRecipe.getResult().getType() != itemMaterial) + continue; - if (recipe instanceof ShapelessRecipe) { - for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) { - if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getType().equals(repairMaterial))) { - quantity += ingredient.getAmount(); + if(bukkitRecipe instanceof ShapelessRecipe) { + for (ItemStack ingredient : ((ShapelessRecipe) bukkitRecipe).getIngredientList()) { + if (ingredient != null + && (recipeMaterial == null || ingredient.getType() == recipeMaterial) + && (ingredient.getType() == recipeMaterial)) { + quantity += ingredient.getAmount(); + } } - } - } - else if (recipe instanceof ShapedRecipe) { - for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) { - if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getType().equals(repairMaterial))) { - quantity += ingredient.getAmount(); + } else if(bukkitRecipe instanceof ShapedRecipe) { + for (ItemStack ingredient : ((ShapedRecipe) bukkitRecipe).getIngredientMap().values()) { + if (ingredient != null + && (recipeMaterial == null || ingredient.getType() == recipeMaterial) + && (ingredient.getType() == recipeMaterial)) { + quantity += ingredient.getAmount(); + } } } } diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 47215d079..05d92949a 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -373,14 +373,14 @@ Repair.Arcane.Perfect=[[GREEN]]You have sustained the arcane energies in this it Salvage.Pretty.Name=Salvage Salvage.SubSkill.UnderstandingTheArt.Name=Understanding The Art Salvage.SubSkill.UnderstandingTheArt.Description=You're not just digging through your neighbors trash, you're taking care of the environment.\nPowers up various properties of Salvaging. -Salvage.SubSkill.AdvancedSalvage.Name=Advanced Salvage -Salvage.SubSkill.AdvancedSalvage.Description=Salvage damaged items +Salvage.SubSkill.ScrapCollector.Name=Scrap Collector +Salvage.SubSkill.ScrapCollector.Description=Salvage materials from an item, a perfect salvage depends on skill and luck. +Salvage.SubSkill.ScrapCollector.Stat=Scrap Collector: [[GREEN]]Salvage up to [[YELLOW]]{0}[[GREEN]] items. Some luck is involved. Salvage.SubSkill.ArcaneSalvage.Name=Arcane Salvaging Salvage.SubSkill.ArcaneSalvage.Description=Extract enchantments from items Salvage.SubSkill.ArcaneSalvage.Stat=Arcane Salvaging: [[YELLOW]]Rank {0}/{1} -Salvage.Ability.Locked.0=LOCKED UNTIL {0}+ SKILL (ADVANCED SALVAGE) -Salvage.Ability.Bonus.0=Advanced Salvage -Salvage.Ability.Bonus.1={0} Max Materials Recovered from Salvaging +Salvage.Ability.Bonus.0=Scrap Collector +Salvage.Ability.Bonus.1=Salvage up to [[YELLOW]]{0}[[GREEN]] items. Some luck is involved. Salvage.Arcane.ExtractFull=[[GRAY]]AS Full-Enchant Chance Salvage.Arcane.ExtractPartial=[[GRAY]]AS Partial-Enchant Chance Salvage.Skills.Success=[[GREEN]]Item salvaged! @@ -393,6 +393,9 @@ Salvage.Skills.ArcaneSuccess=[[GREEN]]You able to extract all of the knowledge c Salvage.Listener.Anvil=[[DARK_RED]]You have placed a Salvage anvil, use this to Salvage tools and armor. Salvage.Listener=Salvage: Salvage.SkillName=SALVAGE +Salvage.Skills.Lottery.Normal=[[GOLD]]You were able to salvage [[GREEN]]{0}[[GOLD]] materials from [[DARK_AQUA]]{1}[[GOLD]]. +Salvage.Skills.Lottery.Perfect=[[GREEN]][[BOLD]]Perfect![[RESET]][[GOLD]] You salvaged [[GREEN]]{1}[[GOLD]] effortlessly, retrieving [[DARK_AQUA]]{0}[[GOLD]] materials. +Salvage.Skills.Lottery.Untrained=[[GRAY]]You aren't properly trained in salvaging. You were only able to recover [[RED]]{0}[[GRAY]] materials from [[GREEN]]{1}[[GRAY]]. #Anvil (Shared between SALVAGE and REPAIR) Anvil.Unbreakable=This item is unbreakable! #SWORDS diff --git a/src/main/resources/repair.vanilla.yml b/src/main/resources/repair.vanilla.yml index 50850eb7a..2a1c496cf 100644 --- a/src/main/resources/repair.vanilla.yml +++ b/src/main/resources/repair.vanilla.yml @@ -29,10 +29,6 @@ ## Valid values are => 0 ## This defaults to 0 # -# MinimumQuantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses. -## This is typically the number of the repair material needed to create a new item, for example for a sword it is 2, for an axe it is 3 -## This defaults to 2 -# # XpMultiplier: This is the amount to multiply the xp bonus by. ## This defaults to 1 # diff --git a/src/main/resources/skillranks.yml b/src/main/resources/skillranks.yml index 0197e7055..8bdbd953a 100644 --- a/src/main/resources/skillranks.yml +++ b/src/main/resources/skillranks.yml @@ -282,11 +282,25 @@ Smelting: Rank_7: 850 Rank_8: 1000 Salvage: - AdvancedSalvage: + ScrapCollector: Standard: - Rank_1: 35 + Rank_1: 2 + Rank_2: 10 + Rank_3: 15 + Rank_4: 20 + Rank_5: 25 + Rank_6: 30 + Rank_7: 35 + Rank_8: 40 RetroMode: - Rank_1: 350 + Rank_1: 20 + Rank_2: 100 + Rank_3: 150 + Rank_4: 200 + Rank_5: 250 + Rank_6: 300 + Rank_7: 350 + Rank_8: 400 ArcaneSalvage: Standard: Rank_1: 10 From 3fe47c939abd16dcfbb2047229c5106fb6205f74 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 10 Jun 2019 22:46:03 -0700 Subject: [PATCH 17/21] You can not salvage without 1 rank in Scrap Collector now (unlocks at level 2) --- Changelog.txt | 5 ++++- pom.xml | 2 +- .../commands/skills/SalvageCommand.java | 4 ++-- .../nossr50/listeners/PlayerListener.java | 19 +++++++++++-------- .../skills/salvage/SalvageManager.java | 6 ------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 3f9893eb5..8e820ed0f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,9 @@ Version 2.1.76 + Advanced Salvage has been renamed to Scrap Collector Fixed a bug where Repair was repairing too much - Fixed a bug where Arcane Salvage was used to determine how many materials a player could salvage from an item + Fixed a bug where Arcane Salvage was used to determine how many materials a player could salvage from an item instead of Scrap Collector (formerly Advanced Salvage) + Fixed a bug where messages about an item being too damage to salvage were being sent twice + You can not salvage without at least 1 rank in Scrap Collector now (formerly Advanced Salvage) Removed the minimum quantity field from the repair config Removed the item data (metadata) field from repair config as its not used anymore Salvage will no longer return the max amount of materials possible, instead you are guaranteed one item and then some luck is involved on how many items are returned. diff --git a/pom.xml b/pom.xml index e30ac6d87..85261dd01 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.76-SNAPSHOT + 2.1.76 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java index 1d10521e4..6d16655b7 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java @@ -42,8 +42,8 @@ public class SalvageCommand extends SkillCommand { if (canScrapCollector) { messages.add(getStatMessage(false, true, SubSkillType.SALVAGE_SCRAP_COLLECTOR, - String.valueOf(RankUtils.getRank(player, SubSkillType.REPAIR_ARCANE_FORGING)), - RankUtils.getHighestRankStr(SubSkillType.REPAIR_ARCANE_FORGING))); + String.valueOf(RankUtils.getRank(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)), + RankUtils.getHighestRankStr(SubSkillType.SALVAGE_SCRAP_COLLECTOR))); } if (canArcaneSalvage) { diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index ca67ab155..8f1f91f0d 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -10,6 +10,7 @@ import com.gmail.nossr50.datatypes.chat.ChatMode; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; @@ -25,6 +26,7 @@ import com.gmail.nossr50.skills.salvage.SalvageManager; import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; @@ -619,17 +621,18 @@ public class PlayerListener implements Listener { /* SALVAGE CHECKS */ else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player) + && RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR) && mcMMO.getSalvageableManager().isSalvageable(heldItem) && heldItem.getAmount() <= 1) { - SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager(); - event.setCancelled(true); + SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager(); + event.setCancelled(true); - // Make sure the player knows what he's doing when trying to salvage an enchanted item - if (salvageManager.checkConfirmation(true)) { - SkillUtils.handleAbilitySpeedDecrease(player); - salvageManager.handleSalvage(block.getLocation(), heldItem); - player.updateInventory(); - } + // Make sure the player knows what he's doing when trying to salvage an enchanted item + if (salvageManager.checkConfirmation(true)) { + SkillUtils.handleAbilitySpeedDecrease(player); + salvageManager.handleSalvage(block.getLocation(), heldItem); + player.updateInventory(); + } } } /* BLAST MINING CHECK */ diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java index df626872a..70b4990b1 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -87,18 +87,12 @@ public class SalvageManager extends SkillManager { return; } - if (item.getDurability() != 0 && (!RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR) || !Permissions.advancedSalvage(player))) { - NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.Adept.Damaged"); - return; - } - int maxAmountSalvageable = Salvage.calculateSalvageableAmount(item.getDurability(), salvageable.getMaximumDurability(), salvageable.getMaximumQuantity()); int salvageableAmount = maxAmountSalvageable; if (salvageableAmount == 0) { NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.TooDamaged"); - player.sendMessage(LocaleLoader.getString("Salvage.Skills.TooDamaged")); return; } From 97c98969fff3ca92f2ca8ae38afed34a3babb875 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 10 Jun 2019 22:49:47 -0700 Subject: [PATCH 18/21] 2.1.76 --- Changelog.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 8e820ed0f..454180ccd 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,13 +1,13 @@ Version 2.1.76 Advanced Salvage has been renamed to Scrap Collector + Scrap Collector has 8 ranks, the first rank is unlocked at level 2 (Level 20 in RetroMode) + You can not salvage without at least 1 rank in Scrap Collector now (formerly Advanced Salvage) Fixed a bug where Repair was repairing too much Fixed a bug where Arcane Salvage was used to determine how many materials a player could salvage from an item instead of Scrap Collector (formerly Advanced Salvage) Fixed a bug where messages about an item being too damage to salvage were being sent twice - You can not salvage without at least 1 rank in Scrap Collector now (formerly Advanced Salvage) Removed the minimum quantity field from the repair config Removed the item data (metadata) field from repair config as its not used anymore Salvage will no longer return the max amount of materials possible, instead you are guaranteed one item and then some luck is involved on how many items are returned. - Advanced Salvage has been renamed to Scrap Collector Updated Chinese locale (thanks to the user named 89009332 from github) New locale strings @@ -18,13 +18,15 @@ Version 2.1.76 Salvage.SubSkill.ScrapCollector.Description Salvage.SubSkill.ScrapCollector.Stat - (API) SALVAGE_ARCANE_SALVAGE in SubSkillTypes has been renamed to SALVAGE_SCRAP_COLLECTOR + (API) SALVAGE_ARCANE_SALVAGE in SubSkillType has been renamed to SALVAGE_SCRAP_COLLECTOR NOTES: You do not need to update your configs for this update. + How Salvage works - If you have enough skill to gain up to 5 items from salvaging something, and that item has enough durability to yield up to 5 materials, salvage will play out like this + As an example, say you had enough skill to gain up to 5 items from salvaging something, and that item has enough durability to yield up to 5 materials, salvage will play out like this... First off, you will be guaranteed 1 material, after this you have 80% chance to get the next material, if successful, another dice roll is conducted but lowers your odds by 20%, you chance to succeed will never fall below 33% + If you fail a dice roll, it will still conduct dice rolls for the remaining maximum amount of materials returned but your odds of success are only lowered upon a successful dice roll, the sum of the successful dice rolls is used to calculate how many items you are given back, the first item is guaranteed and has no dice rolls, which means for example the Diamond Shovel will always succeed. Version 2.1.75 Fixed a bug that prevented Fortune from working correctly if a Double Drop was triggered From 9062dbcaaedcb13bebdc35da81b7eaac7866aecb Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 11 Jun 2019 03:50:13 -0700 Subject: [PATCH 19/21] Add minimum quantity back to the repair config --- Changelog.txt | 7 +++++++ pom.xml | 2 +- .../config/skills/repair/RepairConfig.java | 10 +++++++++- .../repair/repairables/RepairableFactory.java | 9 ++++++++- .../repair/repairables/SimpleRepairable.java | 18 +++++++++++++++++- 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 454180ccd..b01a34d69 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,10 @@ +Version 2.1.77 + Added minimum quantity back to Repair config + + NOTES: I removed this last patch because I did not consider that server admins might be allowing users to repair items without crafting recipes (as of last patch mcMMO determines minimum quantity via counting ingredients in a recipe) + If you do not define minimum quantity in the repair config, mcMMO will grab the minimum quantity automatically as I programmed it to do as of last patch, otherwise if it is defined, mcMMO will respect that and use that for calculations. + The minimum quanitty should be set to the number of ingredients used to craft the recipe, for example 8 for diamond chestplate etc, you do not need to define this unless you are allowing players to repair custom items. + Version 2.1.76 Advanced Salvage has been renamed to Scrap Collector Scrap Collector has 8 ranks, the first rank is unlocked at level 2 (Level 20 in RetroMode) diff --git a/pom.xml b/pom.xml index 85261dd01..d8d1fe306 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.76 + 2.1.77-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java index 0c88041d8..6aebb9841 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java @@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.skills.MaterialType; import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.skills.repair.repairables.RepairableFactory; import com.gmail.nossr50.util.ItemUtils; +import com.gmail.nossr50.util.skills.SkillUtils; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.ItemStack; @@ -132,8 +133,15 @@ public class RepairConfig extends ConfigLoader { reason.add(key + " has an invalid MinimumLevel of " + minimumLevel); } + // Minimum Quantity + int minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity"); + + if(minimumQuantity == 0) { + minimumQuantity = -1; + } + if (noErrorsInRepairable(reason)) { - Repairable repairable = RepairableFactory.getRepairable(itemMaterial, repairMaterial, minimumLevel, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); + Repairable repairable = RepairableFactory.getRepairable(itemMaterial, repairMaterial, null, minimumLevel, maximumDurability, repairItemType, repairMaterialType, xpMultiplier, minimumQuantity); repairables.add(repairable); } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java index df4b8718f..85ed7d8ae 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableFactory.java @@ -14,8 +14,15 @@ public class RepairableFactory { return getRepairable(itemMaterial, repairMaterial, null, minimumLevel, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); } - public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, String repairMaterialPrettyName, int minimumLevel, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { + public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, String repairMaterialPrettyName, + int minimumLevel, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { // TODO: Add in loading from config what type of repairable we want. return new SimpleRepairable(itemMaterial, repairMaterial, repairMaterialPrettyName, minimumLevel, maximumDurability, repairItemType, repairMaterialType, xpMultiplier); } + + public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, String repairMaterialPrettyName, + int minimumLevel, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier, int minQuantity) { + // TODO: Add in loading from config what type of repairable we want. + return new SimpleRepairable(itemMaterial, repairMaterial, repairMaterialPrettyName, minimumLevel, maximumDurability, repairItemType, repairMaterialType, xpMultiplier, minQuantity); + } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java index 74a8544c5..6d5472b53 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java @@ -15,6 +15,7 @@ public class SimpleRepairable implements Repairable { private final ItemType repairItemType; private final MaterialType repairMaterialType; private final double xpMultiplier; + private int minQuantity = -1; protected SimpleRepairable(Material type, Material repairMaterial, String repairMaterialPrettyName, int minimumLevel, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier) { this.itemMaterial = type; @@ -27,6 +28,18 @@ public class SimpleRepairable implements Repairable { this.xpMultiplier = xpMultiplier; } + protected SimpleRepairable(Material type, Material repairMaterial, String repairMaterialPrettyName, int minimumLevel, short maximumDurability, ItemType repairItemType, MaterialType repairMaterialType, double xpMultiplier, int minQuantity) { + this.itemMaterial = type; + this.repairMaterial = repairMaterial; + this.repairMaterialPrettyName = repairMaterialPrettyName; + this.repairItemType = repairItemType; + this.repairMaterialType = repairMaterialType; + this.minimumLevel = minimumLevel; + this.maximumDurability = maximumDurability; + this.xpMultiplier = xpMultiplier; + this.minQuantity = minQuantity; + } + @Override public Material getItemMaterial() { return itemMaterial; @@ -54,7 +67,10 @@ public class SimpleRepairable implements Repairable { @Override public int getMinimumQuantity() { - return Math.max(SkillUtils.getRepairAndSalvageQuantities(itemMaterial, repairMaterial), 2); + if(minQuantity != -1) + return Math.max(SkillUtils.getRepairAndSalvageQuantities(itemMaterial, repairMaterial), 2); + else + return minQuantity; } @Override From e1dcb65888780e5fa2ce466904494e4240b1f341 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 11 Jun 2019 03:52:45 -0700 Subject: [PATCH 20/21] Add back in the comment about min quantity --- src/main/resources/repair.vanilla.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/resources/repair.vanilla.yml b/src/main/resources/repair.vanilla.yml index 2a1c496cf..49eec21d7 100644 --- a/src/main/resources/repair.vanilla.yml +++ b/src/main/resources/repair.vanilla.yml @@ -1,6 +1,5 @@ # # Repair configuration -# Last updated on ${project.version}-b${BUILD_NUMBER} # # Any file named repair.*.yml in the mcmmmo folder will be loaded as a repair config # All repair configs have a main section titled "Repairables" @@ -11,7 +10,7 @@ ## Valid values are ARMOR, TOOL, and OTHER. ## This defaults to OTHER. # -# MaterialType: This is the type of the material of the item to be repaired, this is only important for permissions. +# ItemMaterialCategory: This is the type of the material of the item to be repaired, this is only important for permissions. ## Valid values are STRING, LEATHER, WOOD, STONE, IRON, GOLD, DIAMOND, and OTHER ## This defaults to OTHER. # @@ -29,6 +28,10 @@ ## Valid values are => 0 ## This defaults to 0 # +# MinimumQuantity: This is the minimum number of items needed to repair this item ignoring all other repair bonuses. +## This is typically the number of the repair material needed to create a new item, for example for a sword it is 2, for an axe it is 3 +## If this isn't set, mcMMO will try to look up the minimum quantity for the item via recipes. It is not necessary to define this field. +# # XpMultiplier: This is the amount to multiply the xp bonus by. ## This defaults to 1 # From 705285878fc5b0022e2dbefda03584f9f62ebbbc Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 11 Jun 2019 03:57:28 -0700 Subject: [PATCH 21/21] Diagnosing myself with dyslexia --- pom.xml | 2 +- .../nossr50/skills/repair/repairables/SimpleRepairable.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d8d1fe306..ded08ae53 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.77-SNAPSHOT + 2.1.77 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java index 6d5472b53..21b9fe5b8 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java @@ -67,7 +67,7 @@ public class SimpleRepairable implements Repairable { @Override public int getMinimumQuantity() { - if(minQuantity != -1) + if(minQuantity == -1) return Math.max(SkillUtils.getRepairAndSalvageQuantities(itemMaterial, repairMaterial), 2); else return minQuantity;