Merge master

This commit is contained in:
nossr50 2023-05-13 15:02:04 -07:00
commit 75ace0cfa0
11 changed files with 83 additions and 29 deletions

View File

@ -57,9 +57,14 @@ Version 2.2.000
This power level command gives you a view of all your current masteries, it also provides a summary of your power level.
Version 2.1.220
(API) Added TreeFellerBlockBreakEvent class which extends FakeBlockBreakEvent (see notes), this is sent out during Tree Feller processing to allow other plugins to differentiate between Tree Feller and other fake block break events
Config files update automatically again
Default configs are now copied to plugins/mcMMO/defaults for easy reference, these configs will always match the default values of the config in the JAR
Default configs are now copied to plugins/mcMMO/defaults for easy reference
Fixed child skills counting towards power level in /inspect (Thanks Wariorrrr)
NOTES: For a while configs were not updating automatically as a rewrite of how config files were loaded was partially done, this is now complete and configs will update automatically again.
Fake block break events have been sent out historically by mcMMO to check other plugins for a players permission to break or place a block, Tree Feller will now specify via inheritance its own event type for this so mcMMO plugins can handle Tree Feller fake block break events differently if they so choose.
You can now view the default configs more easily as they are now copied to plugins/mcMMO/defaults, these configs will be overwritten on start up to match the default values of the config in the JAR
Version 2.1.219
Fixed Fishing exploit protection being triggered inappropriately by other plugins (Thanks smudgge)
Fixed wiki url being incorrect in commands

View File

@ -0,0 +1,6 @@
package com.gmail.nossr50.api;
public enum FakeBlockBreakEventType {
FAKE,
TREE_FELLER
}

View File

@ -0,0 +1,14 @@
package com.gmail.nossr50.api;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeEvent;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.jetbrains.annotations.NotNull;
public class TreeFellerBlockBreakEvent extends FakeBlockBreakEvent {
public TreeFellerBlockBreakEvent(@NotNull Block theBlock, @NotNull Player player) {
super(theBlock, player);
}
}

View File

