From 5ba6305ad4d5047cd22fdf6614a73c8dd4953ed6 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 4 May 2024 10:26:43 -0700 Subject: [PATCH] 2.2.007 --- Changelog.txt | 7 ++- pom.xml | 18 +++--- .../config/experience/ExperienceConfig.java | 2 +- src/main/java/com/gmail/nossr50/mcMMO.java | 8 +++ .../nossr50/protocollib/ProtocolHandler.java | 36 ++++++++++++ .../protocollib/ProtocolLibManager.java | 58 +++++++++++++------ .../skills/alchemy/AlchemyPotionBrewer.java | 2 +- .../woodcutting/WoodcuttingManager.java | 10 +++- .../com/gmail/nossr50/util/PotionUtil.java | 3 +- src/main/resources/experience.yml | 23 ++++---- 10 files changed, 122 insertions(+), 45 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/protocollib/ProtocolHandler.java diff --git a/Changelog.txt b/Changelog.txt index 4e3d3c86d..fe6f1b950 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,11 +1,16 @@ Version 2.2.007 Compatibility with the 1.20.5 / 1.20.6 MC Update Fixed bug where Alchemy was not brewing certain potions (haste, etc) + Tree Feller no longer restricts how many saplings can drop + Tree Feller now drops leaves 25% of the time (up from 10%) + Alchemy XP has been DRAMATICALLY increased, it was extremely grindy by default + Alchemy experience values in experience.yml are now found under 'Experience_Values.Alchemy.Potion_Brewing' Fixed bug where the probability of success of Graceful Roll was not being calculated correctly - Added armadillo to combat experience in experience.yml Fixed bug where Green Thumb did not replant if seed was in the off hand + Added armadillo to combat experience in experience.yml NOTES: + While fixing various Alchemy bugs, I noticed Alchemy leveled SUPER slow, I have increased it dramatically. Feel free to change it back by modifying the new values in experience.yml I did my best to keep mcMMO compatible with older versions of Minecraft for this update. This update to MC was quite large, with breaking changes to a lot of code relating to Alchemy, and some other things. I expect there to be bugs, please report them on GitHub or Discord, but preferably GitHub. diff --git a/pom.xml b/pom.xml index 466d48791..8693a420f 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.2.007-SNAPSHOT + 2.2.007 mcMMO https://github.com/mcMMO-Dev/mcMMO @@ -304,37 +304,37 @@ net.kyori adventure-text-serializer-gson - 4.15.0 + 4.16.0 net.kyori adventure-text-serializer-gson-legacy-impl - 4.15.0 + 4.16.0 net.kyori adventure-text-serializer-json - 4.15.0 + 4.16.0 net.kyori adventure-text-serializer-json-legacy-impl - 4.15.0 + 4.16.0 net.kyori adventure-api - 4.15.0 + 4.16.0 net.kyori adventure-nbt - 4.15.0 + 4.16.0 net.kyori adventure-key - 4.15.0 + 4.16.0 net.kyori @@ -375,7 +375,7 @@ org.spigotmc spigot-api - 1.19.2-R0.1-SNAPSHOT + 1.20.5-R0.1-SNAPSHOT provided diff --git a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java index b64e3b62b..4eddee5db 100644 --- a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java +++ b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java @@ -467,7 +467,7 @@ public class ExperienceConfig extends BukkitConfig { /* Alchemy */ public double getPotionXP(PotionStage stage) { - return config.getDouble("Experience_Values.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); + return config.getDouble("Experience_Values.Alchemy.Potion_Brewing.Stage_" + stage.toNumerical(), 10D); } /* Archery */ diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 3a806e8be..423a46333 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -95,6 +95,7 @@ public class mcMMO extends JavaPlugin { private static ChatManager chatManager; private static CommandManager commandManager; //ACF private static TransientEntityTracker transientEntityTracker; +// private static ProtocolLibManager protocolLibManager; private SkillTools skillTools; @@ -364,6 +365,9 @@ public class mcMMO extends JavaPlugin { if(getServer().getPluginManager().getPlugin("WorldGuard") != null) { WorldGuardManager.getInstance().registerFlags(); } + + // ProtocolLib + // protocolLibManager = new ProtocolLibManager(this); } /** @@ -825,4 +829,8 @@ public class mcMMO extends JavaPlugin { public @NotNull FoliaLib getFoliaLib() { return foliaLib; } + +// public ProtocolLibManager getProtocolLibManager() { +// return protocolLibManager; +// } } diff --git a/src/main/java/com/gmail/nossr50/protocollib/ProtocolHandler.java b/src/main/java/com/gmail/nossr50/protocollib/ProtocolHandler.java new file mode 100644 index 000000000..bae3793f9 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/protocollib/ProtocolHandler.java @@ -0,0 +1,36 @@ +//package com.gmail.nossr50.protocollib; +// +//import com.comphenix.protocol.PacketType; +//import com.comphenix.protocol.ProtocolLibrary; +//import com.comphenix.protocol.ProtocolManager; +//import com.comphenix.protocol.events.ListenerPriority; +//import com.comphenix.protocol.events.PacketAdapter; +//import com.comphenix.protocol.events.PacketContainer; +//import com.comphenix.protocol.events.PacketEvent; +//import com.gmail.nossr50.mcMMO; +//import org.bukkit.entity.Player; +// +//public class ProtocolHandler { +// private final mcMMO pluginRef; +// private final ProtocolManager protocolManager; +// +// public ProtocolHandler(mcMMO pluginRef) { +// this.pluginRef = pluginRef; +// this.protocolManager = ProtocolLibrary.getProtocolManager(); +// // TODO: encapsulate this in a method +// protocolManager.addPacketListener(new PacketAdapter(pluginRef, ListenerPriority.NORMAL, PacketType.Play.Server.WINDOW_DATA) { +// @Override +// public void onPacketSending(PacketEvent event) { +// Player player = event.getPlayer(); +// PacketContainer packet = event.getPacket(); +// if (packet.getIntegers().read(0) == 400) { +// event.setCancelled(true); +// } +// } +// }); +// } +// public void sendPacketToPlayer(Player player) { +// final PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.WINDOW_DATA); +// protocolManager.sendServerPacket(player, packet); +// } +//} diff --git a/src/main/java/com/gmail/nossr50/protocollib/ProtocolLibManager.java b/src/main/java/com/gmail/nossr50/protocollib/ProtocolLibManager.java index 7b82ac9d9..77f3c21bf 100644 --- a/src/main/java/com/gmail/nossr50/protocollib/ProtocolLibManager.java +++ b/src/main/java/com/gmail/nossr50/protocollib/ProtocolLibManager.java @@ -1,18 +1,40 @@ -package com.gmail.nossr50.protocollib; - -import com.gmail.nossr50.mcMMO; -import org.bukkit.plugin.Plugin; - -// TODO: Finish this class -public class ProtocolLibManager { - Plugin protocolLibPluginRef; - mcMMO pluginRef; - public ProtocolLibManager(mcMMO pluginRef) { - this.pluginRef = pluginRef; - } - - public boolean isProtocolLibPresent() { - protocolLibPluginRef = pluginRef.getServer().getPluginManager().getPlugin("ProtocolLib"); - return protocolLibPluginRef != null; - } -} +//package com.gmail.nossr50.protocollib; +// +//import com.gmail.nossr50.mcMMO; +//import org.bukkit.Bukkit; +//import org.bukkit.entity.Player; +//import org.bukkit.plugin.Plugin; +// +//public class ProtocolLibManager { +// final Plugin protocolLibPluginRef; +// final mcMMO pluginRef; +// final ProtocolHandler protocolHandler; +// +// public ProtocolLibManager(mcMMO pluginRef) { +// this.pluginRef = pluginRef; +// +// if (isProtocolLibPresent()) { +// protocolLibPluginRef = pluginRef.getServer().getPluginManager().getPlugin("ProtocolLib"); +// protocolHandler = new ProtocolHandler(pluginRef); +// pluginRef.getLogger().info("ProtocolLib found, enabling ProtocolLib features."); +// } else { +// protocolLibPluginRef = null; +// protocolHandler = null; +// pluginRef.getLogger().info("No ProtocolLib found, some completely optional cosmetic features will not be enabled."); +// } +// } +// +// public boolean usingProtocolLib() { +// return protocolLibPluginRef != null && protocolHandler != null; +// } +// +// private boolean isProtocolLibPresent() { +// return Bukkit.getServer().getPluginManager().getPlugin("ProtocolLib") != null; +// } +// +// public void sendPacketToPlayer(Player player) { +// if (usingProtocolLib()) { +// protocolHandler.sendPacketToPlayer(player); +// } +// } +//} diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java index 1b5ee9850..82b2e0e85 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -178,7 +178,7 @@ public final class AlchemyPotionBrewer { PotionStage potionStage = PotionStage.getPotionStage(input, output); // Update player alchemy skills or effects based on brewing success - if (UserManager.hasPlayerDataKey(player)) { + if (UserManager.getPlayer(player) != null) { UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(potionStage, 1); } } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index dd198131e..c4ee8e41c 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -323,9 +323,13 @@ public class WoodcuttingManager extends SkillManager { //Bonus Drops / Harvest lumber checks processBonusDropCheck(blockState); } else if (BlockUtils.isNonWoodPartOfTree(blockState)) { - // 90% of the time do not drop leaf blocks - if (ThreadLocalRandom.current().nextInt(100) > 90) { - Misc.spawnItemsFromCollection(getPlayer(), Misc.getBlockCenter(blockState), block.getDrops(itemStack), ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK); + // 75% of the time do not drop leaf blocks + if (blockState.getType().getKey().getKey().toLowerCase().contains("sapling") + || ThreadLocalRandom.current().nextInt(100) > 75) { + Misc.spawnItemsFromCollection(getPlayer(), + Misc.getBlockCenter(blockState), + block.getDrops(itemStack), + ItemSpawnReason.TREE_FELLER_DISPLACED_BLOCK); } //Drop displaced non-woodcutting XP blocks diff --git a/src/main/java/com/gmail/nossr50/util/PotionUtil.java b/src/main/java/com/gmail/nossr50/util/PotionUtil.java index fb1c9289b..a83897a5f 100644 --- a/src/main/java/com/gmail/nossr50/util/PotionUtil.java +++ b/src/main/java/com/gmail/nossr50/util/PotionUtil.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.util; import com.gmail.nossr50.mcMMO; +import org.bukkit.Bukkit; import org.bukkit.NamespacedKey; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionEffectType; @@ -404,7 +405,7 @@ public class PotionUtil { try { PotionType potionType = (PotionType) methodPotionMetaGetBasePotionType.invoke(potionMeta); List potionEffectTypeList = (List) methodPotionTypeGetPotionEffects.invoke(potionType); - return potionEffectTypeList != null || !potionEffectTypeList.isEmpty(); + return potionEffectTypeList != null && !potionEffectTypeList.isEmpty(); } catch (IllegalAccessException | InvocationTargetException ex) { throw new RuntimeException(ex); } diff --git a/src/main/resources/experience.yml b/src/main/resources/experience.yml index 13fe09386..84df0e214 100644 --- a/src/main/resources/experience.yml +++ b/src/main/resources/experience.yml @@ -239,17 +239,18 @@ Experience_Values: # FeatherFall_Multiplier: Multiply Acrobatics XP by this value when wearing boots with the Feather Fall enchant FeatherFall_Multiplier: 2.0 Alchemy: - # Alchemy potion stages are based on the number of ingredients added - # Potion_Stage_1 represents a base potion - # Potion_Stage_2 represents a base potion with one ingredient - # Potion_Stage_3 represents a base potion with one ingredient and one amplifier - # Potion_Stage_4 represents a base potion with one ingredient and two amplifiers - # Potion_Stage_5 represents a base potion with one ingredient where the amplifiers are swapped - Potion_Stage_1: 15 - Potion_Stage_2: 30 - Potion_Stage_3: 60 - Potion_Stage_4: 120 - Potion_Stage_5: 0 + Potion_Brewing: + # Alchemy potion stages are based on the number of ingredients added + # Stage_1 represents a base potion + # Stage_2 represents a base potion with one ingredient + # Stage_3 represents a base potion with one ingredient and one amplifier + # Stage_4 represents a base potion with one ingredient and two amplifiers + # Stage_5 represents a base potion with one ingredient where the amplifiers are swapped + Stage_1: 120 + Stage_2: 240 + Stage_3: 480 + Stage_4: 960 + Stage_5: 0 Archery: Distance_Multiplier: 0.025 Fishing: