*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,153 +22,120 @@ 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()){ *
case CLAY: * @param material The type of block to check
case DIRT: * @return
case GRASS: */
case GRAVEL: public static boolean canBeGigaDrillBroken(Material type) {
case MYCEL: switch (type) {
case SAND: case CLAY:
case SOUL_SAND: case DIRT:
return true; case GRASS:
} case GRAVEL:
return false; case MYCEL:
} case SAND:
case SOUL_SAND:
public static void excavationProcCheck(Block block, Player player) return true;
{ default:
Material type = block.getType(); return false;
Location loc = block.getLocation(); }
}
PlayerProfile PP = Users.getProfile(player);
int skillLevel = PP.getSkillLevel(SkillType.EXCAVATION); /**
ArrayList<ItemStack> is = new ArrayList<ItemStack>(); * Check to see if treasures were found.
int xp = LoadProperties.mbase; *
* @param block The block to check
switch(type) * @param player The player who broke the block
{ */
case DIRT: public static void excavationProcCheck(Block block, Player player) {
for(ExcavationTreasure treasure : LoadTreasures.excavationFromDirt) Material type = block.getType();
{ Location loc = block.getLocation();
if(skillLevel >= treasure.getDropLevel())
{ PlayerProfile PP = Users.getProfile(player);
if(Math.random() * 100 > (100.00 - treasure.getDropChance())) int skillLevel = PP.getSkillLevel(SkillType.EXCAVATION);
{ ArrayList<ItemStack> is = new ArrayList<ItemStack>();
xp += treasure.getXp();
is.add(treasure.getDrop()); List<ExcavationTreasure> treasures = new ArrayList<ExcavationTreasure>();
}
} int xp = LoadProperties.mbase;
}
break; switch (type) {
case GRASS: case DIRT:
for(ExcavationTreasure treasure : LoadTreasures.excavationFromGrass) treasures = LoadTreasures.excavationFromDirt;
{ break;
if(skillLevel >= treasure.getDropLevel())
{ case GRASS:
if(Math.random() * 100 > (100.00 - treasure.getDropChance())) treasures = LoadTreasures.excavationFromGrass;
{ break;
xp += treasure.getXp();
is.add(treasure.getDrop()); case SAND:
} treasures = LoadTreasures.excavationFromSand;
} break;
}
break; case GRAVEL:
case SAND: treasures = LoadTreasures.excavationFromGravel;
for(ExcavationTreasure treasure : LoadTreasures.excavationFromSand) break;
{
if(skillLevel >= treasure.getDropLevel()) case CLAY:
{ treasures = LoadTreasures.excavationFromClay;
if(Math.random() * 100 > (100.00 - treasure.getDropChance())) break;
{
xp += treasure.getXp(); case MYCEL:
is.add(treasure.getDrop()); treasures = LoadTreasures.excavationFromMycel;
} break;
}
} case SOUL_SAND:
break; treasures = LoadTreasures.excavationFromSoulSand;
case GRAVEL: break;
for(ExcavationTreasure treasure : LoadTreasures.excavationFromGravel)
{ default:
if(skillLevel >= treasure.getDropLevel()) break;
{ }
if(Math.random() * 100 > (100.00 - treasure.getDropChance()))
{ for (ExcavationTreasure treasure : treasures) {
xp += treasure.getXp(); if (skillLevel >= treasure.getDropLevel()) {
is.add(treasure.getDrop()); if (Math.random() * 100 <= treasure.getDropChance()) {
} xp += treasure.getXp();
} is.add(treasure.getDrop());
} }
break; }
case CLAY: }
for(ExcavationTreasure treasure : LoadTreasures.excavationFromClay)
{ //Drop items
if(skillLevel >= treasure.getDropLevel()) for (ItemStack x : is) {
{ if (x != null) {
if(Math.random() * 100 > (100.00 - treasure.getDropChance())) m.mcDropItem(loc, x);
{ }
xp += treasure.getXp(); }
is.add(treasure.getDrop());
} //Handle XP related tasks
} PP.addXP(SkillType.EXCAVATION, xp, player);
} Skills.XpCheckSkill(SkillType.EXCAVATION, player);
break; }
case MYCEL:
for(ExcavationTreasure treasure : LoadTreasures.excavationFromMycel) /**
{ * Handle triple drops from Giga Drill Breaker.
if(skillLevel >= treasure.getDropLevel()) *
{ * @param player The player using the ability
if(Math.random() * 100 > (100.00 - treasure.getDropChance())) * @param block The block to check
{ */
xp += treasure.getXp(); public static void gigaDrillBreaker(Player player, Block block) {
is.add(treasure.getDrop()); Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss);
}
} if (block.getData() != (byte) 0x5) {
} PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
break; Bukkit.getPluginManager().callEvent(armswing);
case SOUL_SAND:
for(ExcavationTreasure treasure : LoadTreasures.excavationFromSoulSand) Excavation.excavationProcCheck(block, player);
{ Excavation.excavationProcCheck(block, player);
if(skillLevel >= treasure.getDropLevel()) }
{
if(Math.random() * 100 > (100.00 - treasure.getDropChance())) if (LoadProperties.spoutEnabled) {
{ SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
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 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());
}
} }

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;
} }