Cleanup listeners a bit more. Also fix bug in recent dev builds where

placed blocks were not properly tracked.
This commit is contained in:
GJ
2013-01-25 12:33:48 -05:00
parent a35af4dbe6
commit a7be57241c
10 changed files with 70 additions and 78 deletions

View File

@ -422,19 +422,15 @@ public class Skills {
*/
public static void abilityCheck(Player player, SkillType type) {
PlayerProfile profile = Users.getProfile(player);
if (profile == null) {
return;
}
ToolType tool = type.getTool();
AbilityType ability = type.getAbility();
if (!profile.getToolPreparationMode(tool)) {
if (!profile.getToolPreparationMode(tool) || !ability.getPermissions(player)) {
return;
}
profile.setToolPreparationMode(tool, false);
AbilityType ability = type.getAbility();
/* Axes and Woodcutting are odd because they share the same tool.
* We show them the too tired message when they take action.
*/
@ -532,15 +528,11 @@ public class Skills {
* @param xp the amount of XP to gain
*/
public static void xpProcessing(Player player, PlayerProfile profile, SkillType type, int xp) {
if (type.getPermissions(player)) {
if (Users.getPlayer(player) == null)
return;
if ((type.getMaxLevel() < profile.getSkillLevel(type) + 1) || (Misc.getPowerLevelCap() < Users.getPlayer(player).getPowerLevel() + 1))
return;
Users.getPlayer(player).addXP(type, xp);
xpCheckSkill(type, player, profile);
if ((type.getMaxLevel() < profile.getSkillLevel(type) + 1) || (Misc.getPowerLevelCap() < Users.getPlayer(player).getPowerLevel() + 1)) {
return;
}
Users.getPlayer(player).addXP(type, xp);
xpCheckSkill(type, player, profile);
}
}

View File

@ -27,6 +27,7 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Excavation {
public static boolean requiresTool = Config.getInstance().getExcavationRequiresTool();
/**
* Check to see if treasures were found.

View File

@ -106,9 +106,6 @@ 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);
int herbLevel = profile.getSkillLevel(SkillType.HERBALISM);
@ -557,7 +554,7 @@ public class Herbalism {
if (chance > Misc.getRandom().nextInt(activationChance)) {
Location location = block.getLocation();
int dropNumber = Misc.getRandom().nextInt(3);
ItemStack item = null;
ItemStack item;
switch (block.getType()) {
case DEAD_BUSH:
@ -584,6 +581,11 @@ public class Herbalism {
case RED_ROSE:
case YELLOW_FLOWER:
if (mcMMO.placeStore.isTrue(block)) {
mcMMO.placeStore.setFalse(block);
return;
}
if (dropNumber == 0) {
item = new ItemStack(Material.POTATO);
}
@ -594,7 +596,6 @@ public class Herbalism {
item = new ItemStack(Material.APPLE);
}
mcMMO.placeStore.setFalse(block);
break;
case FLOWER_POT:
@ -610,10 +611,6 @@ public class Herbalism {
break;
default:
break;
}
if (item == null) {
return;
}

View File

@ -26,6 +26,8 @@ public class Mining {
public static double doubleDropsMaxChance = advancedConfig.getMiningDoubleDropChance();
public static boolean doubleDropsDisabled = config.miningDoubleDropsDisabled();
public static boolean requiresTool = Config.getInstance().getMiningRequiresTool();
public static final int DIAMOND_TOOL_TIER = 4;
public static final int IRON_TOOL_TIER = 3;
public static final int STONE_TOOL_TIER = 2;

View File

@ -112,12 +112,7 @@ public class MiningManager extends SkillManager{
* @param block The block being broken
*/
public void miningBlockCheck(Block block) {
if (mcMMO.placeStore.isTrue(block)) {
return;
}
MiningBlockEventHandler eventHandler = new MiningBlockEventHandler(this, block);
eventHandler.processXPGain();
if (!Permissions.miningDoubleDrops(player)) {

View File

@ -34,6 +34,7 @@ public class Repair {
public static boolean arcaneForgingDowngrades = advancedConfig.getArcaneForgingDowngradeEnabled();
public static boolean arcaneForgingEnchantLoss = advancedConfig.getArcaneForgingEnchantLossEnabled();
public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled();
public static int anvilID = Config.getInstance().getRepairAnvilId();
/**

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.smelting;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
@ -10,14 +11,17 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillType;
import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class FluxMiningEventHandler {
private SmeltingManager manager;
private Player player;
private BlockBreakEvent event;
private Block block;
protected FluxMiningEventHandler(SmeltingManager manager, BlockBreakEvent event) {
this.manager = manager;
this.player = manager.getPlayer();
this.event = event;
this.block = event.getBlock();
}
@ -43,9 +47,12 @@ public class FluxMiningEventHandler {
}
Location location = block.getLocation();
int chance = (int) ((Mining.doubleDropsMaxChance / Mining.doubleDropsMaxLevel) * (Misc.skillCheck(manager.getProfile().getSkillLevel(SkillType.MINING), Mining.doubleDropsMaxLevel)));
Misc.dropItem(location, item);
Misc.randomDropItem(location, item, chance);
if (Permissions.secondSmelt(player)) {
int chance = (int) ((Mining.doubleDropsMaxChance / Mining.doubleDropsMaxLevel) * (Misc.skillCheck(manager.getProfile().getSkillLevel(SkillType.MINING), Mining.doubleDropsMaxLevel)));
Misc.randomDropItem(location, item, chance);
}
}
protected void eventCancellationAndProcessing() {
@ -54,6 +61,6 @@ public class FluxMiningEventHandler {
}
protected void sendAbilityMessage() {
manager.getPlayer().sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success"));
player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success"));
}
}

View File

@ -56,7 +56,7 @@ public class SmeltingManager extends SkillManager {
}
public void fluxMining(BlockBreakEvent event) {
if (skillLevel < Smelting.fluxMiningUnlockLevel || !Permissions.fluxMining(player)) {
if (skillLevel < Smelting.fluxMiningUnlockLevel) {
return;
}

View File

@ -29,6 +29,8 @@ public abstract class Woodcutting {
public static final boolean DOUBLE_DROP_DISABLED = Config.getInstance().woodcuttingDoubleDropsDisabled();
public static final int TREE_FELLER_THRESHOLD = Config.getInstance().getTreeFellerThreshold();
public static boolean requiresTool = Config.getInstance().getWoodcuttingRequiresTool();
/**
* Begins the Tree Feller ability
*