Phase 1 of moving crap around in the interest of my sanity. Also currently does not build due to a

craftbukkit dep. (ColoredConsoleSender isn't in bukkit, if you are building this, switch to cb for now
in your library deps.) UNTESTED.
This commit is contained in:
Ben Diskmaster L
2011-09-04 04:21:59 -05:00
parent be4986b253
commit cbd4a512d5
364 changed files with 9545 additions and 9545 deletions

View File

@@ -0,0 +1,89 @@
package com.gmail.nossr50.skills;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
public class Acrobatics {
public static void acrobaticsCheck(Player player, EntityDamageEvent event)
{
if(player != null && mcPermissions.getInstance().acrobatics(player))
{
PlayerProfile PP = Users.getProfile(player);
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
if(player.isSneaking())
acrovar = acrovar * 2;
if(Math.random() * 1000 <= acrovar && !event.isCancelled())
{
int threshold = 7;
if(player.isSneaking())
threshold = 14;
int newDamage = event.getDamage() - threshold;
if(newDamage < 0)
newDamage = 0;
/*
* Check for death
*/
if(player.getHealth() - newDamage >= 1){
if(!event.isCancelled())
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 8)*10);
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
event.setDamage(newDamage);
if(event.getDamage() <= 0)
event.setCancelled(true);
if(player.isSneaking()){
player.sendMessage(ChatColor.GREEN+"**GRACEFUL ROLL**");
} else {
player.sendMessage("**ROLL**");
}
}
} else if (!event.isCancelled()){
if(player.getHealth() - event.getDamage() >= 1){
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*10);
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
}
}
}
}
public static void dodgeChecks(EntityDamageByEntityEvent event){
Player defender = (Player) event.getEntity();
PlayerProfile PPd = Users.getProfile(defender);
if(mcPermissions.getInstance().acrobatics(defender)){
if(PPd.getSkillLevel(SkillType.ACROBATICS) <= 800){
if(Math.random() * 4000 <= PPd.getSkillLevel(SkillType.ACROBATICS)){
defender.sendMessage(ChatColor.GREEN+"**DODGE**");
if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){
PPd.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*1);
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
}
event.setDamage(event.getDamage() / 2);
//Needs to do minimal damage
if(event.getDamage() <= 0)
event.setDamage(1);
}
} else if(Math.random() * 4000 <= 800) {
defender.sendMessage(ChatColor.GREEN+"**DODGE**");
if(System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1){
PPd.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*10);
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
}
event.setDamage(event.getDamage() / 2);
//Needs to deal minimal damage
if(event.getDamage() <= 0)
event.setDamage(1);
}
}
}
}

View File

@@ -0,0 +1,99 @@
package com.gmail.nossr50.skills;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
public class Archery
{
public static void trackArrows(mcMMO pluginx, Entity x, EntityDamageByEntityEvent event, Player attacker)
{
PlayerProfile PPa = Users.getProfile(attacker);
if(!pluginx.misc.arrowTracker.containsKey(x) && event.getDamage() > 0)
{
pluginx.misc.arrowTracker.put(x, 0);
if(attacker != null)
{
if(Math.random() * 1000 <= PPa.getSkillLevel(SkillType.ARCHERY))
{
pluginx.misc.arrowTracker.put(x, 1);
}
}
} else
{
if(event.getDamage() > 0)
{
if(attacker != null)
{
if(Math.random() * 1000 <= PPa.getSkillLevel(SkillType.ARCHERY))
{
pluginx.misc.arrowTracker.put(x, 1);
}
}
}
}
}
public static void ignitionCheck(Entity x, EntityDamageByEntityEvent event, Player attacker)
{
PlayerProfile PPa = Users.getProfile(attacker);
if(Math.random() * 100 >= 75)
{
int ignition = 20;
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 200)
ignition+=20;
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 400)
ignition+=20;
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 600)
ignition+=20;
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 800)
ignition+=20;
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 1000)
ignition+=20;
if(x instanceof Player)
{
Player Defender = (Player)x;
if(!Party.getInstance().inSameParty(attacker, Defender))
{
event.getEntity().setFireTicks(ignition);
attacker.sendMessage(mcLocale.getString("Combat.Ignition")); //$NON-NLS-1$
Defender.sendMessage(mcLocale.getString("Combat.BurningArrowHit")); //$NON-NLS-1$
}
} else {
event.getEntity().setFireTicks(ignition);
attacker.sendMessage(mcLocale.getString("Combat.Ignition")); //$NON-NLS-1$
}
}
}
public static void dazeCheck(Player defender, Player attacker)
{
PlayerProfile PPa = Users.getProfile(attacker);
Location loc = defender.getLocation();
if(Math.random() * 10 > 5)
{
loc.setPitch(90);
} else {
loc.setPitch(-90);
}
if(PPa.getSkillLevel(SkillType.ARCHERY) >= 1000){
if(Math.random() * 1000 <= 500){
defender.teleport(loc);
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); //$NON-NLS-1$
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$
}
} else if(Math.random() * 2000 <= PPa.getSkillLevel(SkillType.ARCHERY)){
defender.teleport(loc);
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); //$NON-NLS-1$
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}

View File

@@ -0,0 +1,155 @@
package com.gmail.nossr50.skills;
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.party.Party;
public class Axes {
public static void skullSplitterCheck(Player player){
PlayerProfile PP = Users.getProfile(player);
if(m.isAxes(player.getItemInHand()) && mcPermissions.getInstance().axesAbility(player)){
/*
* CHECK FOR AXE PREP MODE
*/
if(PP.getAxePreparationMode())
{
PP.setAxePreparationMode(false);
}
int ticks = 2;
int x = PP.getSkillLevel(SkillType.AXES);
while(x >= 50){
x-=50;
ticks++;
}
if(!PP.getSkullSplitterMode() && Skills.cooldownOver(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown))
{
player.sendMessage(mcLocale.getString("Skills.SkullSplitterOn"));
for(Player y : player.getWorld().getPlayers()){
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
y.sendMessage(mcLocale.getString("Skills.SkullSplitterPlayer", new Object[] {player.getName()}));
}
PP.setSkullSplitterActivatedTimeStamp(System.currentTimeMillis());
PP.setSkullSplitterDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
PP.setSkullSplitterMode(true);
}
if(!PP.getSkullSplitterMode() && !Skills.cooldownOver(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown)){
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown)+"s)");
}
}
}
public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx){
Entity x = event.getEntity();
if(x instanceof Wolf){
Wolf wolf = (Wolf)x;
if(Taming.getOwner(wolf, pluginx) != null)
{
if(Taming.getOwner(wolf, pluginx) == attacker)
return;
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(wolf, pluginx)))
return;
}
}
PlayerProfile PPa = Users.getProfile(attacker);
if(m.isAxes(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){
if(PPa.getSkillLevel(SkillType.AXES) >= 750){
if(Math.random() * 1000 <= 750){
if(x instanceof Player){
Player player = (Player)x;
player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!");
}
if(x instanceof Player){
event.setDamage(event.getDamage() * 2 - event.getDamage() / 2);
} else {
event.setDamage(event.getDamage() * 2);
}
attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!");
}
} else if(Math.random() * 1000 <= PPa.getSkillLevel(SkillType.AXES)){
if(x instanceof Player){
Player player = (Player)x;
player.sendMessage(ChatColor.DARK_RED + "You were CRITICALLY hit!");
}
if(x instanceof Player){
event.setDamage(event.getDamage() * 2 - event.getDamage() / 2);
} else {
event.setDamage(event.getDamage() * 2);
}
attacker.sendMessage(ChatColor.RED+"CRITICAL HIT!");
}
}
}
public static void applyAoeDamage(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx)
{
int targets = 0;
if(event.getEntity() instanceof LivingEntity)
{
LivingEntity x = (LivingEntity) event.getEntity();
targets = m.getTier(attacker);
for(Entity derp : x.getWorld().getEntities())
{
if(m.getDistance(x.getLocation(), derp.getLocation()) < 5)
{
//Make sure the Wolf is not friendly
if(derp instanceof Wolf)
{
Wolf hurrDurr = (Wolf)derp;
if(Taming.getOwner(hurrDurr, pluginx) == attacker)
continue;
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr, pluginx)))
continue;
}
//Damage nearby LivingEntities
if(derp instanceof LivingEntity && targets >= 1)
{
if(derp instanceof Player)
{
Player target = (Player)derp;
if(Users.getProfile(target).getGodMode())
continue;
if(target.getName().equals(attacker.getName()))
continue;
if(Party.getInstance().inSameParty(attacker, target))
continue;
if(targets >= 1 && derp.getWorld().getPVP())
{
target.damage(event.getDamage() / 2);
target.sendMessage(ChatColor.DARK_RED+"Struck by CLEAVE!");
targets--;
continue;
}
}
else
{
LivingEntity target = (LivingEntity)derp;
target.damage(event.getDamage() / 2);
targets--;
}
}
}
}
}
}
}

View File

