mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-30 00:56:47 +01:00
*CLEANUP*
This commit is contained in:
parent
49bb3e0a3c
commit
0070333b35
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 class Excavation {
|
||||
|
||||
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<ItemStack> is = new ArrayList<ItemStack>();
|
||||
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);
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
/**
|
||||
* 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();
|
||||
|
||||
if(LoadProperties.spoutEnabled)
|
||||
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int skillLevel = PP.getSkillLevel(SkillType.EXCAVATION);
|
||||
ArrayList<ItemStack> is = new ArrayList<ItemStack>();
|
||||
|
||||
List<ExcavationTreasure> treasures = new ArrayList<ExcavationTreasure>();
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
@ -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:
|
||||
|
@ -322,7 +322,7 @@ public class Skills
|
||||
}
|
||||
|
||||
case GREEN_TERRA:
|
||||
if (!ability.blockCheck(block)) {
|
||||
if (!ability.blockCheck(block.getType())) {
|
||||
activate = false;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user