Another WIP

This commit is contained in:
nossr50 2011-08-07 15:44:50 -07:00
parent ca9e5c5349
commit 6b97494b75
14 changed files with 114 additions and 176 deletions

View File

@ -9,6 +9,7 @@ Intervals at which players renegerate hp have doubled in length
Rewrote many variables stored per player to be integer instead of long, reducing overall memory usage of mcMMO
Rewrote the Timer mcMMO relies on to instead use the BukkitScheduler for performance
Fixed the party member list of /party
Removed a debug message when repairing diamond armor
Version 1.0.50
New /xprate command for those with mcmmo.admin permissions!

View File

@ -266,11 +266,11 @@ public class Combat
{
//Check to see if any abilities need to be activated
if(PPa.getAxePreparationMode())
Axes.skullSplitterCheck(attacker, pluginx);
Axes.skullSplitterCheck(attacker);
if(PPa.getSwordsPreparationMode())
Swords.serratedStrikesActivationCheck(attacker, pluginx);
Swords.serratedStrikesActivationCheck(attacker);
if(PPa.getFistsPreparationMode())
Unarmed.berserkActivationCheck(attacker, pluginx);
Unarmed.berserkActivationCheck(attacker);
}
public static void archeryCheck(EntityDamageByProjectileEvent event, mcMMO pluginx)
{

View File

@ -332,7 +332,7 @@ public class SpoutStuff
}
public static String getUrlIcon(SkillType skillType)
{
return "http://dl.dropbox.com/u/18212134/xpbar/+"+m.getCapitalized(skillType.toString())+".png";
return "http://dl.dropbox.com/u/18212134/xpbar/"+m.getCapitalized(skillType.toString())+".png";
}
public static boolean shouldBeFilled(PlayerProfile PP)
{

View File

@ -115,7 +115,7 @@ public class mcBlockListener extends BlockListener
//Green Terra
if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalismAbility(player) && block.getTypeId() == 59 && block.getData() == (byte) 0x07)
{
Herbalism.greenTerraCheck(player, block, plugin);
Herbalism.greenTerraCheck(player, block);
}
//Wheat && Triple drops
@ -135,17 +135,11 @@ public class mcBlockListener extends BlockListener
{
if(m.isMiningPick(inhand))
{
if(PP.getSkillLevel(SkillType.MINING) >= 500)
Mining.miningBlockCheck(false, player, block, plugin);
else
Mining.miningBlockCheck(false, player, block, plugin);
Mining.miningBlockCheck(false, player, block, plugin);
}
} else
{
if(PP.getSkillLevel(SkillType.MINING) >= 500)
Mining.miningBlockCheck(false, player, block, plugin);
else
Mining.miningBlockCheck(false, player, block, plugin);
Mining.miningBlockCheck(false, player, block, plugin);
}
}
/*
@ -243,14 +237,14 @@ public class mcBlockListener extends BlockListener
/*
* EXCAVATION
*/
if(mcPermissions.getInstance().excavation(player) && block.getData() != (byte) 5)
if(Excavation.canBeGigaDrillBroken(block) && mcPermissions.getInstance().excavation(player) && block.getData() != (byte) 5)
Excavation.excavationProcCheck(block.getData(), block.getTypeId(), block.getLocation(), player);
/*
* HERBALISM
*/
if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalism(player) && Herbalism.canBeGreenTerra(block))
{
Herbalism.greenTerraCheck(player, block, plugin);
Herbalism.greenTerraCheck(player, block);
}
if(mcPermissions.getInstance().herbalism(player) && block.getData() != (byte) 5)
Herbalism.herbalismProcCheck(block, player, event, plugin);
@ -281,15 +275,15 @@ public class mcBlockListener extends BlockListener
* ABILITY PREPARATION CHECKS
*/
if(PP.getHoePreparationMode() && Herbalism.canBeGreenTerra(block))
Herbalism.greenTerraCheck(player, block, plugin);
Herbalism.greenTerraCheck(player, block);
if(PP.getAxePreparationMode() && block.getTypeId() == 17)
WoodCutting.treeFellerCheck(player, block, plugin);
WoodCutting.treeFellerCheck(player, block);
if(PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(block))
Mining.superBreakerCheck(player, block, plugin);
Mining.superBreakerCheck(player, block);
if(PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(block))
Excavation.gigaDrillBreakerActivationCheck(player, block, plugin);
Excavation.gigaDrillBreakerActivationCheck(player, block);
if(PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(block) || block.getTypeId() == 78))
Unarmed.berserkActivationCheck(player, plugin);
Unarmed.berserkActivationCheck(player);
/*
* TREE FELLAN STUFF

View File

@ -112,7 +112,6 @@ public class m
public static boolean blockBreakSimulate(Block block, Player player, Plugin plugin)
{
FakeBlockBreakEvent event = new FakeBlockBreakEvent(block, player);
if(block != null && plugin != null && player != null){
plugin.getServer().getPluginManager().callEvent(event);
@ -146,7 +145,8 @@ public class m
}
}
}
public static Integer getTier(Player player){
public static Integer getTier(Player player)
{
int i = player.getItemInHand().getTypeId();
if(i == 268 || i == 269 || i == 270 || i == 271 || i == 290){
return 1; //WOOD
@ -162,7 +162,8 @@ public class m
return 1; //UNRECOGNIZED
}
}
public static Integer getMaxDurability(Integer tier, ItemStack item){
public static Integer getMaxDurability(Integer tier, ItemStack item)
{
int id = item.getTypeId();
if(tier == 1){
if((id == 276 || id == 277 || id == 278 || id == 279 || id == 293)){
@ -242,8 +243,10 @@ public class m
}
return true;
}
public static void mcDropItem(Location loc, int id){
if(loc != null){
public static void mcDropItem(Location loc, int id)
{
if(loc != null)
{
Material mat = Material.getMaterial(id);
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
@ -251,18 +254,24 @@ public class m
}
}
public static boolean isSwords(ItemStack is){
if(is.getTypeId() == 268 || is.getTypeId() == 267 || is.getTypeId() == 272 || is.getTypeId() == 283 || is.getTypeId() == 276){
public static boolean isSwords(ItemStack is)
{
if(is.getTypeId() == 268 || is.getTypeId() == 267 || is.getTypeId() == 272 || is.getTypeId() == 283 || is.getTypeId() == 276)
{
return true;
} else {
} else
{
return false;
}
}
public static boolean isHoe(ItemStack is){
public static boolean isHoe(ItemStack is)
{
int id = is.getTypeId();
if(id == 290 || id == 291 || id == 292 || id == 293 || id == 294){
if(id == 290 || id == 291 || id == 292 || id == 293 || id == 294)
{
return true;
} else {
} else
{
return false;
}
}

View File

@ -18,7 +18,7 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.party.Party;
public class Axes {
public static void skullSplitterCheck(Player player, Plugin pluginx){
public static void skullSplitterCheck(Player player){
PlayerProfile PP = Users.getProfile(player);
if(m.isAxes(player.getItemInHand()) && mcPermissions.getInstance().axesAbility(player)){
/*
@ -38,7 +38,7 @@ public class Axes {
if(!PP.getSkullSplitterMode() && Skills.cooldownOver(player, (PP.getSkullSplitterDeactivatedTimeStamp()*1000), LoadProperties.skullSplitterCooldown))
{
player.sendMessage(mcLocale.getString("Skills.SkullSplitterOn"));
for(Player y : pluginx.getServer().getOnlinePlayers()){
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()}));
}

View File

@ -7,8 +7,6 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
@ -19,7 +17,7 @@ import com.gmail.nossr50.datatypes.SkillType;
public class Excavation
{
public static void gigaDrillBreakerActivationCheck(Player player, Block block, Plugin pluginx)
public static void gigaDrillBreakerActivationCheck(Player player, Block block)
{
PlayerProfile PP = Users.getProfile(player);
if(m.isShovel(player.getItemInHand()))
@ -44,7 +42,7 @@ public class Excavation
if(!PP.getGigaDrillBreakerMode() && PP.getGigaDrillBreakerDeactivatedTimeStamp() < System.currentTimeMillis())
{
player.sendMessage(mcLocale.getString("Skills.GigaDrillBreakerOn"));
for(Player y : pluginx.getServer().getOnlinePlayers())
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()}));

View File

@ -7,8 +7,6 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
@ -18,8 +16,46 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
public class Herbalism {
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)
@ -89,36 +125,6 @@ public class Herbalism {
}
}
}
public static void greenTerraCheck(Player player, Block block, Plugin pluginx){
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 : pluginx.getServer().getOnlinePlayers()){
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 herbalismProcCheck(Block block, Player player, BlockBreakEvent event, mcMMO plugin)
{
PlayerProfile PP = Users.getProfile(player);

View File

@ -6,7 +6,6 @@ import org.bukkit.Statistic;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.getspout.spoutapi.sound.SoundEffect;
import com.gmail.nossr50.Users;
@ -21,19 +20,24 @@ import com.gmail.nossr50.locale.mcLocale;
public class Mining
{
public static void superBreakerCheck(Player player, Block block, Plugin pluginx)
public static void superBreakerCheck(Player player, Block block)
{
PlayerProfile PP = Users.getProfile(player);
if(m.isMiningPick(player.getItemInHand())){
if(block != null){
if(m.isMiningPick(player.getItemInHand()))
{
if(block != null)
{
if(!m.abilityBlockCheck(block))
return;
}
if(PP.getPickaxePreparationMode()){
if(PP.getPickaxePreparationMode())
{
PP.setPickaxePreparationMode(false);
}
int ticks = 2;
int x = PP.getSkillLevel(SkillType.MINING);
while(x >= 50)
{
x-=50;
@ -42,7 +46,7 @@ public class Mining
if(!PP.getSuperBreakerMode() && Skills.cooldownOver(player, PP.getSuperBreakerDeactivatedTimeStamp(), LoadProperties.superBreakerCooldown)){
player.sendMessage(mcLocale.getString("Skills.SuperBreakerOn"));
for(Player y : pluginx.getServer().getOnlinePlayers())
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()}));
@ -108,93 +112,17 @@ public class Mining
loc.getWorld().dropItemNaturally(loc, item);
}
}
public static void blockProcSmeltSimulate(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() != 14 && block.getTypeId() != 15 && 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() == 14)
{
mat = Material.getMaterial(266);
item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
}
if(block.getTypeId() == 15)
{
mat = Material.getMaterial(265);
item = new ItemStack(mat, 1, (byte)0, damage);
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 blockProcSmeltCheck(Block block, Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(player != null)
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.MINING))
{
blockProcSmeltSimulate(block);
return;
}
}
}
*/
public static void blockProcCheck(Block block, Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(player != null)
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.MINING))
{
if(Math.random() * 1000 <= PP.getSkillLevel(SkillType.MINING))
{
blockProcSimulate(block);
return;
}
blockProcSimulate(block);
return;
}
}
public static void miningBlockCheck(Boolean smelt, Player player, Block block, mcMMO plugin)
{
PlayerProfile PP = Users.getProfile(player);
@ -295,14 +223,17 @@ public class Mining
/*
* Handling SuperBreaker stuff
*/
public static Boolean canBeSuperBroken(Block block){
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){
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);

View File

@ -50,7 +50,6 @@ public class Repair {
removeItem(player, rDiamond);
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
player.sendMessage(String.valueOf(durabilityBefore - durabilityAfter));
dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 6); //Boost XP
PP.addXP(SkillType.REPAIR, dif * LoadProperties.xpGainMultiplier);

View File

@ -100,7 +100,7 @@ public class Skills
return;
}
player.sendMessage(mcLocale.getString("Skills.ReadyHoe"));
PP.setHoePreparationATS(System.currentTimeMillis()/1000);
PP.setHoePreparationATS(System.currentTimeMillis());
PP.setHoePreparationMode(true);
}
}