@@ -0,0 +1,260 @@
package com.gmail.nossr50.skills;
import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
public class Excavation
{
public static void gigaDrillBreakerActivationCheck(Player player, Block block)
{
PlayerProfile PP = Users.getProfile(player);
if(m.isShovel(player.getItemInHand()))
{
if(block != null)
{
if(!m.abilityBlockCheck(block))
return;
}
if(PP.getShovelPreparationMode())
{
PP.setShovelPreparationMode(false);
}
int ticks = 2;
int x = PP.getSkillLevel(SkillType.EXCAVATION);
while(x >= 50)
{
x-=50;
ticks++;
}
if(!PP.getGigaDrillBreakerMode() && PP.getGigaDrillBreakerDeactivatedTimeStamp() < System.currentTimeMillis())
{
player.sendMessage(mcLocale.getString("Skills.GigaDrillBreakerOn"));
for(Player y : player.getWorld().getPlayers())
{
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
y.sendMessage(mcLocale.getString("Skills.GigaDrillBreakerPlayer", new Object[] {player.getName()}));
}
PP.setGigaDrillBreakerActivatedTimeStamp(System.currentTimeMillis());
PP.setGigaDrillBreakerDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
PP.setGigaDrillBreakerMode(true);
}
}
}
public static boolean canBeGigaDrillBroken(Block block)
{
return block.getType() == Material.DIRT || block.getType() == Material.GRASS || block.getType() == Material.SAND || block.getType() == Material.GRAVEL || block.getType() == Material.CLAY;
}
public static void excavationProcCheck(byte data, Material type, Location loc, Player player)
{
PlayerProfile PP = Users.getProfile(player);
ArrayList<ItemStack> is = new ArrayList<ItemStack>();
int xp = 0;
switch(type)
{
case GRASS:
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 250)
{
//CHANCE TO GET EGGS
if(LoadProperties.eggs == true && Math.random() * 100 > 99)
{
xp+= LoadProperties.meggs;
is.add(new ItemStack(Material.EGG, 1, (byte)0, (byte)0));
}
//CHANCE TO GET APPLES
if(LoadProperties.apples == true && Math.random() * 100 > 99)
{
xp+= LoadProperties.mapple;
is.add(new ItemStack(Material.APPLE, 1, (byte)0, (byte)0));
}
}
break;
case GRAVEL:
//CHANCE TO GET NETHERRACK
if(LoadProperties.netherrack == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 850 && Math.random() * 200 > 199)
{
xp+= LoadProperties.mnetherrack;
is.add(new ItemStack(Material.NETHERRACK, 1, (byte)0, (byte)0));
}
//CHANCE TO GET SULPHUR
if(LoadProperties.sulphur == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 75)
{
if(Math.random() * 10 > 9)
{
xp+= LoadProperties.msulphur;
is.add(new ItemStack(Material.SULPHUR, 1, (byte)0, (byte)0));
}
}
//CHANCE TO GET BONES
if(LoadProperties.bones == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 175)
{
if(Math.random() * 10 > 9)
{
xp+= LoadProperties.mbones;
is.add(new ItemStack(Material.BONE, 1, (byte)0, (byte)0));
}
}
break;
case SAND:
//CHANCE TO GET GLOWSTONE
if(LoadProperties.glowstone == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 50 && Math.random() * 100 > 95)
{
xp+= LoadProperties.mglowstone2;
is.add(new ItemStack(Material.GLOWSTONE_DUST, 1, (byte)0, (byte)0));
}
//CHANCE TO GET SOUL SAND
if(LoadProperties.slowsand == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 650 && Math.random() * 200 > 199)
{
xp+= LoadProperties.mslowsand;
is.add(new ItemStack(Material.SOUL_SAND, 1, (byte)0, (byte)0));
}
break;
case CLAY:
if(LoadProperties.slimeballs && PP.getSkillLevel(SkillType.EXCAVATION) >= 50)
{
if(Math.random() * 20 > 19)
{
xp+= LoadProperties.mslimeballs;
is.add(new ItemStack(Material.SLIME_BALL, 1, (byte)0, (byte)0));
}
}
if(LoadProperties.string && PP.getSkillLevel(SkillType.EXCAVATION) >= 250)
{
if(Math.random() * 20 > 19)
{
xp+= LoadProperties.mstring;
is.add(new ItemStack(Material.STRING, 1, (byte)0, (byte)0));
}
}
if(LoadProperties.watch && PP.getSkillLevel(SkillType.EXCAVATION) >= 500)
{
if(Math.random() * 100 > 99)
{
xp+= LoadProperties.mwatch;
is.add(new ItemStack(Material.WATCH, 1, (byte)0));
}
}
if(LoadProperties.bucket && PP.getSkillLevel(SkillType.EXCAVATION) >= 500)
{
if(Math.random() * 100 > 99)
{
xp+= LoadProperties.mbucket;
is.add(new ItemStack(Material.BUCKET, 1, (byte)0, (byte)0));
}
}
if(LoadProperties.web && PP.getSkillLevel(SkillType.EXCAVATION) >= 750)
{
if(Math.random() * 20 > 19)
{
xp+= LoadProperties.mweb;
is.add(new ItemStack(Material.WEB, 1, (byte)0, (byte)0));
}
}
break;
}
//DIRT SAND OR GRAVEL
if(type == Material.GRASS || type == Material.DIRT || type == Material.GRAVEL || type == Material.SAND || type == Material.CLAY)
{
xp+= LoadProperties.mbase;
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 750)
{
//CHANCE TO GET CAKE
if(LoadProperties.cake == true && Math.random() * 2000 > 1999)
{
xp+= LoadProperties.mcake;
is.add(new ItemStack(Material.CAKE, 1, (byte)0, (byte)0));
}
}
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 350)
{
//CHANCE TO GET DIAMOND
if(LoadProperties.diamond == true && Math.random() * 750 > 749)
{
xp+= LoadProperties.mdiamond2;
is.add(new ItemStack(Material.DIAMOND, 1, (byte)0, (byte)0));
}
}
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 250)
{
//CHANCE TO GET YELLOW MUSIC
if(LoadProperties.music == true && Math.random() * 2000 > 1999)
{
xp+= LoadProperties.mmusic;
is.add(new ItemStack(Material.GOLD_RECORD, 1, (byte)0, (byte)0));
}
}
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 350)
{
//CHANCE TO GET GREEN MUSIC
if(LoadProperties.music == true && Math.random() * 2000 > 1999)
{
xp+= LoadProperties.mmusic;
is.add(new ItemStack(Material.GREEN_RECORD, 1, (byte)0, (byte)0));
}
}
}
//GRASS OR DIRT
if(type == Material.DIRT || type == Material.GRASS)
{
if(PP.getSkillLevel(SkillType.EXCAVATION) >= 50)
{
//CHANCE FOR COCOA BEANS
if(LoadProperties.cocoabeans == true && Math.random() * 75 > 74)
{
xp+= LoadProperties.mcocoa;
is.add(new ItemStack(Material.getMaterial(351), 1, (byte)0, (byte)3));
}
}
//CHANCE FOR SHROOMS
if(LoadProperties.mushrooms == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 500 && Math.random() * 200 > 199)
{
xp+= LoadProperties.mmushroom2;
switch((int) Math.random() * 1)
{
case 0:
is.add(new ItemStack(Material.BROWN_MUSHROOM, 1, (byte)0, (byte)0));
break;
case 1:
is.add(new ItemStack(Material.RED_MUSHROOM, 1, (byte)0, (byte)0));
break;
}
}
//CHANCE TO GET GLOWSTONE
if(LoadProperties.glowstone == true && PP.getSkillLevel(SkillType.EXCAVATION) >= 25 && Math.random() * 100 > 95)
{
xp+= LoadProperties.mglowstone2;
is.add(new ItemStack(Material.GLOWSTONE_DUST, 1, (byte)0, (byte)0));
}
}
//Drop items
for(ItemStack x : is)
{
if(x != null)
loc.getWorld().dropItemNaturally(loc, x);
}
//Handle XP related tasks
PP.addXP(SkillType.EXCAVATION, xp);
Skills.XpCheckSkill(SkillType.EXCAVATION, player);
}
}

View File

