*CLEANUP*

This commit is contained in:
GJ 2012-03-12 17:57:44 -04:00
parent 49bb3e0a3c
commit 0070333b35
9 changed files with 152 additions and 190 deletions

View File

@ -2,7 +2,14 @@ package com.gmail.nossr50;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; 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.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
package com.gmail.nossr50; package com.gmail.nossr50;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.datatypes; package com.gmail.nossr50.datatypes;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.mcPermissions;
@ -201,20 +200,20 @@ public enum AbilityType
return false; return false;
} }
public boolean blockCheck(Block block) { public boolean blockCheck(Material material) {
switch (this) { switch (this) {
case BERSERK: case BERSERK:
return (Excavation.canBeGigaDrillBroken(block) || block.getType().equals(Material.SNOW)); return (Excavation.canBeGigaDrillBroken(material) || material.equals(Material.SNOW));
case GIGA_DRILL_BREAKER: case GIGA_DRILL_BREAKER:
return Excavation.canBeGigaDrillBroken(block); return Excavation.canBeGigaDrillBroken(material);
case GREEN_TERRA: case GREEN_TERRA:
return Herbalism.makeMossy(block.getType()); return Herbalism.makeMossy(material);
case LEAF_BLOWER: case LEAF_BLOWER:
return block.getType().equals(Material.LEAVES); return material.equals(Material.LEAVES);
case SUPER_BREAKER: case SUPER_BREAKER:
return Mining.canBeSuperBroken(block); return Mining.canBeSuperBroken(material);
case TREE_FELLER: case TREE_FELLER:
return block.getType().equals(Material.LOG); return material.equals(Material.LOG);
default: default:
return false; return false;
} }

View File

@ -2,14 +2,20 @@ package com.gmail.nossr50.listeners;
import com.gmail.nossr50.BlockChecks; import com.gmail.nossr50.BlockChecks;
import com.gmail.nossr50.ItemChecks; import com.gmail.nossr50.ItemChecks;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.datatypes.AbilityType; import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; 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.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
@ -29,7 +35,6 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import org.getspout.spoutapi.sound.SoundEffect; import org.getspout.spoutapi.sound.SoundEffect;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.skills.*;
import com.gmail.nossr50.events.FakeBlockBreakEvent; import com.gmail.nossr50.events.FakeBlockBreakEvent;
public class mcBlockListener implements Listener { public class mcBlockListener implements Listener {
@ -139,7 +144,7 @@ public class mcBlockListener implements Listener {
* MINING * MINING
*/ */
if (mcPermissions.getInstance().mining(player) && Mining.canBeSuperBroken(block)) { if (mcPermissions.getInstance().mining(player) && Mining.canBeSuperBroken(mat)) {
if (LoadProperties.miningrequirespickaxe && ItemChecks.isMiningPick(inhand)) { if (LoadProperties.miningrequirespickaxe && ItemChecks.isMiningPick(inhand)) {
Mining.miningBlockCheck(player, block, plugin); Mining.miningBlockCheck(player, block, plugin);
} }
@ -169,7 +174,7 @@ public class mcBlockListener implements Listener {
* EXCAVATION * 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)) { if (LoadProperties.excavationRequiresShovel && ItemChecks.isShovel(inhand)) {
Excavation.excavationProcCheck(block, player); 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? else if (PP.getAxePreparationMode() && mat.equals(Material.LOG) && mcPermissions.getInstance().woodCuttingAbility(player)) { //Why are we checking the permissions here?
Skills.abilityCheck(player, SkillType.WOODCUTTING); Skills.abilityCheck(player, SkillType.WOODCUTTING);
} }
else if (PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(block)) { else if (PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(mat)) {
Skills.abilityCheck(player, SkillType.MINING); Skills.abilityCheck(player, SkillType.MINING);
} }
else if (PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(block)) { else if (PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(mat)) {
Skills.abilityCheck(player, SkillType.EXCAVATION); 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); Skills.abilityCheck(player, SkillType.UNARMED);
} }
} }

View File

@ -3,12 +3,13 @@ package com.gmail.nossr50;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; 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.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.inventory.ItemStack; 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.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.FakeBlockBreakEvent; import com.gmail.nossr50.events.FakeBlockBreakEvent;

View File

@ -9,13 +9,13 @@ import com.gmail.nossr50.commands.party.*;
import com.gmail.nossr50.commands.general.*; import com.gmail.nossr50.commands.general.*;
import com.gmail.nossr50.config.*; import com.gmail.nossr50.config.*;
import com.gmail.nossr50.runnables.*; import com.gmail.nossr50.runnables.*;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.listeners.mcBlockListener; import com.gmail.nossr50.listeners.mcBlockListener;
import com.gmail.nossr50.listeners.mcEntityListener; import com.gmail.nossr50.listeners.mcEntityListener;
import com.gmail.nossr50.listeners.mcPlayerListener; import com.gmail.nossr50.listeners.mcPlayerListener;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.skills.*;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedReader; import java.io.BufferedReader;

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.skills; package com.gmail.nossr50.skills;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -21,11 +22,16 @@ import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import org.getspout.spoutapi.sound.SoundEffect; import org.getspout.spoutapi.sound.SoundEffect;
public class Excavation public class Excavation {
{
public static boolean canBeGigaDrillBroken(Block block) /**
{ * Check to see if a block can be broken by Giga Drill Breaker.
switch(block.getType()){ *
* @param material The type of block to check
* @return
*/
public static boolean canBeGigaDrillBroken(Material type) {
switch (type) {
case CLAY: case CLAY:
case DIRT: case DIRT:
case GRASS: case GRASS:
@ -34,140 +40,102 @@ public class Excavation
case SAND: case SAND:
case SOUL_SAND: case SOUL_SAND:
return true; return true;
} default:
return false; return false;
} }
}
public static void excavationProcCheck(Block block, Player player) /**
{ * 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(); Material type = block.getType();
Location loc = block.getLocation(); Location loc = block.getLocation();
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
int skillLevel = PP.getSkillLevel(SkillType.EXCAVATION); int skillLevel = PP.getSkillLevel(SkillType.EXCAVATION);
ArrayList<ItemStack> is = new ArrayList<ItemStack>(); ArrayList<ItemStack> is = new ArrayList<ItemStack>();
List<ExcavationTreasure> treasures = new ArrayList<ExcavationTreasure>();
int xp = LoadProperties.mbase; int xp = LoadProperties.mbase;
switch(type) switch (type) {
{
case DIRT: case DIRT:
for(ExcavationTreasure treasure : LoadTreasures.excavationFromDirt) treasures = LoadTreasures.excavationFromDirt;
{
if(skillLevel >= treasure.getDropLevel())
{
if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
{
xp += treasure.getXp();
is.add(treasure.getDrop());
}
}
}
break; break;
case GRASS: case GRASS:
for(ExcavationTreasure treasure : LoadTreasures.excavationFromGrass) treasures = LoadTreasures.excavationFromGrass;
{
if(skillLevel >= treasure.getDropLevel())
{
if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
{
xp += treasure.getXp();
is.add(treasure.getDrop());
}
}
}
break; break;
case SAND: case SAND:
for(ExcavationTreasure treasure : LoadTreasures.excavationFromSand) treasures = LoadTreasures.excavationFromSand;
{
if(skillLevel >= treasure.getDropLevel())
{
if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
{
xp += treasure.getXp();
is.add(treasure.getDrop());
}
}
}
break; break;
case GRAVEL: case GRAVEL:
for(ExcavationTreasure treasure : LoadTreasures.excavationFromGravel) treasures = LoadTreasures.excavationFromGravel;
{
if(skillLevel >= treasure.getDropLevel())
{
if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
{
xp += treasure.getXp();
is.add(treasure.getDrop());
}
}
}
break; break;
case CLAY: case CLAY:
for(ExcavationTreasure treasure : LoadTreasures.excavationFromClay) treasures = LoadTreasures.excavationFromClay;
{
if(skillLevel >= treasure.getDropLevel())
{
if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
{
xp += treasure.getXp();
is.add(treasure.getDrop());
}
}
}
break; break;
case MYCEL: case MYCEL:
for(ExcavationTreasure treasure : LoadTreasures.excavationFromMycel) treasures = LoadTreasures.excavationFromMycel;
{
if(skillLevel >= treasure.getDropLevel())
{
if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
{
xp += treasure.getXp();
is.add(treasure.getDrop());
}
}
}
break; break;
case SOUL_SAND: case SOUL_SAND:
for(ExcavationTreasure treasure : LoadTreasures.excavationFromSoulSand) treasures = LoadTreasures.excavationFromSoulSand;
{ break;
if(skillLevel >= treasure.getDropLevel())
{ default:
if(Math.random() * 100 > (100.00 - treasure.getDropChance())) break;
{ }
for (ExcavationTreasure treasure : treasures) {
if (skillLevel >= treasure.getDropLevel()) {
if (Math.random() * 100 <= treasure.getDropChance()) {
xp += treasure.getXp(); xp += treasure.getXp();
is.add(treasure.getDrop()); is.add(treasure.getDrop());
} }
} }
} }
break;
}
//Drop items //Drop items
for(ItemStack x : is) for (ItemStack x : is) {
{ if (x != null) {
if(x != null)
m.mcDropItem(loc, x); m.mcDropItem(loc, x);
} }
}
//Handle XP related tasks //Handle XP related tasks
PP.addXP(SkillType.EXCAVATION, xp, player); PP.addXP(SkillType.EXCAVATION, xp, player);
Skills.XpCheckSkill(SkillType.EXCAVATION, player); Skills.XpCheckSkill(SkillType.EXCAVATION, player);
} }
public static void gigaDrillBreaker(Player player, Block block) /**
{ * 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); Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss);
if(block.getData() != (byte)5)
{ if (block.getData() != (byte) 0x5) {
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player); PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
Bukkit.getPluginManager().callEvent(armswing); Bukkit.getPluginManager().callEvent(armswing);
Excavation.excavationProcCheck(block, player);
Excavation.excavationProcCheck(block, player); Excavation.excavationProcCheck(block, player);
Excavation.excavationProcCheck(block, player); Excavation.excavationProcCheck(block, player);
} }
if(LoadProperties.spoutEnabled) if (LoadProperties.spoutEnabled) {
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
} }
}
} }

View File

@ -140,16 +140,16 @@ public class Mining
if(plugin.misc.blockWatchList.contains(block) || block.getData() == (byte) 5) if(plugin.misc.blockWatchList.contains(block) || block.getData() == (byte) 5)
return; return;
miningXP(player, block); miningXP(player, block);
if(canBeSuperBroken(block)) if(canBeSuperBroken(block.getType()))
blockProcCheck(block, player); blockProcCheck(block, player);
} }
/* /*
* Handling SuperBreaker stuff * Handling SuperBreaker stuff
*/ */
public static Boolean canBeSuperBroken(Block block) public static Boolean canBeSuperBroken(Material type)
{ {
switch(block.getType()){ switch(type){
case COAL_ORE: case COAL_ORE:
case DIAMOND_ORE: case DIAMOND_ORE:
case ENDER_STONE: case ENDER_STONE:

View File

@ -322,7 +322,7 @@ public class Skills
} }
case GREEN_TERRA: case GREEN_TERRA:
if (!ability.blockCheck(block)) { if (!ability.blockCheck(block.getType())) {
activate = false; activate = false;
break; break;
} }