This commit is contained in:
nossr50
2024-05-04 10:26:43 -07:00
parent 75561350c1
commit 5ba6305ad4
10 changed files with 122 additions and 45 deletions

View File

@ -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 */

View File

@ -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;
// }
}

View File

@ -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);
// }
//}

View File

@ -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);
// }
// }
//}

View File

@ -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);
}
}

View File

@ -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

View File

@ -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<PotionEffectType> potionEffectTypeList = (List<PotionEffectType>) methodPotionTypeGetPotionEffects.invoke(potionType);
return potionEffectTypeList != null || !potionEffectTypeList.isEmpty();
return potionEffectTypeList != null && !potionEffectTypeList.isEmpty();
} catch (IllegalAccessException | InvocationTargetException ex) {
throw new RuntimeException(ex);
}