@@ -0,0 +1,390 @@
package com.gmail.nossr50.skills;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
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;
import com.gmail.nossr50.locale.mcLocale;
public class Herbalism
{
public static void greenTerraCheck(Player player, Block block)
{
PlayerProfile PP = Users.getProfile(player);
if(m.isHoe(player.getItemInHand()))
{
if(block != null)
{
if(!m.abilityBlockCheck(block))
return;
}
if(PP.getHoePreparationMode())
{
PP.setHoePreparationMode(false);
}
int ticks = 2;
int x = PP.getSkillLevel(SkillType.HERBALISM);
while(x >= 50)
{
x-=50;
ticks++;
}
if(!PP.getGreenTerraMode() && Skills.cooldownOver(player, PP.getGreenTerraDeactivatedTimeStamp(), LoadProperties.greenTerraCooldown))
{
player.sendMessage(mcLocale.getString("Skills.GreenTerraOn"));
for(Player y : player.getWorld().getPlayers())
{
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
y.sendMessage(mcLocale.getString("Skills.GreenTerraPlayer", new Object[] {player.getName()}));
}
PP.setGreenTerraActivatedTimeStamp(System.currentTimeMillis());
PP.setGreenTerraDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
PP.setGreenTerraMode(true);
}
}
}
public static void greenTerraWheat(Player player, Block block, BlockBreakEvent event, mcMMO plugin)
{
if(block.getType() == Material.WHEAT && block.getData() == (byte) 0x07)
{
event.setCancelled(true);
PlayerProfile PP = Users.getProfile(player);
Material mat = Material.getMaterial(296);
Location loc = block.getLocation();
ItemStack is = new ItemStack(mat, 1, (byte)0, (byte)0);
PP.addXP(SkillType.HERBALISM, LoadProperties.mwheat);
loc.getWorld().dropItemNaturally(loc, is);
//DROP SOME SEEDS
mat = Material.SEEDS;
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
herbalismProcCheck(block, player, event, plugin);
herbalismProcCheck(block, player, event, plugin);
block.setData((byte) 0x03);
}
}
public static void greenTerra(Player player, Block block){
if(block.getType() == Material.COBBLESTONE || block.getType() == Material.DIRT){
if(!hasSeeds(player))
player.sendMessage("You need more seeds to spread Green Terra");
if(hasSeeds(player) && block.getType() != Material.WHEAT)
{
removeSeeds(player);
if(block.getType() == Material.DIRT)
block.setType(Material.GRASS);
if(LoadProperties.enableCobbleToMossy && block.getType() == Material.COBBLESTONE)
block.setType(Material.MOSSY_COBBLESTONE);
}
}
}
public static Boolean canBeGreenTerra(Block block){
int t = block.getTypeId();
if(t == 4 || t == 3 || t == 59 || t == 81 || t == 83 || t == 91 || t == 86 || t == 39 || t == 46 || t == 37 || t == 38){
return true;
} else {
return false;
}
}
public static boolean hasSeeds(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 295){
return true;
}
}
return false;
}
public static void removeSeeds(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 295){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
player.getInventory().setContents(inventory);
} else{
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
return;
}
}
}
public static void herbalismProcCheck(Block block, Player player, BlockBreakEvent event, mcMMO plugin)
{
PlayerProfile PP = Users.getProfile(player);
int type = block.getTypeId();
Location loc = block.getLocation();
ItemStack is = null;
Material mat = null;
if(plugin.misc.blockWatchList.contains(block))
{
return;
}
if(type == 59 && block.getData() == (byte) 0x7)
{
mat = Material.getMaterial(296);
is = new ItemStack(mat, 1, (byte)0, (byte)0);
PP.addXP(SkillType.HERBALISM, LoadProperties.mwheat);
if(player != null)
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
{
loc.getWorld().dropItemNaturally(loc, is);
}
}
//GREEN THUMB
if(Math.random() * 1500 <= PP.getSkillLevel(SkillType.HERBALISM))
{
event.setCancelled(true);
loc.getWorld().dropItemNaturally(loc, is);
//DROP SOME SEEDS
mat = Material.SEEDS;
is = new ItemStack(mat, 1, (byte)0, (byte)0);
loc.getWorld().dropItemNaturally(loc, is);
block.setData((byte) 0x1); //Change it to first stage
//Setup the bonuses
int bonus = 0;
if(PP.getSkillLevel(SkillType.HERBALISM) >= 200)
bonus++;
if(PP.getSkillLevel(SkillType.HERBALISM) >= 400)
bonus++;
if(PP.getSkillLevel(SkillType.HERBALISM) >= 600)
bonus++;
//Change wheat to be whatever stage based on the bonus
if(bonus == 1)
block.setData((byte) 0x2);
if(bonus == 2)
block.setData((byte) 0x3);
if(bonus == 3)
block.setData((byte) 0x4);
}
}
/*
* We need to check not-wheat stuff for if it was placed by the player or not
*/
if(block.getData() != (byte) 5)
{
//Cactus
if(type == 81){
//Setup the loop
World world = block.getWorld();
Block[] blockArray = new Block[3];
blockArray[0] = block;
blockArray[1] = world.getBlockAt(block.getX(), block.getY()+1, block.getZ());
blockArray[2] = world.getBlockAt(block.getX(), block.getY()+2, block.getZ());
Material[] materialArray = new Material[3];
materialArray[0] = blockArray[0].getType();
materialArray[1] = blockArray[1].getType();
materialArray[2] = blockArray[2].getType();
byte[] byteArray = new byte[3];
byteArray[0] = blockArray[0].getData();
byteArray[1] = blockArray[0].getData();
byteArray[2] = blockArray[0].getData();
int x = 0;
for(Block target : blockArray)
{
if(materialArray[x] == Material.CACTUS)
{
is = new ItemStack(Material.CACTUS, 1, (byte)0, (byte)0);
if(byteArray[x] != (byte) 5)
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
{
loc.getWorld().dropItemNaturally(target.getLocation(), is);
}
PP.addXP(SkillType.HERBALISM, LoadProperties.mcactus);
}
}
x++;
}
}
//Sugar Canes
if(type == 83)
{
//Setup the loop
World world = block.getWorld();
Block[] blockArray = new Block[3];
blockArray[0] = block;
blockArray[1] = world.getBlockAt(block.getX(), block.getY()+1, block.getZ());
blockArray[2] = world.getBlockAt(block.getX(), block.getY()+2, block.getZ());
Material[] materialArray = new Material[3];
materialArray[0] = blockArray[0].getType();
materialArray[1] = blockArray[1].getType();
materialArray[2] = blockArray[2].getType();
byte[] byteArray = new byte[3];
byteArray[0] = blockArray[0].getData();
byteArray[1] = blockArray[0].getData();
byteArray[2] = blockArray[0].getData();
int x = 0;
for(Block target : blockArray)
{
if(materialArray[x] == Material.SUGAR_CANE_BLOCK)
{
is = new ItemStack(Material.SUGAR_CANE, 1, (byte)0, (byte)0);
//Check for being placed by the player
if(byteArray[x] != (byte) 5)
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
{
loc.getWorld().dropItemNaturally(target.getLocation(), is);
}
PP.addXP(SkillType.HERBALISM, LoadProperties.msugar);
}
}
x++;
}
}
//Pumpkins
if((type == 91 || type == 86))
{
mat = Material.getMaterial(block.getTypeId());
is = new ItemStack(mat, 1, (byte)0, (byte)0);
if(player != null)
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
{
loc.getWorld().dropItemNaturally(loc, is);
}
}
PP.addXP(SkillType.HERBALISM, LoadProperties.mpumpkin);
}
//Mushroom
if(type == 39 || type == 40)
{
mat = Material.getMaterial(block.getTypeId());
is = new ItemStack(mat, 1, (byte)0, (byte)0);
if(player != null)
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM))
{
loc.getWorld().dropItemNaturally(loc, is);
}
}
PP.addXP(SkillType.HERBALISM, LoadProperties.mmushroom);
}
//Flower
if(type == 37 || type == 38){
mat = Material.getMaterial(block.getTypeId());
is = new ItemStack(mat, 1, (byte)0, (byte)0);
if(player != null){
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.HERBALISM)){
loc.getWorld().dropItemNaturally(loc, is);
}
}
PP.addXP(SkillType.HERBALISM, LoadProperties.mflower);
}
}
Skills.XpCheckSkill(SkillType.HERBALISM, player);
}
public static void breadCheck(Player player, ItemStack is)
{
PlayerProfile PP = Users.getProfile(player);
int herbalism = PP.getSkillLevel(SkillType.HERBALISM);
int heal = 0;
if(is.getTypeId() == 297)
{
if(herbalism >= 50 && herbalism < 150)
{
heal = 1;
} else if (herbalism >= 150 && herbalism < 250)
{
heal = 2;
} else if (herbalism >= 250 && herbalism < 350)
{
heal = 3;
} else if (herbalism >= 350 && herbalism < 450)
{
heal = 4;
} else if (herbalism >= 450 && herbalism < 550)
{
heal = 5;
} else if (herbalism >= 550 && herbalism < 650)
{
heal = 6;
} else if (herbalism >= 650 && herbalism < 750)
{
heal = 7;
} else if (herbalism >= 750)
{
heal = 8;
}
if(player.getHealth()+heal > 20)
{
player.setHealth(20);
}
else
player.setHealth(player.getHealth()+heal);
}
}
public static void stewCheck(Player player, ItemStack is)
{
PlayerProfile PP = Users.getProfile(player);
int herbalism = PP.getSkillLevel(SkillType.HERBALISM);
int heal = 0;
if(is.getTypeId() == 282)
{
if(herbalism >= 50 && herbalism < 150)
{
heal = 1;
} else if (herbalism >= 150 && herbalism < 250)
{
heal = 2;
} else if (herbalism >= 250 && herbalism < 350)
{
heal = 3;
} else if (herbalism >= 350 && herbalism < 450)
{
heal = 4;
} else if (herbalism >= 450 && herbalism < 550)
{
heal = 5;
} else if (herbalism >= 550 && herbalism < 650)
{
heal = 6;
} else if (herbalism >= 650 && herbalism < 750)
{
heal = 7;
} else if (herbalism >= 750)
{
heal = 8;
}
if(player.getHealth()+heal > 20)
{
player.setHealth(20);
}
else
player.setHealth(player.getHealth()+heal);
}
}
}

View File

