Attempting to fix issues #272 , #266 , #261 , and #255 .

This commit is contained in:
U-YUE\Sean 2012-10-30 11:46:52 -07:00
parent 8dfa8c20f3
commit ab7a83b37e
18 changed files with 161 additions and 0 deletions

View File

@ -51,6 +51,9 @@ public abstract class AcrobaticsEventHandler {
* @return true if the damage is fatal, false otherwise
*/
protected boolean isFatal(int damage) {
if(player == null)
return true;
if (player.getHealth() - damage < 1) {
return true;
}

View File

@ -26,6 +26,9 @@ public class AcrobaticsManager {
* @param event The event to check
*/
public void rollCheck(EntityDamageEvent event) {
if(player == null)
return;
if (!permissionInstance.roll(player)) {
return;
}
@ -54,6 +57,9 @@ public class AcrobaticsManager {
* @param event The event to check
*/
public void dodgeCheck(EntityDamageEvent event) {
if(player == null)
return;
if (!permissionInstance.dodge(player)) {
return;
}

View File

@ -39,11 +39,17 @@ public class DodgeEventHandler extends AcrobaticsEventHandler {
@Override
protected void sendAbilityMessage() {
if(player == null)
return;
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
}
@Override
protected void processXPGain(int xp) {
if(player == null)
return;
PlayerProfile profile = manager.getProfile();
if (System.currentTimeMillis() >= profile.getRespawnATS() + 5) {

View File

@ -56,6 +56,9 @@ public class RollEventHandler extends AcrobaticsEventHandler {
@Override
protected void sendAbilityMessage() {
if(player == null)
return;
if (isGraceful) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
}
@ -67,6 +70,9 @@ public class RollEventHandler extends AcrobaticsEventHandler {
@Override
protected void processXPGain(int xpGain) {
if(player == null)
return;
Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xpGain);
}
@ -74,6 +80,9 @@ public class RollEventHandler extends AcrobaticsEventHandler {
* Check if this is a graceful roll.
*/
private void isGracefulRoll() {
if(player == null)
return;
if (Permissions.getInstance().gracefulRoll(player)) {
this.isGraceful = player.isSneaking();
}

View File

@ -33,6 +33,9 @@ public class ArcheryManager {
* @param livingEntity Entity damaged by the arrow
*/
public void trackArrows(LivingEntity livingEntity) {
if(player == null)
return;
if (!permissionsInstance.trackArrows(player)) {
return;
}
@ -57,6 +60,9 @@ public class ArcheryManager {
* @param event The event to modify
*/
public void dazeCheck(Player defender, EntityDamageEvent event) {
if(player == null)
return;
if (!permissionsInstance.daze(player)) {
return;
}
@ -81,6 +87,9 @@ public class ArcheryManager {
* @param event The event to modify.
*/
public void bonusDamage(EntityDamageEvent event) {
if(player == null)
return;
if (!permissionsInstance.archeryBonus(player)) {
return;
}

View File

@ -30,6 +30,9 @@ public class Axes {
* @param event The event to modify
*/
public static void axesBonus(Player attacker, EntityDamageByEntityEvent event) {
if(attacker == null)
return;
final int MAX_BONUS = 4;
/* Add 1 DMG for every 50 skill levels */
@ -49,6 +52,9 @@ public class Axes {
* @param event The event to modify
*/
public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event) {
if(attacker == null)
return;
Entity entity = event.getEntity();
if (entity instanceof Tameable) {
@ -104,6 +110,8 @@ public class Axes {
*/
@SuppressWarnings("deprecation")
public static void impact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
if(attacker == null)
return;
/*
* TODO: Finish this skill. The idea is you will greatly damage an opponents armor.
@ -140,6 +148,9 @@ public class Axes {
* @param event The event to modify
*/
private static void applyGreaterImpact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
if(attacker == null)
return;
final int GREATER_IMPACT_CHANCE = 25;
final double GREATER_IMPACT_MULTIPLIER = 1.5;
@ -167,6 +178,9 @@ public class Axes {
* @return true if the player has armor, false otherwise
*/
private static boolean hasArmor(Player player) {
if(player == null)
return false;
PlayerInventory inventory = player.getInventory();
if (inventory.getBoots() != null || inventory.getChestplate() != null || inventory.getHelmet() != null || inventory.getLeggings() != null) {

View File

@ -82,6 +82,9 @@ public class BlastMining {
* @param event Event whose explosion is being processed
*/
public static void dropProcessing(Player player, EntityExplodeEvent event) {
if(player == null)
return;
final int RANK_1_LEVEL = 125;
final int RANK_2_LEVEL = 250;
final int RANK_3_LEVEL = 375;
@ -172,6 +175,9 @@ public class BlastMining {
* @param event Event whose explosion radius is being changed
*/
public static void biggerBombs(Player player, ExplosionPrimeEvent event) {
if(player == null)
return;
final int RANK_1_LEVEL = 250;
final int RANK_2_LEVEL = 500;
final int RANK_3_LEVEL = 750;
@ -210,6 +216,9 @@ public class BlastMining {
* @param event Event whose explosion damage is being reduced
*/
public static void demolitionsExpertise(Player player, EntityDamageEvent event) {
if(player == null)
return;
final int RANK_1_LEVEL = 500;
final int RANK_2_LEVEL = 750;
final int RANK_3_LEVEL = 1000;
@ -242,6 +251,9 @@ public class BlastMining {
* @param plugin mcMMO plugin instance
*/
public static void detonate(PlayerInteractEvent event, Player player, mcMMO plugin) {
if(player == null)
return;
PlayerProfile profile = Users.getProfile(player);
if (profile.getSkillLevel(SkillType.MINING) < 125)

View File

@ -37,6 +37,9 @@ public class Excavation {
* @param player The player who broke the block
*/
public static void excavationProcCheck(Block block, Player player) {
if(player == null)
return;
Material type = block.getType();
Location location = block.getLocation();
@ -122,6 +125,9 @@ public class Excavation {
* @param block The block to check
*/
public static void gigaDrillBreaker(Player player, Block block) {
if(player == null)
return;
Skills.abilityDurabilityLoss(player.getItemInHand(), Config.getInstance().getAbilityToolDamage());
if (!mcMMO.placeStore.isTrue(block) && !Misc.blockBreakSimulate(block, player, true)) {

View File

@ -72,6 +72,9 @@ public class Fishing {
* @param event The event to modify
*/
private static void getFishingResults(Player player, PlayerFishEvent event) {
if(player == null)
return;
PlayerProfile profile = Users.getProfile(player);
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
Item theCatch = (Item) event.getCaught();
@ -135,6 +138,9 @@ public class Fishing {
*/
public static void processResults(PlayerFishEvent event) {
Player player = event.getPlayer();
if(player == null)
return;
PlayerProfile profile = Users.getProfile(player);
getFishingResults(player, event);

View File

@ -37,6 +37,9 @@ public class Herbalism {
* @param block The block to be changed by Green Terra
*/
public static void greenTerra(Player player, Block block) {
if(player == null)
return;
PlayerInventory inventory = player.getInventory();
boolean hasSeeds = inventory.contains(Material.SEEDS);
@ -51,6 +54,9 @@ public class Herbalism {
}
public static void greenTerraConvert(Player player, Block block) {
if(player == null)
return;
Material type = block.getType();
if (Misc.blockBreakSimulate(block, player, false)) {
@ -77,6 +83,9 @@ public class Herbalism {
* @param plugin mcMMO plugin instance
*/
public static void herbalismProcCheck(final Block block, Player player, BlockBreakEvent event, mcMMO plugin) {
if(player == null)
return;
final PlayerProfile profile = Users.getProfile(player);
final int MAX_BONUS_LEVEL = 1000;
@ -372,6 +381,9 @@ public class Herbalism {
* @param plugin mcMMO plugin instance
*/
private static void greenThumbWheat(Block block, Player player, BlockBreakEvent event, mcMMO plugin) {
if(player == null)
return;
final int MAX_BONUS_LEVEL = 1500;
PlayerProfile profile = Users.getProfile(player);
@ -407,6 +419,9 @@ public class Herbalism {
* @param block The block being used in the ability
*/
public static void greenThumbBlocks(ItemStack is, Player player, Block block) {
if(player == null)
return;
final int MAX_BONUS_LEVEL = 1500;
PlayerProfile profile = Users.getProfile(player);

View File

@ -24,6 +24,9 @@ public class CounterAttackEventHandler {
}
protected boolean isHoldingSword() {
if(player == null)
return false;
return ItemChecks.isSword(player.getItemInHand());
}
@ -36,6 +39,9 @@ public class CounterAttackEventHandler {
}
protected void sendAbilityMessages() {
if(player == null)
return;
player.sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
if (attacker instanceof Player) {

View File

@ -19,6 +19,9 @@ public class SerratedStrikesEventHandler {
}
protected void applyAbilityEffects() {
if(player == null)
return;
Combat.applyAbilityAoE(player, target, damage / Swords.SERRATED_STRIKES_MODIFIER, SkillType.SWORDS);
BleedTimer.add(target, Swords.SERRATED_STRIKES_BLEED_TICKS);
}

View File

@ -28,6 +28,9 @@ public class SwordsManager {
* @param defender The defending entity
*/
public void bleedCheck(LivingEntity defender) {
if(player == null)
return;
if (!permissionsInstance.swordsBleed(player)) {
return;
}

View File

@ -19,6 +19,9 @@ public class BeastLoreEventHandler {
}
protected void sendInspectMessage() {
if(player == null)
return;
String message = LocaleLoader.getString("Combat.BeastLore") + " ";
if (beast.isTamed()) {

View File

@ -29,10 +29,16 @@ public class CallOfTheWildEventHandler {
}
protected void sendInsufficientAmountMessage() {
if(player == null)
return;
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GRAY + Misc.prettyItemString(inHand.getTypeId()));
}
protected boolean nearbyEntityExists() {
if(player == null)
return false;
boolean entityExists = false;
for (Entity entity : player.getNearbyEntities(40, 40, 40)) {
@ -46,6 +52,9 @@ public class CallOfTheWildEventHandler {
}
protected void sendFailureMessage() {
if(player == null)
return;
if (type == EntityType.OCELOT) {
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Ocelot"));
}
@ -55,6 +64,9 @@ public class CallOfTheWildEventHandler {
}
protected void spawnCreature() {
if(player == null)
return;
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);
entity.setMetadata("mcmmoSummoned", new FixedMetadataValue(mcMMO.p, true));
@ -69,6 +81,9 @@ public class CallOfTheWildEventHandler {
}
protected void processResourceCost() {
if(player == null)
return;
int newAmount = inHand.getAmount() - summonAmount;
if (newAmount == 0) {
@ -80,6 +95,9 @@ public class CallOfTheWildEventHandler {
}
protected void sendSuccessMessage() {
if(player == null)
return;
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
}
}

View File

@ -18,6 +18,9 @@ public class EnvironmentallyAwareEventHandler {
}
protected void teleportWolf() {
if(player == null)
return;
if (event.getDamage() > wolf.getHealth()) {
return;
}
@ -26,6 +29,9 @@ public class EnvironmentallyAwareEventHandler {
}
protected void sendAbilityMessage() {
if(player == null)
return;
player.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
}

View File

@ -36,6 +36,9 @@ public class TamingManager {
* @param damage The damage being absorbed by the wolf
*/
public void fastFoodService(Wolf wolf, int damage) {
if(player == null)
return;
if (!permissionsInstance.fastFoodService(player)) {
return;
}
@ -61,6 +64,9 @@ public class TamingManager {
* @param event The event to modify
*/
public void sharpenedClaws(EntityDamageEvent event) {
if(player == null)
return;
if (!permissionsInstance.sharpenedClaws(player)) {
return;
}
@ -78,6 +84,9 @@ public class TamingManager {
* @param event The event to modify
*/
public void gore(EntityDamageEvent event) {
if(player == null)
return;
if (!permissionsInstance.gore(player)) {
return;
}
@ -150,6 +159,9 @@ public class TamingManager {
* @param livingEntity The entity to examine
*/
public void beastLore(LivingEntity livingEntity) {
if(player == null)
return;
if (!permissionsInstance.beastLore(player)) {
return;
}
@ -166,6 +178,9 @@ public class TamingManager {
* @param summonAmount The amount of material needed to summon the entity
*/
private void callOfTheWild(EntityType type, int summonAmount) {
if(player == null)
return;
if (!permissionsInstance.callOfTheWild(player)) {
return;
}
@ -198,6 +213,9 @@ public class TamingManager {
* @param cause The damage cause of the event
*/
private void environmentallyAware(EntityDamageEvent event, DamageCause cause) {
if(player == null)
return;
if (!permissionsInstance.environmentallyAware(player)) {
return;
}
@ -230,6 +248,9 @@ public class TamingManager {
* @param cause The damage cause of the event
*/
private void thickFur(EntityDamageEvent event, DamageCause cause) {
if(player == null)
return;
if (!permissionsInstance.thickFur(player)) {
return;
}
@ -247,6 +268,9 @@ public class TamingManager {
* @param event The event to modify
*/
private void shockProof(EntityDamageEvent event) {
if(player == null)
return;
if (!permissionsInstance.shockProof(player)) {
return;
}

View File

@ -27,6 +27,9 @@ public class UnarmedManager {
* @param defender The defending player
*/
public void disarmCheck(Player defender) {
if(player == null)
return;
if (!permissionsInstance.disarm(player)) {
return;
}
@ -58,6 +61,9 @@ public class UnarmedManager {
* @param event The event to modify
*/
public void deflectCheck(EntityDamageEvent event) {
if(player == null)
return;
if (!permissionsInstance.deflect(player)) {
return;
}
@ -82,6 +88,9 @@ public class UnarmedManager {
* @param event The event to modify.
*/
public void bonusDamage(EntityDamageEvent event) {
if(player == null)
return;
if (!permissionsInstance.unarmedBonus(player)) {
return;
}
@ -99,6 +108,9 @@ public class UnarmedManager {
* @return true if the defender was not disarmed, false otherwise
*/
private boolean hasIronGrip(Player defender) {
if(defender == null)
return false;
if (!permissionsInstance.ironGrip(defender)) {
return false;
}