mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 16:19:53 +01:00
SkillTools, not Misc
This commit is contained in:
parent
add4bc24df
commit
671be42472
@ -90,7 +90,7 @@ public class Herbalism {
|
||||
}
|
||||
|
||||
public static void greenTerraConvert(Player player, Block block) {
|
||||
if (Misc.blockBreakSimulate(block, player, false)) {
|
||||
if (SkillTools.blockBreakSimulate(block, player, false)) {
|
||||
Material type = block.getType();
|
||||
|
||||
switch (type) {
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@ -36,7 +37,7 @@ public class MiningManager extends SkillManager{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Misc.blockBreakSimulate(eventHandler.getBlock(), mcMMOPlayer.getPlayer(), true)) {
|
||||
if (!SkillTools.blockBreakSimulate(eventHandler.getBlock(), mcMMOPlayer.getPlayer(), true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
|
||||
public class Unarmed {
|
||||
public static int ironArmMaxBonusDamage = AdvancedConfig.getInstance().getIronArmMaxBonus();
|
||||
@ -29,7 +29,7 @@ public class Unarmed {
|
||||
public static double berserkDamageModifier = 1.5;
|
||||
|
||||
public static void blockCracker(Player player, Block block) {
|
||||
if (Misc.blockBreakSimulate(block, player, false)) {
|
||||
if (SkillTools.blockBreakSimulate(block, player, false)) {
|
||||
Material type = block.getType();
|
||||
|
||||
switch (type) {
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
@ -22,6 +23,9 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mods.ModChecks;
|
||||
import com.gmail.nossr50.spout.SpoutConfig;
|
||||
@ -479,7 +483,7 @@ public class SkillTools {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!Misc.blockBreakSimulate(block, player, true)) {
|
||||
if (!blockBreakSimulate(block, player, true)) {
|
||||
activate = false;
|
||||
break;
|
||||
}
|
||||
@ -632,4 +636,35 @@ public class SkillTools {
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate a block break event.
|
||||
*
|
||||
* @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
|
||||
* @return true if the event wasn't cancelled, false otherwise
|
||||
*/
|
||||
public static boolean blockBreakSimulate(Block block, Player player, Boolean shouldArmSwing) {
|
||||
|
||||
//Support for NoCheat
|
||||
if (shouldArmSwing) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||
}
|
||||
|
||||
PluginManager pluginManger = mcMMO.p.getServer().getPluginManager();
|
||||
|
||||
FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getItemInHand(), true);
|
||||
pluginManger.callEvent(damageEvent);
|
||||
|
||||
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
|
||||
pluginManger.callEvent(breakEvent);
|
||||
|
||||
if (!damageEvent.isCancelled() && !breakEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ public final class TreeFeller {
|
||||
int xp = 0;
|
||||
|
||||
for (Block block : treeFellerBlocks) {
|
||||
if (!Misc.blockBreakSimulate(block, mcMMOPlayer.getPlayer(), true)) {
|
||||
if (!SkillTools.blockBreakSimulate(block, mcMMOPlayer.getPlayer(), true)) {
|
||||
break; // TODO: Shouldn't we use continue instead?
|
||||
}
|
||||
|
||||
|
@ -4,18 +4,13 @@ import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
||||
import com.gmail.nossr50.mods.ModChecks;
|
||||
|
||||
@ -51,37 +46,6 @@ public final class Misc {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate a block break event.
|
||||
*
|
||||
* @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
|
||||
* @return true if the event wasn't cancelled, false otherwise
|
||||
*/
|
||||
public static boolean blockBreakSimulate(Block block, Player player, Boolean shouldArmSwing) {
|
||||
|
||||
//Support for NoCheat
|
||||
if (shouldArmSwing) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||
}
|
||||
|
||||
PluginManager pluginManger = mcMMO.p.getServer().getPluginManager();
|
||||
|
||||
FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getItemInHand(), true);
|
||||
pluginManger.callEvent(damageEvent);
|
||||
|
||||
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
|
||||
pluginManger.callEvent(breakEvent);
|
||||
|
||||
if (!damageEvent.isCancelled() && !breakEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the upgrade tier of the item in hand.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user