@@ -0,0 +1,415 @@
package com.gmail.nossr50.skills;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.sound.SoundEffect;
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.spout.SpoutStuff;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
public class Mining
{
public static void superBreakerCheck(Player player, Block block)
{
PlayerProfile PP = Users.getProfile(player);
if(m.isMiningPick(player.getItemInHand()))
{
if(block != null)
{
if(!m.abilityBlockCheck(block))
return;
}
if(PP.getPickaxePreparationMode())
{
PP.setPickaxePreparationMode(false);
}
int ticks = 2;
int x = PP.getSkillLevel(SkillType.MINING);
while(x >= 50)
{
x-=50;
ticks++;
}
if(!PP.getSuperBreakerMode() && Skills.cooldownOver(player, PP.getSuperBreakerDeactivatedTimeStamp(), LoadProperties.superBreakerCooldown)){
player.sendMessage(mcLocale.getString("Skills.SuperBreakerOn"));
for(Player y : player.getWorld().getPlayers())
{
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
y.sendMessage(mcLocale.getString("Skills.SuperBreakerPlayer", new Object[] {player.getName()}));
}
PP.setSuperBreakerActivatedTimeStamp(System.currentTimeMillis());
PP.setSuperBreakerDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
PP.setSuperBreakerMode(true);
}
}
}
public static void blockProcSimulate(Block block)
{
Location loc = block.getLocation();
Material mat = Material.getMaterial(block.getTypeId());
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
if(block.getTypeId() != 89 && block.getTypeId() != 73 && block.getTypeId() != 74 && block.getTypeId() != 56
&& block.getTypeId() != 21 && block.getTypeId() != 1 && block.getTypeId() != 16)
loc.getWorld().dropItemNaturally(loc, item);
if(block.getTypeId() == 89)
{
mat = Material.getMaterial(348);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 73 || block.getTypeId() == 74)
{
mat = Material.getMaterial(331);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
if(Math.random() * 10 > 5){
loc.getWorld().dropItemNaturally(loc, item);
}
}
if(block.getTypeId() == 21)
{
mat = Material.getMaterial(351);
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 56)
{
mat = Material.getMaterial(264);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 1)
{
mat = Material.getMaterial(4);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 16)
{
mat = Material.getMaterial(263);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
}
}
public static void blockProcCheck(Block block, Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.MINING))
{
blockProcSimulate(block);
return;
}
}
public static void miningBlockCheck(Boolean smelt, 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;
if(block.getTypeId() == 1 || block.getTypeId() == 24)
{
xp += LoadProperties.mstone;
if(smelt = false)
blockProcCheck(block, player);
else
blockProcCheck(block, player);
}
//OBSIDIAN
if(block.getTypeId() == 49)
{
xp += LoadProperties.mobsidian;
if(smelt = false)
blockProcCheck(block, player);
else
blockProcCheck(block, player);
}
//NETHERRACK
if(block.getTypeId() == 87)
{
xp += LoadProperties.mnetherrack;
if(smelt = false)
blockProcCheck(block, player);
else
blockProcCheck(block, player);
}
//GLOWSTONE
if(block.getTypeId() == 89)
{
xp += LoadProperties.mglowstone;
if(smelt = false)
blockProcCheck(block, player);
else
blockProcCheck(block, player);
}
//COAL
if(block.getTypeId() == 16)
{
xp += LoadProperties.mcoal;
if(smelt = false)
blockProcCheck(block, player);
else
blockProcCheck(block, player);
}
//GOLD
if(block.getTypeId() == 14)
{
xp += LoadProperties.mgold;
if(smelt = false)
blockProcCheck(block, player);
else
blockProcCheck(block, player);
}
//DIAMOND
if(block.getTypeId() == 56){
xp += LoadProperties.mdiamond;
if(smelt = false)
blockProcCheck(block, player);
else
blockProcCheck(block, player);
}
//IRON
if(block.getTypeId() == 15)
{
xp += LoadProperties.miron;
if(smelt = false)
blockProcCheck(block, player);
else
blockProcCheck(block, player);
}
//REDSTONE
if(block.getTypeId() == 73 || block.getTypeId() == 74)
{
xp += LoadProperties.mredstone;
if(smelt = false)
blockProcCheck(block, player);
else
blockProcCheck(block, player);
}
//LAPUS
if(block.getTypeId() == 21)
{
xp += LoadProperties.mlapis;
if(smelt = false)
blockProcCheck(block, player);
else
blockProcCheck(block, player);
}
PP.addXP(SkillType.MINING, xp);
Skills.XpCheckSkill(SkillType.MINING, player);
}
/*
* Handling SuperBreaker stuff
*/
public static Boolean canBeSuperBroken(Block block)
{
int t = block.getTypeId();
if(t == 49 || t == 87 || t == 89 || t == 73 || t == 74 || t == 56 || t == 21 || t == 1 || t == 16 || t == 14 || t == 15)
{
return true;
} else {
return false;
}
}
public static void SuperBreakerBlockCheck(Player player, Block block, mcMMO plugin)
{
PlayerProfile PP = Users.getProfile(player);
if(LoadProperties.toolsLoseDurabilityFromAbilities)
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
Location loc = block.getLocation();
Material mat = Material.getMaterial(block.getTypeId());
int xp = 0;
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
if(block.getTypeId() == 1 || block.getTypeId() == 24)
{
if(block.getTypeId() == 1)
{
mat = Material.COBBLESTONE;
if(!plugin.misc.blockWatchList.contains(block) && block.getData() != (byte) 5)
{
xp += LoadProperties.mstone;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
} else
{
mat = Material.SANDSTONE;
if(!plugin.misc.blockWatchList.contains(block) && block.getData() != (byte) 5)
{
xp += LoadProperties.msandstone;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
}
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//NETHERRACK
if(block.getTypeId() == 87)
{
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mnetherrack;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
mat = Material.getMaterial(87);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//GLOWSTONE
if(block.getTypeId() == 89)
{
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mglowstone;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
mat = Material.getMaterial(348);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//COAL
if(block.getTypeId() == 16)
{
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mcoal;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
mat = Material.getMaterial(263);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//GOLD
if(block.getTypeId() == 14 && m.getTier(player) >= 3)
{
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mgold;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//OBSIDIAN
if(block.getTypeId() == 49 && m.getTier(player) >= 4)
{
if(LoadProperties.toolsLoseDurabilityFromAbilities)
m.damageTool(player, (short) LoadProperties.abilityDurabilityLoss);
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mobsidian;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
mat = Material.getMaterial(49);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//DIAMOND
if(block.getTypeId() == 56 && m.getTier(player) >= 3)
{
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mdiamond;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
mat = Material.getMaterial(264);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//IRON
if(block.getTypeId() == 15 && m.getTier(player) >= 2)
{
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.miron;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//REDSTONE
if((block.getTypeId() == 73 || block.getTypeId() == 74) && m.getTier(player) >= 4)
{
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5)
{
xp += LoadProperties.mredstone;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
mat = Material.getMaterial(331);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
if(Math.random() * 10 > 5)
{
loc.getWorld().dropItemNaturally(loc, item);
}
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
//LAPUS
if(block.getTypeId() == 21 && m.getTier(player) >= 3){
if(!plugin.misc.blockWatchList.contains(block)&& block.getData() != (byte) 5){
xp += LoadProperties.mlapis;
blockProcCheck(block, player);
blockProcCheck(block, player);
}
mat = Material.getMaterial(351);
item = new ItemStack(mat, 1, (byte)0,(byte)0x4);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
loc.getWorld().dropItemNaturally(loc, item);
player.incrementStatistic(Statistic.MINE_BLOCK, block.getType());
block.setType(Material.AIR);
}
if(block.getData() != (byte) 5)
PP.addXP(SkillType.MINING, xp);
if(LoadProperties.spoutEnabled)
SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
Skills.XpCheckSkill(SkillType.MINING, player);
}
}

View File

@@ -0,0 +1,480 @@
package com.gmail.nossr50.skills;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
public class Repair {
/*
* Repair requirements for each material
*/
private static int rGold = LoadProperties.rGold;
private static String nGold = LoadProperties.nGold;
private static int rStone = LoadProperties.rStone;
private static String nStone = LoadProperties.nStone;
private static int rWood = LoadProperties.rWood;
private static String nWood = LoadProperties.nWood;
private static int rDiamond = LoadProperties.rDiamond;
private static String nDiamond = LoadProperties.nDiamond;
private static int rIron = LoadProperties.rIron;
private static String nIron = LoadProperties.nIron;
@SuppressWarnings("deprecation")
public static void repairCheck(Player player, ItemStack is, Block block){
PlayerProfile PP = Users.getProfile(player);
short durabilityBefore = player.getItemInHand().getDurability();
short durabilityAfter = 0;
short dif = 0;
if(block != null && mcPermissions.getInstance().repair(player)){
if(player.getItemInHand().getDurability() > 0 && player.getItemInHand().getAmount() < 2){
/*
* ARMOR
*/
if(isArmor(is)){
/*
* DIAMOND ARMOR
*/
if(isDiamondArmor(is) && hasItem(player, rDiamond) && PP.getSkillLevel(SkillType.REPAIR) >= LoadProperties.repairdiamondlevel){
removeItem(player, rDiamond);
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 6); //Boost XP
PP.addXP(SkillType.REPAIR, dif*10);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
}
else if (isIronArmor(is) && hasItem(player, rIron)){
/*
* IRON ARMOR
*/
removeItem(player, rIron);
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 2); //Boost XP
PP.addXP(SkillType.REPAIR, dif*10);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
//GOLD ARMOR
} else if (isGoldArmor(is) && hasItem(player, rGold)){
removeItem(player, rGold);
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 4); //Boost XP of Gold to around Iron
PP.addXP(SkillType.REPAIR, dif*10);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
} else {
needMoreVespeneGas(is, player);
}
}
/*
* TOOLS
*/
if(isTools(is)){
if(isStoneTools(is) && hasItem(player, rStone)){
removeItem(player, rStone);
/*
* Repair Durability and calculate dif
*/
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
//STONE NERF
dif = (short) (dif / 2);
PP.addXP(SkillType.REPAIR, dif*10);
} else if(isWoodTools(is) && hasItem(player,rWood)){
removeItem(player,rWood);
/*
* Repair Durability and calculate dif
*/
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
//WOOD NERF
dif = (short) (dif / 2);
PP.addXP(SkillType.REPAIR, dif*10);
} else if(isIronTools(is) && hasItem(player, rIron)){
removeItem(player, rIron);
/*
* Repair Durability and calculate dif
*/
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
PP.addXP(SkillType.REPAIR, dif*10);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
} else if (isDiamondTools(is) && hasItem(player, rDiamond) && PP.getSkillLevel(SkillType.REPAIR) >= LoadProperties.repairdiamondlevel){ //Check if its diamond and the player has diamonds
/*
* DIAMOND TOOLS
*/
player.getItemInHand().setDurability(getRepairAmount(is, player));
removeItem(player, rDiamond);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
PP.addXP(SkillType.REPAIR, dif*10);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
} else if(isGoldTools(is) && hasItem(player, rGold)){
player.getItemInHand().setDurability(getRepairAmount(is, player));
removeItem(player, rGold);
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 7.6); //Boost XP for Gold to that of around Iron
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
PP.addXP(SkillType.REPAIR, dif*10);
//CLANG CLANG
if(LoadProperties.spoutEnabled)
SpoutStuff.playRepairNoise(player);
} else {
needMoreVespeneGas(is, player);
}
}
} else {
player.sendMessage(mcLocale.getString("Skills.FullDurability"));
}
player.updateInventory();
/*
* GIVE SKILL IF THERE IS ENOUGH XP
*/
Skills.XpCheckSkill(SkillType.REPAIR, player);
}
}
public static boolean isArmor(ItemStack is){
return is.getTypeId() == 306 || is.getTypeId() == 307 ||is.getTypeId() == 308 ||is.getTypeId() == 309 ||
is.getTypeId() == 310 ||is.getTypeId() == 311 ||is.getTypeId() == 312 ||is.getTypeId() == 313 ||
is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317;
}
public static boolean isGoldArmor(ItemStack is){
return is.getTypeId() == 314 || is.getTypeId() == 315 || is.getTypeId() == 316 || is.getTypeId() == 317;
}
public static boolean isIronArmor(ItemStack is){
return is.getTypeId() == 306 || is.getTypeId() == 307 || is.getTypeId() == 308 || is.getTypeId() == 309;
}
public static boolean isDiamondArmor(ItemStack is){
return is.getTypeId() == 310 || is.getTypeId() == 311 || is.getTypeId() == 312 || is.getTypeId() == 313;
}
public static boolean isTools(ItemStack is)
{
return is.getTypeId() == 359 || is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292 || //IRON
is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293 || //DIAMOND
is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || //GOLD
is.getTypeId() == 268 || is.getTypeId() == 269 || is.getTypeId() == 270 || is.getTypeId() == 271 || is.getTypeId() == 290 ||//WOOD
is.getTypeId() == 272 || is.getTypeId() == 273 || is.getTypeId() == 274 || is.getTypeId() == 275|| is.getTypeId() == 291; //STONE
}
public static boolean isStoneTools(ItemStack is){
return is.getTypeId() == 272 || is.getTypeId() == 273 || is.getTypeId() == 274 || is.getTypeId() == 275 || is.getTypeId() == 291;
}
public static boolean isWoodTools(ItemStack is){
return is.getTypeId() == 268 || is.getTypeId() == 269 || is.getTypeId() == 270 || is.getTypeId() == 271 || is.getTypeId() == 290;
}
public static boolean isGoldTools(ItemStack is){
return is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || is.getTypeId() == 294;
}
public static boolean isIronTools(ItemStack is){
return is.getTypeId() == 359 || is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292;
}
public static boolean isDiamondTools(ItemStack is){
if(is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293)
{
return true;
} else {
return false;
}
}
public static void removeItem(Player player, int typeid)
{
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == typeid){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
player.getInventory().setContents(inventory);
} else{
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
return;
}
}
}
public static boolean hasItem(Player player, int typeid){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == typeid){
return true;
}
}
return false;
}
public static short repairCalculate(Player player, short durability, short ramt){
PlayerProfile PP = Users.getProfile(player);
float bonus = (PP.getSkillLevel(SkillType.REPAIR) / 500);
bonus = (ramt * bonus);
ramt = ramt+=bonus;
if(checkPlayerProcRepair(player)){
ramt = (short) (ramt * 2);
}
//player.sendMessage(ChatColor.DARK_RED + "test " +ChatColor.BLUE+ );
durability-=ramt;
// player.sendMessage(ChatColor.DARK_RED + "durability " +ChatColor.BLUE+ durability);
if(durability < 0){
durability = 0;
}
return durability;
}
public static short getRepairAmount(ItemStack is, Player player){
short durability = is.getDurability();
short ramt = 0;
switch(is.getTypeId())
{
/*
* TOOLS
*/
//SHEARS
case 359:
ramt = 119;
break;
//WOOD SWORD
case 268:
ramt = 30;
break;
//WOOD SHOVEL
case 269:
ramt = 60;
break;
//WOOD PICKAXE
case 270:
ramt = 20;
break;
//WOOD AXE
case 271:
ramt = 20;
break;
//WOOD HOE
case 290:
ramt = 30;
break;
//STONE SWORD
case 272:
ramt = 66;
break;
//STONE SHOVEL
case 273:
ramt = 132;
break;
//STONE PICKAXE
case 274:
ramt = 44;
break;
//STONE AXE
case 275:
ramt = 44;
break;
//STONE HOE
case 291:
ramt = 66;
break;
//GOLD SHOVEL
case 284:
ramt = 33;
break;
//IRON SHOVEL
case 256:
ramt = 251;
break;
//DIAMOND SHOVEL
case 277:
ramt = 1562;
break;
//IRON PICK
case 257:
ramt = 84;
break;
//IRON AXE
case 258:
ramt = 84;
break;
//IRON SWORD
case 267:
ramt = 126;
break;
//IRON HOE
case 292:
ramt = 126;
break;
//DIAMOND SWORD
case 276:
ramt = 781;
break;
//DIAMOND PICK
case 278:
ramt = 521;
break;
//DIAMOND AXE
case 279:
ramt = 521;
break;
//DIAMOND HOE
case 293:
ramt = 781;
break;
//GOLD SWORD
case 283:
ramt = 17;
break;
//GOLD PICK
case 285:
ramt = 11;
break;
//GOLD AXE
case 286:
ramt = 11;
break;
//GOLD HOE
case 294:
ramt = 17;
break;
/*
* ARMOR
*/
case 306:
ramt = 27;
break;
case 310:
ramt = 55;
break;
case 307:
ramt = 24;
break;
case 311:
ramt = 48;
break;
case 308:
ramt = 27;
break;
case 312:
ramt = 53;
break;
case 309:
ramt = 40;
break;
case 313:
ramt = 80;
break;
case 314:
ramt = 13;
break;
case 315:
ramt = 12;
break;
case 316:
ramt = 14;
break;
case 317:
ramt = 20;
break;
}
return repairCalculate(player, durability, ramt);
}
public static void needMoreVespeneGas(ItemStack is, Player player)
{
PlayerProfile PP = Users.getProfile(player);
if ((isDiamondTools(is) || isDiamondArmor(is)) && PP.getSkillLevel(SkillType.REPAIR) < LoadProperties.repairdiamondlevel)
{
player.sendMessage(mcLocale.getString("Skills.AdeptDiamond"));
} else if (isDiamondTools(is) && !hasItem(player, rDiamond) || isIronTools(is) && !hasItem(player, rIron) || isGoldTools(is) && !hasItem(player, rGold)){
if(isDiamondTools(is) && !hasItem(player, rDiamond))
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.BLUE+ nDiamond);
if(isIronTools(is) && !hasItem(player, rIron))
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.GRAY+ nIron);
if(isGoldTools(is) && !hasItem(player, rGold))
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.GOLD+nGold);
if(isWoodTools(is) && !hasItem(player,rWood))
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.DARK_GREEN+ nWood);
if(isStoneTools(is) && !hasItem(player, rStone))
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.GRAY+nStone);
} else if (isDiamondArmor(is) && !hasItem(player, rDiamond)){
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.BLUE+ nDiamond);
} else if (isIronArmor(is) && !hasItem(player, rIron)){
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.GRAY+ nIron);
} else if (isGoldArmor(is) && !hasItem(player, rGold)){
player.sendMessage(mcLocale.getString("Skills.NeedMore")+" "+ChatColor.GOLD+ nGold);
} else if (is.getAmount() > 1)
player.sendMessage(mcLocale.getString("Skills.StackedItems"));
}
public static boolean checkPlayerProcRepair(Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(player != null)
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.REPAIR))
{
player.sendMessage(mcLocale.getString("Skills.FeltEasy"));
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,409 @@
package com.gmail.nossr50.skills;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.Leaderboard;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.PlayerStat;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
public class Skills
{
protected static final Logger log = Logger.getLogger("Minecraft");
public void updateSQLfromFile(Player player){
}
public static boolean cooldownOver(Player player, long oldTime, int cooldown){
long currentTime = System.currentTimeMillis();
if(currentTime - oldTime >= (cooldown * 1000)){
return true;
} else {
return false;
}
}
public boolean hasArrows(Player player){
for(ItemStack x : player.getInventory().getContents()){
if (x.getTypeId() == 262){
return true;
}
}
return false;
}
public void addArrows(Player player){
for(ItemStack x : player.getInventory().getContents()){
if (x.getTypeId() == 262){
x.setAmount(x.getAmount() + 1);
return;
}
}
}
public static int calculateTimeLeft(Player player, long deactivatedTimeStamp, int cooldown)
{
return (int) (((deactivatedTimeStamp + (cooldown * 1000)) - System.currentTimeMillis())/1000);
}
public static void watchCooldowns(Player player){
PlayerProfile PP = Users.getProfile(player);
if(!PP.getGreenTerraInformed() && System.currentTimeMillis() - (PP.getGreenTerraDeactivatedTimeStamp()*1000) >= (LoadProperties.greenTerraCooldown * 1000)){
PP.setGreenTerraInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourGreenTerra"));
}
if(!PP.getTreeFellerInformed() && System.currentTimeMillis() - (PP.getTreeFellerDeactivatedTimeStamp()*1000) >= (LoadProperties.greenTerraCooldown * 1000)){
PP.setTreeFellerInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourTreeFeller"));
}
if(!PP.getSuperBreakerInformed() && System.currentTimeMillis() - (PP.getSuperBreakerDeactivatedTimeStamp()*1000) >= (LoadProperties.superBreakerCooldown * 1000)){
PP.setSuperBreakerInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourSuperBreaker"));
}
if(!PP.getSerratedStrikesInformed() && System.currentTimeMillis() - (PP.getSerratedStrikesDeactivatedTimeStamp()*1000) >= (LoadProperties.serratedStrikeCooldown * 1000)){
PP.setSerratedStrikesInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourSerratedStrikes"));
}
if(!PP.getBerserkInformed() && System.currentTimeMillis() - (PP.getBerserkDeactivatedTimeStamp()*1000) >= (LoadProperties.berserkCooldown * 1000)){
PP.setBerserkInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourBerserk"));
}
if(!PP.getSkullSplitterInformed() && System.currentTimeMillis() - (PP.getSkullSplitterDeactivatedTimeStamp()*1000) >= (LoadProperties.skullSplitterCooldown * 1000)){
PP.setSkullSplitterInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourSkullSplitter"));
}
if(!PP.getGigaDrillBreakerInformed() && System.currentTimeMillis() - (PP.getGigaDrillBreakerDeactivatedTimeStamp()*1000) >= (LoadProperties.gigaDrillBreakerCooldown * 1000)){
PP.setGigaDrillBreakerInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourGigaDrillBreaker"));
}
}
public static void hoeReadinessCheck(Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(mcPermissions.getInstance().herbalismAbility(player) && m.isHoe(player.getItemInHand()) && !PP.getHoePreparationMode()){
if(!PP.getGreenTerraMode() && !cooldownOver(player, (PP.getGreenTerraDeactivatedTimeStamp()*1000), LoadProperties.greenTerraCooldown)){
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getGreenTerraDeactivatedTimeStamp()*1000), LoadProperties.greenTerraCooldown)+"s)");
return;
}
player.sendMessage(mcLocale.getString("Skills.ReadyHoe"));
PP.setHoePreparationATS(System.currentTimeMillis());
PP.setHoePreparationMode(true);
}
}
public static void monitorSkills(Player player){
PlayerProfile PP = Users.getProfile(player);
if(PP != null)
{
if(PP.getHoePreparationMode() && System.currentTimeMillis() - (PP.getHoePreparationATS()*1000) >= 4000){
PP.setHoePreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerHoe"));
}
if(PP.getAxePreparationMode() && System.currentTimeMillis() - (PP.getAxePreparationATS()*1000) >= 4000){
PP.setAxePreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerAxe"));
}
if(PP.getPickaxePreparationMode() && System.currentTimeMillis() - (PP.getPickaxePreparationATS()*1000) >= 4000){
PP.setPickaxePreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerPickAxe"));
}
if(PP.getSwordsPreparationMode() && System.currentTimeMillis() - (PP.getSwordsPreparationATS()*1000) >= 4000){
PP.setSwordsPreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerSword"));
}
if(PP.getFistsPreparationMode() && System.currentTimeMillis() - (PP.getFistsPreparationATS()*1000) >= 4000){
PP.setFistsPreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerFists"));
}
if(PP.getShovelPreparationMode() && System.currentTimeMillis() - (PP.getShovelPreparationATS()*1000) >= 4000){
PP.setShovelPreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerShovel"));
}
/*
* HERBALISM ABILITY
*/
if(mcPermissions.getInstance().herbalismAbility(player)){
if(PP.getGreenTerraMode() && (PP.getGreenTerraDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setGreenTerraMode(false);
PP.setGreenTerraInformed(false);
player.sendMessage(mcLocale.getString("Skills.GreenTerraOff"));
}
}
/*
* AXES ABILITY
*/
if(mcPermissions.getInstance().axesAbility(player)){
if(PP.getSkullSplitterMode() && (PP.getSkullSplitterDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setSkullSplitterMode(false);
PP.setSkullSplitterInformed(false);
player.sendMessage(mcLocale.getString("Skills.SkullSplitterOff"));
}
}
/*
* WOODCUTTING ABILITY
*/
if(mcPermissions.getInstance().woodCuttingAbility(player)){
if(PP.getTreeFellerMode() && (PP.getTreeFellerDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setTreeFellerMode(false);
PP.setTreeFellerInformed(false);
player.sendMessage(mcLocale.getString("Skills.TreeFellerOff"));
}
}
/*
* MINING ABILITY
*/
if(mcPermissions.getInstance().miningAbility(player)){
if(PP.getSuperBreakerMode() && (PP.getSuperBreakerDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setSuperBreakerMode(false);
PP.setSuperBreakerInformed(false);
player.sendMessage(mcLocale.getString("Skills.SuperBreakerOff"));
}
}
/*
* EXCAVATION ABILITY
*/
if(mcPermissions.getInstance().excavationAbility(player)){
if(PP.getGigaDrillBreakerMode() && (PP.getGigaDrillBreakerDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setGigaDrillBreakerMode(false);
PP.setGigaDrillBreakerInformed(false);
player.sendMessage(mcLocale.getString("Skills.GigaDrillBreakerOff"));
}
}
/*
* SWORDS ABILITY
*/
if(mcPermissions.getInstance().swordsAbility(player)){
if(PP.getSerratedStrikesMode() && (PP.getSerratedStrikesDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setSerratedStrikesMode(false);
PP.setSerratedStrikesInformed(false);
player.sendMessage(mcLocale.getString("Skills.SerratedStrikesOff"));
}
}
/*
* UNARMED ABILITY
*/
if(mcPermissions.getInstance().unarmedAbility(player)){
if(PP.getBerserkMode() && (PP.getBerserkDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
PP.setBerserkMode(false);
PP.setBerserkInformed(false);
player.sendMessage(mcLocale.getString("Skills.BerserkOff"));
}
}
}
}
public static void abilityActivationCheck(Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(PP != null)
{
if(!PP.getAbilityUse())
return;
if(mcPermissions.getInstance().miningAbility(player) && m.isMiningPick(player.getItemInHand()) && !PP.getPickaxePreparationMode())
{
if(!PP.getSuperBreakerMode() && !cooldownOver(player, (PP.getSuperBreakerDeactivatedTimeStamp()*1000), LoadProperties.superBreakerCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getSuperBreakerDeactivatedTimeStamp()*1000), LoadProperties.superBreakerCooldown)+"s)");
return;
}
player.sendMessage(mcLocale.getString("Skills.ReadyPickAxe"));
PP.setPickaxePreparationATS(System.currentTimeMillis());
PP.setPickaxePreparationMode(true);
}
if(mcPermissions.getInstance().excavationAbility(player) && m.isShovel(player.getItemInHand()) && !PP.getShovelPreparationMode())
{
if(!PP.getGigaDrillBreakerMode() && !cooldownOver(player, (PP.getGigaDrillBreakerDeactivatedTimeStamp()*1000), LoadProperties.gigaDrillBreakerCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getGigaDrillBreakerDeactivatedTimeStamp()*1000), LoadProperties.gigaDrillBreakerCooldown)+"s)");
return;
}
player.sendMessage(mcLocale.getString("Skills.ReadyShovel"));
PP.setShovelPreparationATS(System.currentTimeMillis());
PP.setShovelPreparationMode(true);
}
if(mcPermissions.getInstance().swordsAbility(player) && m.isSwords(player.getItemInHand()) && !PP.getSwordsPreparationMode())
{
if(!PP.getSerratedStrikesMode() && !cooldownOver(player, (PP.getSerratedStrikesDeactivatedTimeStamp()*1000), LoadProperties.serratedStrikeCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getSerratedStrikesDeactivatedTimeStamp()*1000), LoadProperties.serratedStrikeCooldown)+"s)");
return;
}
player.sendMessage(mcLocale.getString("Skills.ReadySword"));
PP.setSwordsPreparationATS(System.currentTimeMillis());
PP.setSwordsPreparationMode(true);
}
if(mcPermissions.getInstance().unarmedAbility(player) && player.getItemInHand().getTypeId() == 0 && !PP.getFistsPreparationMode())
{
if(!PP.getBerserkMode() && !cooldownOver(player, (PP.getBerserkDeactivatedTimeStamp()*1000), LoadProperties.berserkCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getBerserkDeactivatedTimeStamp()*1000), LoadProperties.berserkCooldown)+"s)");
return;
}
player.sendMessage(mcLocale.getString("Skills.ReadyFists"));
PP.setFistsPreparationATS(System.currentTimeMillis());
PP.setFistsPreparationMode(true);
}
if((mcPermissions.getInstance().axes(player) || mcPermissions.getInstance().woodcutting(player)) && !PP.getAxePreparationMode())
{
if(m.isAxes(player.getItemInHand()))
{
player.sendMessage(mcLocale.getString("Skills.ReadyAxe"));
PP.setAxePreparationATS(System.currentTimeMillis());
PP.setAxePreparationMode(true);
}
}
}
}
public static void ProcessLeaderboardUpdate(SkillType skillType, Player player)
{
PlayerProfile PP = Users.getProfile(player);
PlayerStat ps = new PlayerStat();
if(skillType != SkillType.ALL)
ps.statVal = PP.getSkillLevel(skillType);
else
ps.statVal = m.getPowerLevel(player);
ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, skillType);
}
public static void XpCheckSkill(SkillType skillType, Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType))
{
int skillups = 0;
while(PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType))
{
skillups++;
PP.removeXP(skillType, PP.getXpToLevel(skillType));
PP.skillUp(skillType, 1);
}
if(!LoadProperties.useMySQL)
{
ProcessLeaderboardUpdate(skillType, player);
ProcessLeaderboardUpdate(SkillType.ALL, player);
}
String capitalized = m.getCapitalized(skillType.toString());
//Contrib stuff
if(LoadProperties.spoutEnabled && player instanceof SpoutPlayer)
{
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
if(sPlayer.isSpoutCraftEnabled())
{
SpoutStuff.levelUpNotification(skillType, sPlayer);
} else
{
player.sendMessage(mcLocale.getString("Skills."+capitalized+"Up", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)}));
}
}
else
player.sendMessage(mcLocale.getString("Skills."+capitalized+"Up", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)}));
}
if(LoadProperties.xpbar && LoadProperties.spoutEnabled)
{
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
if(sPlayer.isSpoutCraftEnabled())
{
SpoutStuff.updateXpBar(sPlayer);
}
}
}
public static void XpCheckAll(Player player)
{
for(SkillType x : SkillType.values())
{
//Don't want to do anything with this one
if(x == SkillType.ALL)
continue;
XpCheckSkill(x, player);
}
}
public static SkillType getSkillType(String skillName)
{
for(SkillType x : SkillType.values())
{
if(x.toString().equals(skillName.toUpperCase()))
return x;
}
return null;
}
public static boolean isSkill(String skillname){
skillname = skillname.toUpperCase();
for(SkillType x : SkillType.values())
{
if(x.toString().equals(skillname))
return true;
}
return false;
}
public static void arrowRetrievalCheck(Entity entity, mcMMO plugin)
{
if(plugin.misc.arrowTracker.containsKey(entity))
{
Integer x = 0;
while(x < plugin.misc.arrowTracker.get(entity))
{
m.mcDropItem(entity.getLocation(), 262);
x++;
}
}
plugin.misc.arrowTracker.remove(entity);
}
public static String getSkillStats(String skillname, Integer level, Integer XP, Integer XPToLevel)
{
ChatColor parColor = ChatColor.DARK_AQUA;
ChatColor xpColor = ChatColor.GRAY;
ChatColor LvlColor = ChatColor.GREEN;
ChatColor skillColor = ChatColor.YELLOW;
return skillColor+skillname+LvlColor+level+parColor+" XP"+"("+xpColor+XP+parColor+"/"+xpColor+XPToLevel+parColor+")";
}
public static boolean hasCombatSkills(Player player)
{
if(mcPermissions.getInstance().axes(player) || mcPermissions.getInstance().archery(player) || mcPermissions.getInstance().swords(player) || mcPermissions.getInstance().taming(player) || mcPermissions.getInstance().unarmed(player))
return true;
else
return false;
}
public static boolean hasGatheringSkills(Player player)
{
if(mcPermissions.getInstance().excavation(player) || mcPermissions.getInstance().herbalism(player) || mcPermissions.getInstance().mining(player) || mcPermissions.getInstance().woodcutting(player))
return true;
else
return false;
}
public static boolean hasMiscSkills(Player player)
{
if(mcPermissions.getInstance().acrobatics(player) || mcPermissions.getInstance().repair(player))
return true;
else
return false;
}
}