View File

@ -8,7 +8,6 @@ import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.Combat;
import com.gmail.nossr50.Users;
@ -22,7 +21,7 @@ import com.gmail.nossr50.party.Party;
public class Swords
{
public static void serratedStrikesActivationCheck(Player player, Plugin pluginx){
public static void serratedStrikesActivationCheck(Player player){
PlayerProfile PP = Users.getProfile(player);
if(m.isSwords(player.getItemInHand()))
{
@ -41,7 +40,7 @@ public class Swords
if(!PP.getSerratedStrikesMode() && PP.getSerratedStrikesDeactivatedTimeStamp() < System.currentTimeMillis())
{
player.sendMessage(mcLocale.getString("Skills.SerratedStrikesOn"));
for(Player y : pluginx.getServer().getOnlinePlayers())
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()}));

View File

@ -4,8 +4,6 @@ import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.config.LoadProperties;
@ -14,10 +12,13 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
public class Unarmed {
public static void berserkActivationCheck(Player player, Plugin pluginx){
public static void berserkActivationCheck(Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(player.getItemInHand().getTypeId() == 0){
if(PP.getFistsPreparationMode()){
if(player.getItemInHand().getTypeId() == 0)
{
if(PP.getFistsPreparationMode())
{
PP.setFistsPreparationMode(false);
}
int ticks = 2;
@ -27,9 +28,11 @@ public class Unarmed {
ticks++;
}
if(!PP.getBerserkMode() && Skills.cooldownOver(player, PP.getBerserkDeactivatedTimeStamp(), LoadProperties.berserkCooldown)){
if(!PP.getBerserkMode() && Skills.cooldownOver(player, PP.getBerserkDeactivatedTimeStamp(), LoadProperties.berserkCooldown))
{
player.sendMessage(mcLocale.getString("Skills.BerserkOn"));
for(Player y : pluginx.getServer().getOnlinePlayers()){
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()}));
}

View File

@ -8,8 +8,6 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
@ -38,7 +36,7 @@ public class WoodCutting
}
}
}
public static void treeFellerCheck(Player player, Block block, Plugin pluginx)
public static void treeFellerCheck(Player player, Block block)
{
PlayerProfile PP = Users.getProfile(player);
if(m.isAxes(player.getItemInHand()))
@ -66,7 +64,7 @@ public class WoodCutting
if(!PP.getTreeFellerMode() && Skills.cooldownOver(player, (PP.getTreeFellerDeactivatedTimeStamp()*1000), LoadProperties.treeFellerCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TreeFellerOn"));
for(Player y : pluginx.getServer().getOnlinePlayers())
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()}));