mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Added SubSkillBlockEvent & GreenThumb + ShroomThumb now fire it
This commit is contained in:
parent
2b4c84b1e8
commit
1c1abe9a2a
@ -3,6 +3,11 @@ Version 2.1.174
|
||||
Updated hu_HU locale (thanks andris155)
|
||||
Updated ru locale (thanks imDaniX)
|
||||
Updated fr locale (thanks Elikill58)
|
||||
(API) Added SubSkillBlockEvent for some SubSkill events that have a block (eg: Green Thumb Block events)
|
||||
(API) Green Thumb (Block) now fires a SubSkillBlockEvent which is cancellable
|
||||
(API) Shroom Thumb now fires a SubSkillBlockEvent which is cancellable
|
||||
|
||||
NOTE: A lot of sub-skills without random chance elements are missing events, this will be cleaned up in the near future. If you need something specific added sooner than that, post a GitHub issue for it and I'll patch it in.
|
||||
|
||||
Version 2.1.173
|
||||
The experience orbs dropped by Knock on Wood rank 2 during Tree Feller are now much less frequent but provide more XP
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.gmail.nossr50.events.skills.secondaryabilities;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SubSkillBlockEvent extends SubSkillEvent {
|
||||
private final @NotNull Block block;
|
||||
|
||||
public SubSkillBlockEvent(@NotNull Player player, @NotNull SubSkillType subSkillType, @NotNull Block block) {
|
||||
super(player, subSkillType);
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block associated with this event
|
||||
* @return the block associated with this event
|
||||
*/
|
||||
public @NotNull Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
}
|
@ -817,19 +817,24 @@ public class PlayerListener implements Listener {
|
||||
|
||||
FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer()); //PlayerAnimationEvent compat
|
||||
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
||||
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||
player.getInventory().getItemInMainHand().setAmount(heldItem.getAmount() - 1);
|
||||
player.updateInventory();
|
||||
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
blockState.update(true);
|
||||
//call event for Green Thumb Block
|
||||
if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_GREEN_THUMB, block).isCancelled()) {
|
||||
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||
player.getInventory().getItemInMainHand().setAmount(heldItem.getAmount() - 1);
|
||||
player.updateInventory();
|
||||
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* SHROOM THUMB CHECK */
|
||||
else if (herbalismManager.canUseShroomThumb(blockState)) {
|
||||
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||
event.setCancelled(true);
|
||||
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
blockState.update(true);
|
||||
if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_SHROOM_THUMB, block).isCancelled()) {
|
||||
Bukkit.getPluginManager().callEvent(fakeSwing);
|
||||
event.setCancelled(true);
|
||||
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||
blockState.update(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -28,6 +28,7 @@ import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
|
||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
|
||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||
import com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent;
|
||||
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillBlockEvent;
|
||||
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
|
||||
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@ -190,13 +191,28 @@ public final class EventUtils {
|
||||
* @return the event after it has been fired
|
||||
*/
|
||||
@Deprecated
|
||||
public static SubSkillEvent callSubSkillEvent(Player player, SubSkillType subSkillType) {
|
||||
public static @NotNull SubSkillEvent callSubSkillEvent(Player player, SubSkillType subSkillType) {
|
||||
SubSkillEvent event = new SubSkillEvent(player, subSkillType);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls a new SubSkillBlockEvent for this SubSkill and its related block and then returns it
|
||||
* @param player target player
|
||||
* @param subSkillType target subskill
|
||||
* @param block associated block
|
||||
* @return the event after it has been fired
|
||||
*/
|
||||
@Deprecated
|
||||
public static @NotNull SubSkillBlockEvent callSubSkillBlockEvent(@NotNull Player player, @NotNull SubSkillType subSkillType, @NotNull Block block) {
|
||||
SubSkillBlockEvent event = new SubSkillBlockEvent(player, subSkillType, block);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls a new SubSkillEvent for this SubSkill and then returns it
|
||||
* @param player target player
|
||||
|
Loading…
Reference in New Issue
Block a user