View File

@@ -0,0 +1,271 @@
package com.gmail.nossr50.skills;
import org.bukkit.ChatColor;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.gmail.nossr50.Combat;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
public class Swords
{
public static void serratedStrikesActivationCheck(Player player){
PlayerProfile PP = Users.getProfile(player);
if(m.isSwords(player.getItemInHand()))
{
if(PP.getSwordsPreparationMode())
{
PP.setSwordsPreparationMode(false);
}
int ticks = 2;
int x = PP.getSkillLevel(SkillType.SWORDS);
while(x >= 50)
{
x-=50;
ticks++;
}
if(!PP.getSerratedStrikesMode() && PP.getSerratedStrikesDeactivatedTimeStamp() < System.currentTimeMillis())
{
player.sendMessage(mcLocale.getString("Skills.SerratedStrikesOn"));
for(Player y : player.getWorld().getPlayers())
{
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
y.sendMessage(mcLocale.getString("Skills.SerratedStrikesPlayer", new Object[] {player.getName()}));
}
PP.setSerratedStrikesActivatedTimeStamp(System.currentTimeMillis());
PP.setSerratedStrikesDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
PP.setSerratedStrikesMode(true);
}
}
}
public static void bleedCheck(Player attacker, LivingEntity x, mcMMO pluginx)
{
PlayerProfile PPa = Users.getProfile(attacker);
if(x instanceof Wolf)
{
Wolf wolf = (Wolf)x;
if(Taming.getOwner(wolf, pluginx) != null)
{
if(Taming.getOwner(wolf, pluginx) == attacker)
return;
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(wolf, pluginx)))
return;
}
}
if(mcPermissions.getInstance().swords(attacker) && m.isSwords(attacker.getItemInHand())){
if(PPa.getSkillLevel(SkillType.SWORDS) >= 750)
{
if(Math.random() * 1000 >= 750)
{
if(!(x instanceof Player))
pluginx.misc.addToBleedQue(x);
if(x instanceof Player)
{
Player target = (Player)x;
Users.getProfile(target).addBleedTicks(3);
}
attacker.sendMessage(ChatColor.GREEN+"**ENEMY BLEEDING**");
}
}
else if (Math.random() * 1000 <= PPa.getSkillLevel(SkillType.SWORDS))
{
if(!(x instanceof Player))
pluginx.misc.addToBleedQue(x);
if(x instanceof Player)
{
Player target = (Player)x;
Users.getProfile(target).addBleedTicks(2);
}
attacker.sendMessage(ChatColor.GREEN+"**ENEMY BLEEDING**");
}
}
}
public static void applySerratedStrikes(Player attacker, EntityDamageByEntityEvent event, mcMMO pluginx)
{
int targets = 0;
if(event.getEntity() instanceof LivingEntity)
{
LivingEntity x = (LivingEntity) event.getEntity();
targets = m.getTier(attacker);
for(Entity derp : x.getWorld().getEntities())
{
if(m.getDistance(x.getLocation(), derp.getLocation()) < 5)
{
//Make sure the Wolf is not friendly
if(derp instanceof Wolf)
{
Wolf hurrDurr = (Wolf)derp;
if(Taming.getOwner(hurrDurr, pluginx) == attacker)
continue;
if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr, pluginx)))
continue;
}
//Damage nearby LivingEntities
if(derp instanceof LivingEntity && targets >= 1)
{
if(derp instanceof Player)
{
Player target = (Player)derp;
if(target.getName().equals(attacker.getName()))
continue;
if(Users.getProfile(target).getGodMode())
continue;
if(Party.getInstance().inSameParty(attacker, target))
continue;
if(targets >= 1 && derp.getWorld().getPVP())
{
target.damage(event.getDamage() / 4);
target.sendMessage(ChatColor.DARK_RED+"Struck by Serrated Strikes!");
Users.getProfile(target).addBleedTicks(5);
targets--;
continue;
}
}
else
{
if(!pluginx.misc.bleedTracker.contains(derp))
pluginx.misc.addToBleedQue((LivingEntity)derp);
LivingEntity target = (LivingEntity)derp;
target.damage(event.getDamage() / 4);
targets--;
}
}
}
}
}
}
public static void parryCheck(EntityDamageByEntityEvent event, Player defender)
{
Entity y = event.getDamager();
PlayerProfile PPd = Users.getProfile(defender);
if(defender != null && m.isSwords(defender.getItemInHand())
&& mcPermissions.getInstance().swords(defender)){
if(PPd.getSkillLevel(SkillType.SWORDS) >= 900)
{
if(Math.random() * 3000 <= 900)
{
event.setCancelled(true);
defender.sendMessage(ChatColor.GREEN+"**PARRIED**");
defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1));
if(y instanceof Player)
{
Player attacker = (Player)y;
attacker.sendMessage(ChatColor.GREEN+"**PARRIED**");
}
}
} else
{
if(Math.random() * 3000 <= PPd.getSkillLevel(SkillType.SWORDS))
{
event.setCancelled(true);
defender.sendMessage(ChatColor.YELLOW+"*CLANG* SUCCESSFUL PARRY *CLANG*");
defender.getItemInHand().setDurability((short) (defender.getItemInHand().getDurability() + 1));
if(y instanceof Player)
{
Player attacker = (Player)y;
attacker.sendMessage(ChatColor.DARK_RED+"**TARGET HAS PARRIED THAT ATTACK**");
}
}
}
}
}
public static void counterAttackChecks(EntityDamageByEntityEvent event)
{
//Don't want to counter attack arrows
if(event.getDamager() instanceof Arrow)
return;
if(event instanceof EntityDamageByEntityEvent)
{
Entity f = ((EntityDamageByEntityEvent) event).getDamager();
if(event.getEntity() instanceof Player)
{
Player defender = (Player)event.getEntity();
PlayerProfile PPd = Users.getProfile(defender);
if(m.isSwords(defender.getItemInHand()) && mcPermissions.getInstance().swords(defender))
{
if(PPd.getSkillLevel(SkillType.SWORDS) >= 600)
{
if(Math.random() * 2000 <= 600)
{
Combat.dealDamage(f, event.getDamage() / 2);
defender.sendMessage(ChatColor.GREEN+"**COUNTER-ATTACKED**");
if(f instanceof Player)
((Player) f).sendMessage(ChatColor.DARK_RED+"Hit with counterattack!");
}
}
else if (Math.random() * 2000 <= PPd.getSkillLevel(SkillType.SWORDS))
{
Combat.dealDamage(f, event.getDamage() / 2);
defender.sendMessage(ChatColor.GREEN+"**COUNTER-ATTACKED**");
if(f instanceof Player)
((Player) f).sendMessage(ChatColor.DARK_RED+"Hit with counterattack!");
}
}
}
}
}
public static void bleedSimulate(mcMMO plugin)
{
//Add items from Que list to BleedTrack list
for(LivingEntity x : plugin.misc.bleedQue)
{
plugin.misc.bleedTracker.add(x);
}
//Clear list
plugin.misc.bleedQue = new LivingEntity[plugin.misc.bleedQue.length];
plugin.misc.bleedQuePos = 0;
//Cleanup any dead entities from the list
for(LivingEntity x : plugin.misc.bleedRemovalQue)
{
plugin.misc.bleedTracker.remove(x);
}
//Clear bleed removal list
plugin.misc.bleedRemovalQue = new LivingEntity[plugin.misc.bleedRemovalQue.length];
plugin.misc.bleedRemovalQuePos = 0;
//Bleed monsters/animals
for(LivingEntity x : plugin.misc.bleedTracker)
{
if(x == null){continue;}
if(x.getHealth() <= 0)
{
plugin.misc.addToBleedRemovalQue(x);
continue;
}
else
{
x.damage(2);
}
}
}
}

View File

@@ -0,0 +1,53 @@
package com.gmail.nossr50.skills;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.plugin.Plugin;
public class Taming
{
public static boolean ownerOnline(Wolf theWolf, Plugin pluginx)
{
for(Player x : pluginx.getServer().getOnlinePlayers())
{
if(x instanceof AnimalTamer)
{
AnimalTamer tamer = (AnimalTamer)x;
if(theWolf.getOwner() == tamer)
return true;
}
}
return false;
}
public static Player getOwner(Entity wolf, Plugin pluginx)
{
if(wolf instanceof Wolf)
{
Wolf theWolf = (Wolf)wolf;
for(Player x : pluginx.getServer().getOnlinePlayers())
{
if(x instanceof AnimalTamer)
{
AnimalTamer tamer = (AnimalTamer)x;
if(theWolf.getOwner() == tamer)
return x;
}
}
}
return null;
}
public static String getOwnerName(Wolf theWolf)
{
Player owner = (Player)theWolf.getOwner();
if(owner != null)
{
return owner.getName();
}
else
return "Offline Master";
}
}

View File

@@ -0,0 +1,95 @@
package com.gmail.nossr50.skills;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
public class Unarmed {
public static void berserkActivationCheck(Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(player.getItemInHand().getTypeId() == 0)
{
if(PP.getFistsPreparationMode())
{
PP.setFistsPreparationMode(false);
}
int ticks = 2;
int x = PP.getSkillLevel(SkillType.UNARMED);
while(x >= 50){
x-=50;
ticks++;
}
if(!PP.getBerserkMode() && Skills.cooldownOver(player, PP.getBerserkDeactivatedTimeStamp(), LoadProperties.berserkCooldown))
{
player.sendMessage(mcLocale.getString("Skills.BerserkOn"));
for(Player y : player.getWorld().getPlayers())
{
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
y.sendMessage(mcLocale.getString("Skills.BerserkPlayer", new Object[] {player.getName()}));
}
PP.setBerserkActivatedTimeStamp(System.currentTimeMillis());
PP.setBerserkDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
PP.setBerserkMode(true);
}
}
}
public static void unarmedBonus(Player attacker, EntityDamageByEntityEvent event)
{
PlayerProfile PPa = Users.getProfile(attacker);
int bonus = 0;
if (PPa.getSkillLevel(SkillType.UNARMED) >= 250)
bonus+=2;
if (PPa.getSkillLevel(SkillType.UNARMED) >= 500)
bonus+=4;
event.setDamage(event.getDamage()+bonus);
}
public static void disarmProcCheck(Player attacker, Player defender)
{
PlayerProfile PP = Users.getProfile(attacker);
if(attacker.getItemInHand().getTypeId() == 0)
{
if(PP.getSkillLevel(SkillType.UNARMED) >= 1000)
{
if(Math.random() * 4000 <= 1000)
{
Location loc = defender.getLocation();
if(defender.getItemInHand() != null && defender.getItemInHand().getTypeId() != 0)
{
defender.sendMessage(mcLocale.getString("Skills.Disarmed"));
ItemStack item = defender.getItemInHand();
if(item != null)
{
loc.getWorld().dropItemNaturally(loc, item);
ItemStack itemx = null;
defender.setItemInHand(itemx);
}
}
}
} else {
if(Math.random() * 4000 <= PP.getSkillLevel(SkillType.UNARMED)){
Location loc = defender.getLocation();
if(defender.getItemInHand() != null && defender.getItemInHand().getTypeId() != 0)
{
defender.sendMessage(mcLocale.getString("Skills.Disarmed"));
ItemStack item = defender.getItemInHand();
if(item != null)
{
loc.getWorld().dropItemNaturally(loc, item);
ItemStack itemx = null;
defender.setItemInHand(itemx);
}
}
}
}
}
}
}

View File

@@ -0,0 +1,153 @@
package com.gmail.nossr50.skills;
import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.config.*;
public class WoodCutting
{
static int w = 0;
private static boolean isdone = false;
public static void woodCuttingProcCheck(Player player, Block block)
{
PlayerProfile PP = Users.getProfile(player);
byte type = block.getData();
Material mat = Material.getMaterial(block.getTypeId());
if(player != null)
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.WOODCUTTING))
{
ItemStack item = new ItemStack(mat, 1, (short) 0, type);
block.getWorld().dropItemNaturally(block.getLocation(), item);
}
}
}
public static void treeFellerCheck(Player player, Block block)
{
PlayerProfile PP = Users.getProfile(player);
if(m.isAxes(player.getItemInHand()))
{
if(block != null)
{
if(!m.abilityBlockCheck(block))
return;
}
/*
* CHECK FOR AXE PREP MODE
*/
if(PP.getAxePreparationMode())
{
PP.setAxePreparationMode(false);
}
int ticks = 2;
int x = PP.getSkillLevel(SkillType.WOODCUTTING);
while(x >= 50)
{
x-=50;
ticks++;
}
if(!PP.getTreeFellerMode() && Skills.cooldownOver(player, (PP.getTreeFellerDeactivatedTimeStamp()*1000), LoadProperties.treeFellerCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TreeFellerOn"));
for(Player y : player.getWorld().getPlayers())
{
if(y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
y.sendMessage(mcLocale.getString("Skills.TreeFellerPlayer", new Object[] {player.getName()}));
}
PP.setTreeFellerActivatedTimeStamp(System.currentTimeMillis());
PP.setTreeFellerDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
PP.setTreeFellerMode(true);
}
if(!PP.getTreeFellerMode() && !Skills.cooldownOver(player, (PP.getTreeFellerDeactivatedTimeStamp()*1000), LoadProperties.treeFellerCooldown)){
player.sendMessage(ChatColor.RED+"You are too tired to use that ability again."
+ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, (PP.getTreeFellerDeactivatedTimeStamp()*1000), LoadProperties.treeFellerCooldown)+"s)");
}
}
}
public static void treeFeller(Block block, Player player, mcMMO plugin){
PlayerProfile PP = Users.getProfile(player);
int radius = 1;
if(PP.getSkillLevel(SkillType.WOODCUTTING) >= 500)
radius++;
if(PP.getSkillLevel(SkillType.WOODCUTTING) >= 950)
radius++;
ArrayList<Block> blocklist = new ArrayList<Block>();
ArrayList<Block> toAdd = new ArrayList<Block>();
if(block != null)
blocklist.add(block);
while(isdone == false){
addBlocksToTreeFelling(blocklist, toAdd, radius);
}
//This needs to be a hashmap too!
isdone = false;
/*
* Add blocks from the temporary 'toAdd' array list into the 'treeFeller' array list
* We use this temporary list to prevent concurrent modification exceptions
*/
for(Block x : toAdd)
{
if(!plugin.misc.treeFeller.contains(x))
plugin.misc.treeFeller.add(x);
}
toAdd.clear();
}
public static void addBlocksToTreeFelling(ArrayList<Block> blocklist, ArrayList<Block> toAdd, Integer radius)
{
int u = 0;
for (Block x : blocklist)
{
u++;
if(toAdd.contains(x))
continue;
w = 0;
Location loc = x.getLocation();
int vx = x.getX();
int vy = x.getY();
int vz = x.getZ();
/*
* Run through the blocks around the broken block to see if they qualify to be 'felled'
*/
for (int cx = -radius; cx <= radius; cx++) {
for (int cy = -radius; cy <= radius; cy++) {
for (int cz = -radius; cz <= radius; cz++) {
Block blocktarget = loc.getWorld().getBlockAt(vx + cx, vy + cy, vz + cz);
if (!blocklist.contains(blocktarget) && !toAdd.contains(blocktarget) && (blocktarget.getTypeId() == 17 || blocktarget.getTypeId() == 18)) {
toAdd.add(blocktarget);
w++;
}
}
}
}
}
/*
* Add more blocks to blocklist so they can be 'felled'
*/
for(Block xx : toAdd)
{
if(!blocklist.contains(xx))
blocklist.add(xx);
}
if(u >= blocklist.size())
{
isdone = true;
} else {
isdone = false;
}
}
}