diff --git a/src/main/java/com/gmail/nossr50/Combat.java b/src/main/java/com/gmail/nossr50/Combat.java
index daba5777b..86115683d 100644
--- a/src/main/java/com/gmail/nossr50/Combat.java
+++ b/src/main/java/com/gmail/nossr50/Combat.java
@@ -2,7 +2,14 @@ package com.gmail.nossr50;
import org.bukkit.Bukkit;
import org.bukkit.Material;
-import org.bukkit.entity.*;
+import org.bukkit.entity.AnimalTamer;
+import org.bukkit.entity.Animals;
+import org.bukkit.entity.Arrow;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
diff --git a/src/main/java/com/gmail/nossr50/ItemChecks.java b/src/main/java/com/gmail/nossr50/ItemChecks.java
index fa5f11f4c..5eb54e367 100644
--- a/src/main/java/com/gmail/nossr50/ItemChecks.java
+++ b/src/main/java/com/gmail/nossr50/ItemChecks.java
@@ -1,21 +1,3 @@
-/*
- * Copyright (C) 2012 Matt 'The Yeti' Burnett & mcMMO Development
- * Copyright (C) 2010-2011 'nossr50'
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
-*/
-
package com.gmail.nossr50;
import org.bukkit.inventory.ItemStack;
diff --git a/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java b/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java
index e2cf9b1b9..71b4777d8 100644
--- a/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java
+++ b/src/main/java/com/gmail/nossr50/datatypes/AbilityType.java
@@ -1,7 +1,6 @@
package com.gmail.nossr50.datatypes;
import org.bukkit.Material;
-import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcPermissions;
@@ -201,20 +200,20 @@ public enum AbilityType
return false;
}
- public boolean blockCheck(Block block) {
+ public boolean blockCheck(Material material) {
switch (this) {
case BERSERK:
- return (Excavation.canBeGigaDrillBroken(block) || block.getType().equals(Material.SNOW));
+ return (Excavation.canBeGigaDrillBroken(material) || material.equals(Material.SNOW));
case GIGA_DRILL_BREAKER:
- return Excavation.canBeGigaDrillBroken(block);
+ return Excavation.canBeGigaDrillBroken(material);
case GREEN_TERRA:
- return Herbalism.makeMossy(block.getType());
+ return Herbalism.makeMossy(material);
case LEAF_BLOWER:
- return block.getType().equals(Material.LEAVES);
+ return material.equals(Material.LEAVES);
case SUPER_BREAKER:
- return Mining.canBeSuperBroken(block);
+ return Mining.canBeSuperBroken(material);
case TREE_FELLER:
- return block.getType().equals(Material.LOG);
+ return material.equals(Material.LOG);
default:
return false;
}
diff --git a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java
index 5edd09b61..7500103de 100644
--- a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java
+++ b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java
@@ -2,14 +2,20 @@ package com.gmail.nossr50.listeners;
import com.gmail.nossr50.BlockChecks;
import com.gmail.nossr50.ItemChecks;
-import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
+import com.gmail.nossr50.Users;
import com.gmail.nossr50.config.LoadProperties;
-import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
+import com.gmail.nossr50.skills.Excavation;
+import com.gmail.nossr50.skills.Herbalism;
+import com.gmail.nossr50.skills.Mining;
+import com.gmail.nossr50.skills.Skills;
+import com.gmail.nossr50.skills.WoodCutting;
+import com.gmail.nossr50.spout.SpoutStuff;
+
import org.bukkit.Bukkit;
import org.bukkit.Material;
@@ -29,7 +35,6 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import org.getspout.spoutapi.sound.SoundEffect;
import com.gmail.nossr50.locale.mcLocale;
-import com.gmail.nossr50.skills.*;
import com.gmail.nossr50.events.FakeBlockBreakEvent;
public class mcBlockListener implements Listener {
@@ -139,7 +144,7 @@ public class mcBlockListener implements Listener {
* MINING
*/
- if (mcPermissions.getInstance().mining(player) && Mining.canBeSuperBroken(block)) {
+ if (mcPermissions.getInstance().mining(player) && Mining.canBeSuperBroken(mat)) {
if (LoadProperties.miningrequirespickaxe && ItemChecks.isMiningPick(inhand)) {
Mining.miningBlockCheck(player, block, plugin);
}
@@ -169,7 +174,7 @@ public class mcBlockListener implements Listener {
* EXCAVATION
*/
- if (Excavation.canBeGigaDrillBroken(block) && mcPermissions.getInstance().excavation(player) && block.getData() != (byte) 0x5) {
+ if (Excavation.canBeGigaDrillBroken(mat) && mcPermissions.getInstance().excavation(player) && block.getData() != (byte) 0x5) {
if (LoadProperties.excavationRequiresShovel && ItemChecks.isShovel(inhand)) {
Excavation.excavationProcCheck(block, player);
}
@@ -210,13 +215,13 @@ public class mcBlockListener implements Listener {
else if (PP.getAxePreparationMode() && mat.equals(Material.LOG) && mcPermissions.getInstance().woodCuttingAbility(player)) { //Why are we checking the permissions here?
Skills.abilityCheck(player, SkillType.WOODCUTTING);
}
- else if (PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(block)) {
+ else if (PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(mat)) {
Skills.abilityCheck(player, SkillType.MINING);
}
- else if (PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(block)) {
+ else if (PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(mat)) {
Skills.abilityCheck(player, SkillType.EXCAVATION);
}
- else if (PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(block) || mat.equals(Material.SNOW))) {
+ else if (PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(mat) || mat.equals(Material.SNOW))) {
Skills.abilityCheck(player, SkillType.UNARMED);
}
}
diff --git a/src/main/java/com/gmail/nossr50/m.java b/src/main/java/com/gmail/nossr50/m.java
index 3c82801e1..60236b185 100644
--- a/src/main/java/com/gmail/nossr50/m.java
+++ b/src/main/java/com/gmail/nossr50/m.java
@@ -3,12 +3,13 @@ package com.gmail.nossr50;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
-import org.bukkit.entity.*;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.inventory.ItemStack;
-import com.gmail.nossr50.config.*;
+import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.FakeBlockBreakEvent;
diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java
index ee2f9b05f..eb76b4e6a 100644
--- a/src/main/java/com/gmail/nossr50/mcMMO.java
+++ b/src/main/java/com/gmail/nossr50/mcMMO.java
@@ -9,13 +9,13 @@ import com.gmail.nossr50.commands.party.*;
import com.gmail.nossr50.commands.general.*;
import com.gmail.nossr50.config.*;
import com.gmail.nossr50.runnables.*;
+import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.listeners.mcBlockListener;
import com.gmail.nossr50.listeners.mcEntityListener;
import com.gmail.nossr50.listeners.mcPlayerListener;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
-import com.gmail.nossr50.skills.*;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
diff --git a/src/main/java/com/gmail/nossr50/skills/Excavation.java b/src/main/java/com/gmail/nossr50/skills/Excavation.java
index e6ac783c3..01bbf512d 100644
--- a/src/main/java/com/gmail/nossr50/skills/Excavation.java
+++ b/src/main/java/com/gmail/nossr50/skills/Excavation.java
@@ -1,6 +1,7 @@
package com.gmail.nossr50.skills;
import java.util.ArrayList;
+import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -21,153 +22,120 @@ import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import org.getspout.spoutapi.sound.SoundEffect;
-public class Excavation
-{
- public static boolean canBeGigaDrillBroken(Block block)
- {
- switch(block.getType()){
- case CLAY:
- case DIRT:
- case GRASS:
- case GRAVEL:
- case MYCEL:
- case SAND:
- case SOUL_SAND:
- return true;
- }
- return false;
- }
-
- public static void excavationProcCheck(Block block, Player player)
- {
- Material type = block.getType();
- Location loc = block.getLocation();
-
- PlayerProfile PP = Users.getProfile(player);
- int skillLevel = PP.getSkillLevel(SkillType.EXCAVATION);
- ArrayList is = new ArrayList();
- int xp = LoadProperties.mbase;
-
- switch(type)
- {
- case DIRT:
- for(ExcavationTreasure treasure : LoadTreasures.excavationFromDirt)
- {
- if(skillLevel >= treasure.getDropLevel())
- {
- if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
- {
- xp += treasure.getXp();
- is.add(treasure.getDrop());
- }
- }
- }
- break;
- case GRASS:
- for(ExcavationTreasure treasure : LoadTreasures.excavationFromGrass)
- {
- if(skillLevel >= treasure.getDropLevel())
- {
- if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
- {
- xp += treasure.getXp();
- is.add(treasure.getDrop());
- }
- }
- }
- break;
- case SAND:
- for(ExcavationTreasure treasure : LoadTreasures.excavationFromSand)
- {
- if(skillLevel >= treasure.getDropLevel())
- {
- if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
- {
- xp += treasure.getXp();
- is.add(treasure.getDrop());
- }
- }
- }
- break;
- case GRAVEL:
- for(ExcavationTreasure treasure : LoadTreasures.excavationFromGravel)
- {
- if(skillLevel >= treasure.getDropLevel())
- {
- if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
- {
- xp += treasure.getXp();
- is.add(treasure.getDrop());
- }
- }
- }
- break;
- case CLAY:
- for(ExcavationTreasure treasure : LoadTreasures.excavationFromClay)
- {
- if(skillLevel >= treasure.getDropLevel())
- {
- if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
- {
- xp += treasure.getXp();
- is.add(treasure.getDrop());
- }
- }
- }
- break;
- case MYCEL:
- for(ExcavationTreasure treasure : LoadTreasures.excavationFromMycel)
- {
- if(skillLevel >= treasure.getDropLevel())
- {
- if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
- {
- xp += treasure.getXp();
- is.add(treasure.getDrop());
- }
- }
- }
- break;
- case SOUL_SAND:
- for(ExcavationTreasure treasure : LoadTreasures.excavationFromSoulSand)
- {
- if(skillLevel >= treasure.getDropLevel())
- {
- if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
- {
- xp += treasure.getXp();
- is.add(treasure.getDrop());
- }
- }
- }
- break;
- }
-
- //Drop items
- for(ItemStack x : is)
- {
- if(x != null)
- m.mcDropItem(loc, x);
- }
-
- //Handle XP related tasks
- PP.addXP(SkillType.EXCAVATION, xp, player);
- Skills.XpCheckSkill(SkillType.EXCAVATION, player);
+public class Excavation {
+
+ /**
+ * Check to see if a block can be broken by Giga Drill Breaker.
+ *
+ * @param material The type of block to check
+ * @return
+ */
+ public static boolean canBeGigaDrillBroken(Material type) {
+ switch (type) {
+ case CLAY:
+ case DIRT:
+ case GRASS:
+ case GRAVEL:
+ case MYCEL:
+ case SAND:
+ case SOUL_SAND:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * Check to see if treasures were found.
+ *
+ * @param block The block to check
+ * @param player The player who broke the block
+ */
+ public static void excavationProcCheck(Block block, Player player) {
+ Material type = block.getType();
+ Location loc = block.getLocation();
+
+ PlayerProfile PP = Users.getProfile(player);
+ int skillLevel = PP.getSkillLevel(SkillType.EXCAVATION);
+ ArrayList is = new ArrayList();
+
+ List treasures = new ArrayList();
+
+ int xp = LoadProperties.mbase;
+
+ switch (type) {
+ case DIRT:
+ treasures = LoadTreasures.excavationFromDirt;
+ break;
+
+ case GRASS:
+ treasures = LoadTreasures.excavationFromGrass;
+ break;
+
+ case SAND:
+ treasures = LoadTreasures.excavationFromSand;
+ break;
+
+ case GRAVEL:
+ treasures = LoadTreasures.excavationFromGravel;
+ break;
+
+ case CLAY:
+ treasures = LoadTreasures.excavationFromClay;
+ break;
+
+ case MYCEL:
+ treasures = LoadTreasures.excavationFromMycel;
+ break;
+
+ case SOUL_SAND:
+ treasures = LoadTreasures.excavationFromSoulSand;
+ break;
+
+ default:
+ break;
+ }
+
+ for (ExcavationTreasure treasure : treasures) {
+ if (skillLevel >= treasure.getDropLevel()) {
+ if (Math.random() * 100 <= treasure.getDropChance()) {
+ xp += treasure.getXp();
+ is.add(treasure.getDrop());
+ }
+ }
+ }
+
+ //Drop items
+ for (ItemStack x : is) {
+ if (x != null) {
+ m.mcDropItem(loc, x);
+ }
+ }
+
+ //Handle XP related tasks
+ PP.addXP(SkillType.EXCAVATION, xp, player);
+ Skills.XpCheckSkill(SkillType.EXCAVATION, player);
+ }
+
+ /**
+ * Handle triple drops from Giga Drill Breaker.
+ *
+ * @param player The player using the ability
+ * @param block The block to check
+ */
+ public static void gigaDrillBreaker(Player player, Block block) {
+ Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss);
+
+ if (block.getData() != (byte) 0x5) {
+ PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
+ Bukkit.getPluginManager().callEvent(armswing);
+
+ Excavation.excavationProcCheck(block, player);
+ Excavation.excavationProcCheck(block, player);
+ }
+
+ if (LoadProperties.spoutEnabled) {
+ SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
+ }
}
-
- public static void gigaDrillBreaker(Player player, Block block)
- {
- Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss);
- if(block.getData() != (byte)5)
- {
- PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
- Bukkit.getPluginManager().callEvent(armswing);
- Excavation.excavationProcCheck(block, player);
- Excavation.excavationProcCheck(block, player);
- Excavation.excavationProcCheck(block, player);
- }
-
- if(LoadProperties.spoutEnabled)
- SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
- }
}
\ No newline at end of file
diff --git a/src/main/java/com/gmail/nossr50/skills/Mining.java b/src/main/java/com/gmail/nossr50/skills/Mining.java
index 0eb60c226..a28a56f3a 100644
--- a/src/main/java/com/gmail/nossr50/skills/Mining.java
+++ b/src/main/java/com/gmail/nossr50/skills/Mining.java
@@ -140,16 +140,16 @@ public class Mining
if(plugin.misc.blockWatchList.contains(block) || block.getData() == (byte) 5)
return;
miningXP(player, block);
- if(canBeSuperBroken(block))
+ if(canBeSuperBroken(block.getType()))
blockProcCheck(block, player);
}
/*
* Handling SuperBreaker stuff
*/
- public static Boolean canBeSuperBroken(Block block)
+ public static Boolean canBeSuperBroken(Material type)
{
- switch(block.getType()){
+ switch(type){
case COAL_ORE:
case DIAMOND_ORE:
case ENDER_STONE:
diff --git a/src/main/java/com/gmail/nossr50/skills/Skills.java b/src/main/java/com/gmail/nossr50/skills/Skills.java
index d7bdd5295..f34e6f6bf 100644
--- a/src/main/java/com/gmail/nossr50/skills/Skills.java
+++ b/src/main/java/com/gmail/nossr50/skills/Skills.java
@@ -322,7 +322,7 @@ public class Skills
}
case GREEN_TERRA:
- if (!ability.blockCheck(block)) {
+ if (!ability.blockCheck(block.getType())) {
activate = false;
break;
}