@ -9,6 +9,7 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.SkillTools;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -47,27 +48,26 @@ public class InspectCommand implements TabExecutor {
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
// Sum power level
int powerLevel = 0;
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
for (PrimarySkillType skill : mcMMO.p.getSkillTools().GATHERING_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
powerLevel += profile.getSkillLevel(skill);
}
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
for (PrimarySkillType skill : mcMMO.p.getSkillTools().COMBAT_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
powerLevel += profile.getSkillLevel(skill);
}
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
for (PrimarySkillType skill : mcMMO.p.getSkillTools().MISC_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
powerLevel += profile.getSkillLevel(skill);
}
// Sum power level
int powerLevel = 0;
for (PrimarySkillType skill : SkillTools.NON_CHILD_SKILLS)
powerLevel += profile.getSkillLevel(skill);
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", powerLevel));
} else {
Player target = mcMMOPlayer.getPlayer();

View File

@ -558,7 +558,7 @@ public class BlockListener implements Listener {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED);
if(mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK)) {
if (SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(blockState.getBlock(), player, true)) {
if (SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(blockState.getBlock(), player)) {
event.setInstaBreak(true);
if(blockState.getType().getKey().getKey().contains("glass")) {
@ -633,11 +633,11 @@ public class BlockListener implements Listener {
}
else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && (heldItem.getType() == Material.AIR || mcMMO.p.getGeneralConfig().getUnarmedItemsAsUnarmed())) {
if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState)) {
if (EventUtils.simulateBlockBreak(block, player, true) && mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
if (EventUtils.simulateBlockBreak(block, player) && mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update();
}
}
else if (!event.getInstaBreak() && SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
else if (!event.getInstaBreak() && SuperAbilityType.BERSERK.blockCheck(blockState) && EventUtils.simulateBlockBreak(block, player)) {
event.setInstaBreak(true);
if(blockState.getType().getKey().getKey().contains("glass")) {
@ -647,7 +647,7 @@ public class BlockListener implements Listener {
}
}
}
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isNonWoodPartOfTree(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isNonWoodPartOfTree(blockState) && EventUtils.simulateBlockBreak(block, player)) {
event.setInstaBreak(true);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
}

View File

@ -866,7 +866,7 @@ public class PlayerListener implements Listener {
// Bukkit.getPluginManager().callEvent(fakeSwing);
player.getInventory().getItemInMainHand().setAmount(heldItem.getAmount() - 1);
player.updateInventory();
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player)) {
blockState.update(true);
}
}
@ -877,7 +877,7 @@ public class PlayerListener implements Listener {
// Bukkit.getPluginManager().callEvent(fakeSwing);
event.setCancelled(true);
if (herbalismManager.processShroomThumb(blockState)
&& EventUtils.simulateBlockBreak(block, player, false)) {
&& EventUtils.simulateBlockBreak(block, player)) {
blockState.update(true);
}
}

View File

@ -187,7 +187,7 @@ public class FishingManager extends SkillManager {
return false;
}
return EventUtils.simulateBlockBreak(block, player, false);
return EventUtils.simulateBlockBreak(block, player);
}
/**

View File

@ -688,7 +688,7 @@ public class HerbalismManager extends SkillManager {
for (HylianTreasure treasure : treasures) {
if (skillLevel >= treasure.getDropLevel()
&& ProbabilityUtil.isStaticSkillRNGSuccessful(PrimarySkillType.HERBALISM, player, treasure.getDropChance())) {
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) {
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player)) {
return false;
}
blockState.setType(Material.AIR);

View File

@ -139,7 +139,7 @@ public class MiningManager extends SkillManager {
Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
//Blast mining cooldown check needs to be first so the player can be messaged
if (!blastMiningCooldownOver() || targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true)) {
if (!blastMiningCooldownOver() || targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player)) {
return;
}

View File

@ -1,8 +1,10 @@
package com.gmail.nossr50.skills.woodcutting;
import com.gmail.nossr50.api.FakeBlockBreakEventType;
import com.gmail.nossr50.api.ItemSpawnReason;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -302,7 +304,7 @@ public class WoodcuttingManager extends SkillManager {
int beforeXP = xp;
Block block = blockState.getBlock();
if (!EventUtils.simulateBlockBreak(block, player, true)) {
if (!EventUtils.simulateBlockBreak(block, player, FakeBlockBreakEventType.TREE_FELLER)) {
continue;
}
@ -347,7 +349,7 @@ public class WoodcuttingManager extends SkillManager {
processedLogCount = updateProcessedLogCount(xp, processedLogCount, beforeXP);
}
applyXpGain(xp, XPGainReason.PVE);
applyXpGain(xp, XPGainReason.PVE, XPGainSource.SELF);
}
private int updateProcessedLogCount(int xp, int processedLogCount, int beforeXP) {

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.api.FakeBlockBreakEventType;
import com.gmail.nossr50.api.TreeFellerBlockBreakEvent;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.party.Party;
@ -43,6 +45,7 @@ import org.bukkit.entity.FishHook;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.inventory.ItemStack;
@ -306,24 +309,48 @@ public final class EventUtils {
*
* @param block The block to break
* @param player The player breaking the block
* @param shouldArmSwing true if an armswing event should be fired, false otherwise
* @param shouldArmSwing ignored (here for API compatibility)
* @return true if the event wasn't cancelled, false otherwise
* {@code @Deprecated} use {@link #simulateBlockBreak(Block, Player, FakeBlockBreakEventType)} instead
*/
public static boolean simulateBlockBreak(Block block, Player player, boolean shouldArmSwing) {
PluginManager pluginManager = mcMMO.p.getServer().getPluginManager();
return simulateBlockBreak(block, player);
}
// Support for NoCheat
//if (shouldArmSwing) {
// callFakeArmSwingEvent(player);
//}
/**
* Simulate a block break event.
*
* @param block The block to break
* @param player The player breaking the block
* @return true if the event wasn't cancelled, false otherwise
* {@code @Deprecated} use {@link #simulateBlockBreak(Block, Player, FakeBlockBreakEventType)} instead
*/
public static boolean simulateBlockBreak(Block block, Player player) {
return simulateBlockBreak(block, player, FakeBlockBreakEventType.FAKE);
}
/**
* Simulate a block break event.
*
* @param block The block to break
* @param player The player breaking the block
* @param eventType The type of event to signal to other plugins
* @return true if the event wasn't cancelled, false otherwise
*/
public static boolean simulateBlockBreak(Block block, Player player, FakeBlockBreakEventType eventType) {
PluginManager pluginManager = mcMMO.p.getServer().getPluginManager();
FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getInventory().getItemInMainHand(), true);
pluginManager.callEvent(damageEvent);
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
pluginManager.callEvent(breakEvent);
BlockBreakEvent fakeBlockBreakEvent = null;
return !damageEvent.isCancelled() && !breakEvent.isCancelled();
switch (eventType) {
case FAKE -> fakeBlockBreakEvent = new FakeBlockBreakEvent(block, player);
case TREE_FELLER -> fakeBlockBreakEvent = new TreeFellerBlockBreakEvent(block, player);
}
pluginManager.callEvent(fakeBlockBreakEvent);
return !damageEvent.isCancelled() && !fakeBlockBreakEvent.isCancelled();
}
public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {