|
@@ -20,7 +20,6 @@ import java.util.ArrayList;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
|
|
|
-import org.bukkit.Location;
|
|
|
import org.bukkit.block.Block;
|
|
|
import org.bukkit.entity.Player;
|
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
|
@@ -30,13 +29,23 @@ import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
|
import com.gmail.nossr50.Users;
|
|
|
import com.gmail.nossr50.m;
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
-import com.gmail.nossr50.config.LoadProperties;
|
|
|
-import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
|
|
|
|
|
public class BlastMining{
|
|
|
|
|
|
- public static List<Block> explosionYields(List<Block> ores, List<Block> debris, float yield, float oreBonus, float debrisReduction, Location location, int extraDrops)
|
|
|
+ /**
|
|
|
+ * Handler for what blocks drop from the explosion.
|
|
|
+ *
|
|
|
+ * @param ores List of ore blocks destroyed by the explosion
|
|
|
+ * @param debris List of non-ore blocks destroyed by the explosion
|
|
|
+ * @param yield Percentage of blocks to drop
|
|
|
+ * @param oreBonus Percentage bonus for ore drops
|
|
|
+ * @param debrisReduction Percentage reduction for non-ore drops
|
|
|
+ * @param extraDrops Number of times to drop each block
|
|
|
+ * @param plugin mcMMO plugin instance
|
|
|
+ * @return A list of blocks dropped from the explosion
|
|
|
+ */
|
|
|
+ private static List<Block> explosionYields(List<Block> ores, List<Block> debris, float yield, float oreBonus, float debrisReduction, int extraDrops, mcMMO plugin)
|
|
|
{
|
|
|
Iterator<Block> iterator2 = ores.iterator();
|
|
|
List<Block> blocksDropped = new ArrayList<Block>();
|
|
@@ -47,15 +56,18 @@ public class BlastMining{
|
|
|
{
|
|
|
blocksDropped.add(temp);
|
|
|
Mining.miningDrops(temp);
|
|
|
- if(extraDrops == 2)
|
|
|
- {
|
|
|
- blocksDropped.add(temp);
|
|
|
- Mining.miningDrops(temp);
|
|
|
- }
|
|
|
- if(extraDrops == 3)
|
|
|
+ if(temp.getData() != (byte)5 && !plugin.misc.blockWatchList.contains(temp))
|
|
|
{
|
|
|
- blocksDropped.add(temp);
|
|
|
- Mining.miningDrops(temp);
|
|
|
+ if(extraDrops == 2)
|
|
|
+ {
|
|
|
+ blocksDropped.add(temp);
|
|
|
+ Mining.miningDrops(temp);
|
|
|
+ }
|
|
|
+ if(extraDrops == 3)
|
|
|
+ {
|
|
|
+ blocksDropped.add(temp);
|
|
|
+ Mining.miningDrops(temp);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -73,32 +85,30 @@ public class BlastMining{
|
|
|
return blocksDropped;
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * Process the drops from the explosion
|
|
|
+ /**
|
|
|
+ * Handler for explosion drops and XP gain.
|
|
|
+ * @param player Player triggering the explosion
|
|
|
+ * @param event Event whose explosion is being processed
|
|
|
+ * @param plugin mcMMO plugin instance
|
|
|
*/
|
|
|
public static void dropProcessing(Player player, EntityExplodeEvent event, mcMMO plugin)
|
|
|
{
|
|
|
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
|
|
float yield = event.getYield();
|
|
|
- Location location = event.getLocation();
|
|
|
List<Block> blocks = event.blockList();
|
|
|
Iterator<Block> iterator = blocks.iterator();
|
|
|
|
|
|
List<Block> ores = new ArrayList<Block>();
|
|
|
List<Block> debris = new ArrayList<Block>();
|
|
|
-
|
|
|
List<Block> xp = new ArrayList<Block>();
|
|
|
-
|
|
|
+
|
|
|
while(iterator.hasNext())
|
|
|
{
|
|
|
Block temp = iterator.next();
|
|
|
- if(temp.getData() != 5 && !plugin.misc.blockWatchList.contains(temp))
|
|
|
- {
|
|
|
- if(m.isOre(temp))
|
|
|
- ores.add(temp);
|
|
|
- else
|
|
|
- debris.add(temp);
|
|
|
- }
|
|
|
+ if(m.isOre(temp))
|
|
|
+ ores.add(temp);
|
|
|
+ else
|
|
|
+ debris.add(temp);
|
|
|
}
|
|
|
|
|
|
//Normal explosion
|
|
@@ -106,51 +116,52 @@ public class BlastMining{
|
|
|
return;
|
|
|
|
|
|
event.setYield(0);
|
|
|
+
|
|
|
//+35% ores, -10% debris
|
|
|
if(skillLevel >= 125 && skillLevel < 250)
|
|
|
- xp = explosionYields(ores, debris, yield, .35f, .10f, location, 1);
|
|
|
+ xp = explosionYields(ores, debris, yield, .35f, .10f, 1, plugin);
|
|
|
|
|
|
//+40% ores, -20% debris
|
|
|
if(skillLevel >= 250 && skillLevel < 375)
|
|
|
- xp = explosionYields(ores, debris, yield, .40f, .20f, location, 1);
|
|
|
+ xp = explosionYields(ores, debris, yield, .40f, .20f, 1, plugin);
|
|
|
|
|
|
//No debris, +45% ores
|
|
|
if(skillLevel >= 375 && skillLevel < 500)
|
|
|
- xp = explosionYields(ores, debris, yield, .45f, .30f, location, 1);
|
|
|
+ xp = explosionYields(ores, debris, yield, .45f, .30f, 1, plugin);
|
|
|
|
|
|
//No debris, +50% ores
|
|
|
if(skillLevel >= 500 && skillLevel < 625)
|
|
|
- xp = explosionYields(ores, debris, yield, .50f, .30f, location, 1);
|
|
|
+ xp = explosionYields(ores, debris, yield, .50f, .30f, 1, plugin);
|
|
|
|
|
|
//Double Drops, No Debris, +55% ores
|
|
|
if(skillLevel >= 625 && skillLevel < 750)
|
|
|
- xp = explosionYields(ores, debris, yield, .55f, .30f, location, 2);
|
|
|
+ xp = explosionYields(ores, debris, yield, .55f, .30f, 2, plugin);
|
|
|
|
|
|
//Double Drops, No Debris, +60% ores
|
|
|
if(skillLevel >= 750 && skillLevel < 875)
|
|
|
- xp = explosionYields(ores, debris, yield, .60f, .30f, location, 2);
|
|
|
+ xp = explosionYields(ores, debris, yield, .60f, .30f, 2, plugin);
|
|
|
|
|
|
//Triple Drops, No debris, +65% ores
|
|
|
if(skillLevel >= 875 && skillLevel < 1000)
|
|
|
- xp = explosionYields(ores, debris, yield, .65f, .30f, location, 3);
|
|
|
+ xp = explosionYields(ores, debris, yield, .65f, .30f, 3, plugin);
|
|
|
|
|
|
//Triple Drops, No debris, +70% ores
|
|
|
if(skillLevel >= 1000)
|
|
|
- xp = explosionYields(ores, debris, yield, .70f, .30f, location, 3);
|
|
|
+ xp = explosionYields(ores, debris, yield, .70f, .30f, 3, plugin);
|
|
|
|
|
|
for(Block block : xp)
|
|
|
{
|
|
|
- blastMiningXP(player, block, plugin);
|
|
|
+ if(block.getData() != (byte)5 && !plugin.misc.blockWatchList.contains(block))
|
|
|
+ Mining.miningXP(player, block);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * Bigger Bombs (Unlocked at Mining 250)
|
|
|
+ /**
|
|
|
+ * Increases the blast radius of the explosion.
|
|
|
*
|
|
|
- * Increases radius of explosion by 1 at 250.
|
|
|
- * Increases radius of explosion by 2 at 500.
|
|
|
- * Increases radius of explosion by 3 at 750.
|
|
|
- * Increases radius of explosion by 4 at 1000.
|
|
|
+ * @param player Player triggering the explosion
|
|
|
+ * @param event Event whose explosion radius is being changed
|
|
|
*/
|
|
|
public static void biggerBombs(Player player, ExplosionPrimeEvent event)
|
|
|
{
|
|
@@ -169,12 +180,11 @@ public class BlastMining{
|
|
|
event.setRadius(radius);
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * Demolitions Expertise (Unlocked at Mining 500)
|
|
|
+ /**
|
|
|
+ * Decreases damage dealt by the explosion.
|
|
|
*
|
|
|
- * Reduces explosion damage to 1/4 of normal at 500.
|
|
|
- * Reduces explosion damage to 1/2 of normal at 750.
|
|
|
- * Reduces explosion damage to 0 at 1000.
|
|
|
+ * @param player Player triggering the explosion
|
|
|
+ * @param event Event whose explosion damage is being reduced
|
|
|
*/
|
|
|
public static void demolitionsExpertise(Player player, EntityDamageEvent event)
|
|
|
{
|
|
@@ -188,46 +198,8 @@ public class BlastMining{
|
|
|
damage = damage/2;
|
|
|
if(skill >= 1000)
|
|
|
damage = 0;
|
|
|
-
|
|
|
event.setDamage(damage);
|
|
|
}
|
|
|
|
|
|
- public static void blastMiningXP(Player player, Block block, mcMMO plugin)
|
|
|
- {
|
|
|
- PlayerProfile PP = Users.getProfile(player);
|
|
|
- if(plugin.misc.blockWatchList.contains(block) || block.getData() == (byte) 5)
|
|
|
- return;
|
|
|
- int xp = 0;
|
|
|
-
|
|
|
- switch (block.getType()) {
|
|
|
- //COAL
|
|
|
- case COAL_ORE:
|
|
|
- xp += LoadProperties.mcoal;
|
|
|
- break;
|
|
|
- //GOLD
|
|
|
- case GOLD_ORE:
|
|
|
- xp += LoadProperties.mgold;
|
|
|
- break;
|
|
|
- //DIAMOND
|
|
|
- case DIAMOND_ORE:
|
|
|
- xp += LoadProperties.mdiamond;
|
|
|
- break;
|
|
|
- //IRON
|
|
|
- case IRON_ORE:
|
|
|
- xp += LoadProperties.miron;
|
|
|
- break;
|
|
|
- //REDSTONE
|
|
|
- case REDSTONE_ORE:
|
|
|
- xp += LoadProperties.mredstone;
|
|
|
- break;
|
|
|
- //LAPIS
|
|
|
- case LAPIS_ORE:
|
|
|
- xp += LoadProperties.mlapis;
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- PP.addXP(SkillType.MINING, xp, player);
|
|
|
- Skills.XpCheckSkill(SkillType.MINING, player);
|
|
|
- }
|
|
|
|
|
|
-}
|
|
|
+}
|