OPTIMIZE ALL THE SKILLS!

Adds some cool enum features & cleans up Skills.java - may possibly
break some message displays for Axes & Woodcutting.
This commit is contained in:
GJ 2012-02-27 17:28:32 -05:00
parent 16a0a3364a
commit 57bf414d59
16 changed files with 537 additions and 512 deletions

View File

@ -22,7 +22,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
@ -60,7 +59,7 @@ public class Combat
PlayerProfile PPa = Users.getProfile(attacker);
//If there are any abilities to activate
combatAbilityChecks(attacker, PPa, pluginx);
combatAbilityChecks(attacker, PPa);
//Damage modifiers and proc checks
if(m.isSwords(itemInHand) && mcPermissions.getInstance().swords(attacker))
@ -179,15 +178,15 @@ public class Combat
}
}
public static void combatAbilityChecks(Player attacker, PlayerProfile PPa, Plugin pluginx)
public static void combatAbilityChecks(Player attacker, PlayerProfile PPa)
{
//Check to see if any abilities need to be activated
if(PPa.getAxePreparationMode())
Axes.skullSplitterCheck(attacker);
if(PPa.getAxePreparationMode() && mcPermissions.getInstance().axesAbility(attacker))
Skills.abilityCheck(attacker, SkillType.AXES);
if(PPa.getSwordsPreparationMode())
Swords.serratedStrikesActivationCheck(attacker);
Skills.abilityCheck(attacker, SkillType.SWORDS);
if(PPa.getFistsPreparationMode())
Unarmed.berserkActivationCheck(attacker);
Skills.abilityCheck(attacker, SkillType.UNARMED);
}
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx)

View File

@ -1,11 +1,166 @@
package com.gmail.nossr50.datatypes;
public enum AbilityType {
BERSERK,
SUPER_BREAKER,
GIGA_DRILL_BREAKER,
GREEN_TERRA,
SKULL_SPLIITER,
TREE_FELLER,
SERRATED_STRIKES;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.locale.mcLocale;
public enum AbilityType
{
BERSERK(LoadProperties.berserkCooldown, mcLocale.getString("Skills.BerserkOn"), mcLocale.getString("Skills.BerserkOff"), "Skills.BerserkPlayer", mcLocale.getString("Skills.YourBerserk")),
SUPER_BREAKER(LoadProperties.superBreakerCooldown, mcLocale.getString("Skills.SuperBreakerOn"), mcLocale.getString("Skills.SuperBreakerOff"), "Skills.SuperBreakerPlayer", mcLocale.getString("Skills.YourSuperBreaker")),
GIGA_DRILL_BREAKER(LoadProperties.gigaDrillBreakerCooldown, mcLocale.getString("Skills.GigaDrillBreakerOn"), mcLocale.getString("Skills.GigaDrillBreakerOff"), "Skills.GigaDrillBreakerPlayer", mcLocale.getString("Skills.YourGigaDrillBreaker")),
GREEN_TERRA(LoadProperties.greenTerraCooldown, mcLocale.getString("Skills.GreenTerraOn"), mcLocale.getString("Skills.GreenTerraOff"), "Skills.GreenTerraPlayer", mcLocale.getString("Skills.YourGreenTerra")),
SKULL_SPLIITER(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SkullSplitterOn"), mcLocale.getString("Skills.SkullSplitterOff"), "Skills.SkullSplitterPlayer", mcLocale.getString("Skills.YourSkullSplitter")),
TREE_FELLER(LoadProperties.treeFellerCooldown, mcLocale.getString("Skills.TreeFellerOn"), mcLocale.getString("Skills.TreeFellerOff"), "Skills.TreeFellerPlayer", mcLocale.getString("Skills.YourTreeFeller")),
SERRATED_STRIKES(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SerratedStrikesOn"), mcLocale.getString("Skills.SerratedStrikesOff"), "Skills.SerratedStrikesPlayer", mcLocale.getString("Skills.YourSerratedStrikes"));
private int cooldown;
private String abilityOn;
private String abilityOff;
private String abilityPlayer;
private String abilityRefresh;
private AbilityType(int cooldown, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh)
{
this.cooldown = cooldown;
this.abilityOn = abilityOn;
this.abilityOff = abilityOff;
this.abilityPlayer = abilityPlayer;
this.abilityRefresh = abilityRefresh;
}
public int getCooldown()
{
return this.cooldown;
}
public String getAbilityOn()
{
return this.abilityOn;
}
public String getAbilityOff()
{
return this.abilityOff;
}
public String getAbilityPlayer(Player player)
{
return mcLocale.getString(this.abilityPlayer, new Object[] {player.getName()});
}
public String getAbilityRefresh()
{
return this.abilityRefresh;
}
public boolean getMode(PlayerProfile PP)
{
switch(this)
{
case BERSERK:
return PP.getBerserkMode();
case SUPER_BREAKER:
return PP.getSuperBreakerMode();
case GIGA_DRILL_BREAKER:
return PP.getGigaDrillBreakerMode();
case GREEN_TERRA:
return PP.getGreenTerraMode();
case SKULL_SPLIITER:
return PP.getSkullSplitterMode();
case TREE_FELLER:
return PP.getTreeFellerMode();
case SERRATED_STRIKES:
return PP.getSerratedStrikesMode();
}
return false;
}
public void setMode(PlayerProfile PP, boolean bool)
{
switch(this)
{
case BERSERK:
PP.setBerserkMode(bool);
case SUPER_BREAKER:
PP.setSuperBreakerMode(bool);
case GIGA_DRILL_BREAKER:
PP.setGigaDrillBreakerMode(bool);
case GREEN_TERRA:
PP.setGreenTerraMode(bool);
case SKULL_SPLIITER:
PP.setSkullSplitterMode(bool);
case TREE_FELLER:
PP.setTreeFellerMode(bool);
case SERRATED_STRIKES:
PP.setSerratedStrikesMode(bool);
}
}
public boolean getInformed(PlayerProfile PP)
{
switch(this)
{
case BERSERK:
return PP.getBerserkInformed();
case SUPER_BREAKER:
return PP.getSuperBreakerInformed();
case GIGA_DRILL_BREAKER:
return PP.getGigaDrillBreakerInformed();
case GREEN_TERRA:
return PP.getGreenTerraInformed();
case SKULL_SPLIITER:
return PP.getSkullSplitterInformed();
case TREE_FELLER:
return PP.getTreeFellerInformed();
case SERRATED_STRIKES:
return PP.getSerratedStrikesInformed();
}
return false;
}
public void setInformed(PlayerProfile PP, boolean bool)
{
switch(this)
{
case BERSERK:
PP.setBerserkInformed(bool);
case SUPER_BREAKER:
PP.setSuperBreakerInformed(bool);
case GIGA_DRILL_BREAKER:
PP.setGigaDrillBreakerInformed(bool);
case GREEN_TERRA:
PP.setGreenTerraInformed(bool);
case SKULL_SPLIITER:
PP.setSkullSplitterInformed(bool);
case TREE_FELLER:
PP.setTreeFellerInformed(bool);
case SERRATED_STRIKES:
PP.setSerratedStrikesInformed(bool);
}
}
public boolean getPermissions(Player player)
{
switch(this)
{
case BERSERK:
return mcPermissions.getInstance().unarmedAbility(player);
case GIGA_DRILL_BREAKER:
return mcPermissions.getInstance().excavationAbility(player);
case GREEN_TERRA:
return mcPermissions.getInstance().herbalismAbility(player);
case SERRATED_STRIKES:
return mcPermissions.getInstance().swordsAbility(player);
case SKULL_SPLIITER:
return mcPermissions.getInstance().axesAbility(player);
case SUPER_BREAKER:
return mcPermissions.getInstance().miningAbility(player);
case TREE_FELLER:
return mcPermissions.getInstance().woodCuttingAbility(player);
}
return false;
}
}

View File

@ -16,19 +16,97 @@
*/
package com.gmail.nossr50.datatypes;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
public enum SkillType
{
ACROBATICS,
ACROBATICS(LoadProperties.levelCapAcrobatics),
ALL, //This one is just for convenience
ARCHERY,
AXES,
EXCAVATION,
FISHING,
HERBALISM,
MINING,
REPAIR,
SWORDS,
TAMING,
UNARMED,
WOODCUTTING;
ARCHERY(LoadProperties.levelCapArchery),
AXES(AbilityType.SKULL_SPLIITER, LoadProperties.levelCapAxes, ToolType.AXE),
EXCAVATION(AbilityType.GIGA_DRILL_BREAKER, LoadProperties.levelCapExcavation, ToolType.SHOVEL),
FISHING(LoadProperties.levelCapFishing),
HERBALISM(AbilityType.GREEN_TERRA, LoadProperties.levelCapHerbalism, ToolType.HOE),
MINING(AbilityType.SUPER_BREAKER, LoadProperties.levelCapMining, ToolType.PICKAXE),
REPAIR(LoadProperties.levelCapRepair),
SWORDS(AbilityType.SERRATED_STRIKES, LoadProperties.levelCapSwords, ToolType.SWORD),
TAMING(LoadProperties.levelCapTaming),
UNARMED(AbilityType.BERSERK, LoadProperties.levelCapUnarmed, ToolType.FISTS),
WOODCUTTING(AbilityType.TREE_FELLER, LoadProperties.levelCapWoodcutting, ToolType.AXE);
private AbilityType ability;
private int maxLevel;
private ToolType tool;
private SkillType()
{
this.ability = null;
this.maxLevel = 0;
this.tool = null;
}
private SkillType(AbilityType ability, int maxLevel, ToolType tool)
{
this.ability = ability;
this.maxLevel = maxLevel;
this.tool = tool;
}
private SkillType(int maxLevel)
{
this(null, maxLevel, null);
}
public AbilityType getAbility()
{
return this.ability;
}
public int getMaxLevel()
{
if(maxLevel > 0)
return maxLevel;
else
return Integer.MAX_VALUE;
}
public ToolType getTool()
{
return this.tool;
}
public boolean getPermissions(Player player)
{
switch(this)
{
case ACROBATICS:
return mcPermissions.getInstance().acrobatics(player);
case ARCHERY:
return mcPermissions.getInstance().archery(player);
case AXES:
return mcPermissions.getInstance().axes(player);
case EXCAVATION:
return mcPermissions.getInstance().excavation(player);
case FISHING:
return mcPermissions.getInstance().fishing(player);
case HERBALISM:
return mcPermissions.getInstance().herbalism(player);
case MINING:
return mcPermissions.getInstance().mining(player);
case REPAIR:
return mcPermissions.getInstance().repair(player);
case SWORDS:
return mcPermissions.getInstance().swords(player);
case TAMING:
return mcPermissions.getInstance().taming(player);
case UNARMED:
return mcPermissions.getInstance().unarmed(player);
case WOODCUTTING:
return mcPermissions.getInstance().woodcutting(player);
}
return false;
}
}

View File

@ -0,0 +1,134 @@
package com.gmail.nossr50.datatypes;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.m;
import com.gmail.nossr50.locale.mcLocale;
public enum ToolType
{
AXE(mcLocale.getString("Skills.LowerAxe"), mcLocale.getString("Skills.ReadyAxe")),
FISTS(mcLocale.getString("Skills.LowerFists"), mcLocale.getString("Skills.ReadyFists")),
HOE(mcLocale.getString("Skills.LowerHoe"), mcLocale.getString("Skills.ReadyHoe")),
PICKAXE(mcLocale.getString("Skills.LowerPickAxe"), mcLocale.getString("Skills.ReadyPickAxe")),
SHOVEL(mcLocale.getString("Skills.LowerShovel"), mcLocale.getString("Skills.ReadyShovel")),
SWORD(mcLocale.getString("Skills.LowerSword"), mcLocale.getString("Skills.ReadySword"));
private String lowerTool;
private String raiseTool;
private ToolType(String lowerTool, String raiseTool)
{
this.lowerTool = lowerTool;
this.raiseTool = raiseTool;
}
public String getLowerTool()
{
return this.lowerTool;
}
public String getRaiseTool()
{
return this.raiseTool;
}
public boolean getToolMode(PlayerProfile PP)
{
switch(this)
{
case AXE:
PP.getAxePreparationMode();
case FISTS:
PP.getFistsPreparationMode();
case HOE:
PP.getHoePreparationMode();
case PICKAXE:
PP.getPickaxePreparationMode();
case SHOVEL:
PP.getShovelPreparationMode();
case SWORD:
PP.getSwordsPreparationMode();
}
return false;
}
public void setToolMode(PlayerProfile PP, boolean bool)
{
switch(this)
{
case AXE:
PP.setAxePreparationMode(bool);
case FISTS:
PP.setFistsPreparationMode(bool);
case HOE:
PP.setHoePreparationMode(bool);
case PICKAXE:
PP.setPickaxePreparationMode(bool);
case SHOVEL:
PP.setShovelPreparationMode(bool);
case SWORD:
PP.setSwordsPreparationMode(bool);
}
}
public long getToolATS(PlayerProfile PP)
{
switch(this)
{
case AXE:
return PP.getAxePreparationATS();
case FISTS:
return PP.getFistsPreparationATS();
case HOE:
return PP.getHoePreparationATS();
case PICKAXE:
return PP.getPickaxePreparationATS();
case SHOVEL:
return PP.getShovelPreparationATS();
case SWORD:
return PP.getSwordsPreparationATS();
}
return 0;
}
public void setToolATS(PlayerProfile PP, long ats)
{
switch(this)
{
case AXE:
PP.setAxePreparationATS(ats);
case FISTS:
PP.setFistsPreparationATS(ats);
case HOE:
PP.setHoePreparationATS(ats);
case PICKAXE:
PP.setPickaxePreparationATS(ats);
case SHOVEL:
PP.setShovelPreparationATS(ats);
case SWORD:
PP.setSwordsPreparationATS(ats);
}
}
public boolean inHand(ItemStack is)
{
switch(this)
{
case AXE:
return m.isAxes(is);
case FISTS:
return is == null;
case HOE:
return m.isHoe(is);
case PICKAXE:
return m.isMiningPick(is);
case SHOVEL:
return m.isShovel(is);
case SWORD:
return m.isSwords(is);
}
return false;
}
}

View File

@ -147,7 +147,7 @@ public class mcBlockListener implements Listener
//Green Terra
if(PP.getHoePreparationMode() && mcPermissions.getInstance().herbalismAbility(player) && ((id == 59 && block.getData() == (byte) 0x07) || Herbalism.canBeGreenTerra(block)))
Herbalism.greenTerraCheck(player);
Skills.abilityCheck(player, SkillType.HERBALISM);
//Wheat && Triple drops
if(PP.getGreenTerraMode() && Herbalism.canBeGreenTerra(block))
@ -224,16 +224,17 @@ public class mcBlockListener implements Listener
if(m.abilityBlockCheck(block))
{
if(PP.getHoePreparationMode() && Herbalism.canBeGreenTerra(block))
Herbalism.greenTerraCheck(player);
Skills.abilityCheck(player, SkillType.HERBALISM);
if(PP.getAxePreparationMode() && id == 17 && mcPermissions.getInstance().woodCuttingAbility(player))
WoodCutting.treeFellerCheck(player);
Skills.abilityCheck(player, SkillType.WOODCUTTING);
if(PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(block))
Mining.superBreakerCheck(player);
Skills.abilityCheck(player, SkillType.MINING);
if(PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(block))
Excavation.gigaDrillBreakerActivationCheck(player);
Skills.abilityCheck(player, SkillType.EXCAVATION);
}
if(PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(block) || id == 78))
Unarmed.berserkActivationCheck(player);
Skills.abilityCheck(player, SkillType.UNARMED);
/*
* TREE FELLER STUFF
@ -323,7 +324,7 @@ public class mcBlockListener implements Listener
* LEAF BLOWER CHECKS
*/
if(id == 18
&& mcPermissions.getInstance().woodcutting(player)
&& mcPermissions.getInstance().woodCuttingAbility(player)
&& PP.getSkillLevel(SkillType.WOODCUTTING) >= 100
&& m.blockBreakSimulate(block, player, true))
{

View File

@ -45,6 +45,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.skills.Acrobatics;
import com.gmail.nossr50.skills.Archery;
import com.gmail.nossr50.skills.BlastMining;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Taming;
@ -159,7 +160,7 @@ public class mcEntityListener implements Listener
if(plugin.misc.bleedTracker.contains((LivingEntity)x))
plugin.misc.addToBleedRemovalQue((LivingEntity)x);
Skills.arrowRetrievalCheck(x, plugin);
Archery.arrowRetrievalCheck(x, plugin);
if(x instanceof Player){
Player player = (Player)x;

View File

@ -227,8 +227,14 @@ public class mcPlayerListener implements Listener
if(LoadProperties.enableAbilities && m.abilityBlockCheck(block))
{
if(block != null && m.isHoe(is) && !mat.equals(Material.DIRT) && !mat.equals(Material.GRASS) && !mat.equals(Material.SOIL))
Skills.hoeReadinessCheck(player);
Skills.abilityActivationCheck(player);
Skills.activationCheck(player, SkillType.HERBALISM);
Skills.activationCheck(player, SkillType.AXES);
Skills.activationCheck(player, SkillType.EXCAVATION);
Skills.activationCheck(player, SkillType.MINING);
Skills.activationCheck(player, SkillType.SWORDS);
Skills.activationCheck(player, SkillType.UNARMED);
Skills.activationCheck(player, SkillType.WOODCUTTING);
}
//GREEN THUMB
@ -274,8 +280,13 @@ public class mcPlayerListener implements Listener
if(LoadProperties.enableAbilities && action == Action.RIGHT_CLICK_AIR)
{
Skills.hoeReadinessCheck(player);
Skills.abilityActivationCheck(player);
Skills.activationCheck(player, SkillType.AXES);
Skills.activationCheck(player, SkillType.EXCAVATION);
Skills.activationCheck(player, SkillType.HERBALISM);
Skills.activationCheck(player, SkillType.MINING);
Skills.activationCheck(player, SkillType.SWORDS);
Skills.activationCheck(player, SkillType.UNARMED);
Skills.activationCheck(player, SkillType.WOODCUTTING);
}
/*

View File

@ -21,6 +21,7 @@ import com.gmail.nossr50.Combat;
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.skills.Skills;
import com.gmail.nossr50.skills.Swords;
@ -51,12 +52,24 @@ public class mcTimer implements Runnable
/*
* MONITOR SKILLS
*/
Skills.monitorSkills(player, PP, curTime);
Skills.monitorSkill(player, PP, curTime, SkillType.AXES);
Skills.monitorSkill(player, PP, curTime, SkillType.EXCAVATION);
Skills.monitorSkill(player, PP, curTime, SkillType.HERBALISM);
Skills.monitorSkill(player, PP, curTime, SkillType.MINING);
Skills.monitorSkill(player, PP, curTime, SkillType.SWORDS);
Skills.monitorSkill(player, PP, curTime, SkillType.UNARMED);
Skills.monitorSkill(player, PP, curTime, SkillType.WOODCUTTING);
/*
* COOLDOWN MONITORING
*/
Skills.watchCooldowns(player, PP, curTime);
Skills.watchCooldown(player, PP, curTime, SkillType.AXES);
Skills.watchCooldown(player, PP, curTime, SkillType.EXCAVATION);
Skills.watchCooldown(player, PP, curTime, SkillType.HERBALISM);
Skills.watchCooldown(player, PP, curTime, SkillType.MINING);
Skills.watchCooldown(player, PP, curTime, SkillType.SWORDS);
Skills.watchCooldown(player, PP, curTime, SkillType.UNARMED);
Skills.watchCooldown(player, PP, curTime, SkillType.WOODCUTTING);
/*
* PLAYER BLEED MONITORING

View File

@ -19,7 +19,10 @@ package com.gmail.nossr50.skills;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
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;
@ -96,4 +99,18 @@ public class Archery
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
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(), new ItemStack(262, 1));
x++;
}
}
plugin.misc.arrowTracker.remove(entity);
}
}

View File

@ -24,51 +24,15 @@ 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.Combat;
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.AbilityType;
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.getSkillDATS(AbilityType.SKULL_SPLIITER)*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.setSkillDATS(AbilityType.SKULL_SPLIITER, System.currentTimeMillis()+(ticks*1000));
PP.setSkullSplitterMode(true);
}
if(!PP.getSkullSplitterMode() && !Skills.cooldownOver(player, (PP.getSkillDATS(AbilityType.SKULL_SPLIITER)*1000), LoadProperties.skullSplitterCooldown)){
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+Skills.calculateTimeLeft(player, (PP.getSkillDATS(AbilityType.SKULL_SPLIITER)*1000), LoadProperties.skullSplitterCooldown)+"s)");
}
}
}
public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event, Plugin pluginx)
{

View File

@ -27,12 +27,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.player.PlayerAnimationEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
@ -41,37 +39,6 @@ import org.getspout.spoutapi.sound.SoundEffect;
public class Excavation
{
public static void gigaDrillBreakerActivationCheck(Player player)
{
PlayerProfile PP = Users.getProfile(player);
if(m.isShovel(player.getItemInHand()))
{
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.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER) < 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.setSkillDATS(AbilityType.GIGA_DRILL_BREAKER, System.currentTimeMillis()+(ticks*1000));
PP.setGigaDrillBreakerMode(true);
}
}
}
public static boolean canBeGigaDrillBroken(Block block)
{
switch(block.getType()){

View File

@ -30,45 +30,12 @@ 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.AbilityType;
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)
{
PlayerProfile PP = Users.getProfile(player);
if(m.isHoe(player.getItemInHand()))
{
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.getSkillDATS(AbilityType.GREEN_TERRA), 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.setSkillDATS(AbilityType.GREEN_TERRA, System.currentTimeMillis()+(ticks*1000));
PP.setGreenTerraMode(true);
}
}
}
public static void greenTerra(Player player, Block block){
PlayerInventory inventory = player.getInventory();
boolean hasSeeds = inventory.contains(Material.SEEDS);

View File

@ -30,44 +30,13 @@ 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.AbilityType;
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)
{
PlayerProfile PP = Users.getProfile(player);
if(m.isMiningPick(player.getItemInHand()))
{
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.getSkillDATS(AbilityType.SUPER_BREAKER), 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.setSkillDATS(AbilityType.SUPER_BREAKER, System.currentTimeMillis()+(ticks*1000));
PP.setSuperBreakerMode(true);
}
}
}
public static void blockProcSimulate(Block block, Player player)
{
Location loc = block.getLocation();

View File

@ -20,16 +20,13 @@ import java.util.logging.Logger;
import org.bukkit.Bukkit;
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;
@ -37,24 +34,20 @@ import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.PlayerStat;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.events.McMMOPlayerLevelUpEvent;
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)){
if(currentTime - oldTime >= (cooldown * 1000))
return true;
} else {
else
return false;
}
}
public static int calculateTimeLeft(Player player, long deactivatedTimeStamp, int cooldown)
@ -62,227 +55,62 @@ public class Skills
return (int) (((deactivatedTimeStamp + (cooldown * 1000)) - System.currentTimeMillis())/1000);
}
public static void watchCooldowns(Player player, PlayerProfile PP, long curTime){
if(!PP.getGreenTerraInformed() && curTime - (PP.getSkillDATS(AbilityType.GREEN_TERRA)*1000) >= (LoadProperties.greenTerraCooldown * 1000)){
PP.setGreenTerraInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourGreenTerra"));
}
if(!PP.getTreeFellerInformed() && curTime - (PP.getSkillDATS(AbilityType.TREE_FELLER)*1000) >= (LoadProperties.treeFellerCooldown * 1000)){
PP.setTreeFellerInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourTreeFeller"));
}
if(!PP.getSuperBreakerInformed() && curTime - (PP.getSkillDATS(AbilityType.SUPER_BREAKER)*1000) >= (LoadProperties.superBreakerCooldown * 1000)){
PP.setSuperBreakerInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourSuperBreaker"));
}
if(!PP.getSerratedStrikesInformed() && curTime - (PP.getSkillDATS(AbilityType.SERRATED_STRIKES)*1000) >= (LoadProperties.serratedStrikeCooldown * 1000)){
PP.setSerratedStrikesInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourSerratedStrikes"));
}
if(!PP.getBerserkInformed() && (curTime - (PP.getSkillDATS(AbilityType.BERSERK)*1000)) >= (LoadProperties.berserkCooldown * 1000)){
PP.setBerserkInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourBerserk"));
}
if(!PP.getSkullSplitterInformed() && curTime - (PP.getSkillDATS(AbilityType.SKULL_SPLIITER)*1000) >= (LoadProperties.skullSplitterCooldown * 1000)){
PP.setSkullSplitterInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourSkullSplitter"));
}
if(!PP.getGigaDrillBreakerInformed() && curTime - (PP.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER)*1000) >= (LoadProperties.gigaDrillBreakerCooldown * 1000)){
PP.setGigaDrillBreakerInformed(true);
player.sendMessage(mcLocale.getString("Skills.YourGigaDrillBreaker"));
public static void watchCooldown(Player player, PlayerProfile PP, long curTime, SkillType skill)
{
AbilityType ability = skill.getAbility();
if(!ability.getInformed(PP) && curTime - (PP.getSkillDATS(ability) * 1000) >= (ability.getCooldown() * 1000))
{
ability.setInformed(PP, true);
player.sendMessage(ability.getAbilityRefresh());
}
}
public static void hoeReadinessCheck(Player player)
public static void activationCheck(Player player, SkillType skill)
{
if(LoadProperties.enableOnlyActivateWhenSneaking && !player.isSneaking())
return;
PlayerProfile PP = Users.getProfile(player);
if(mcPermissions.getInstance().herbalismAbility(player) && m.isHoe(player.getItemInHand()) && !PP.getHoePreparationMode()){
if(!PP.getGreenTerraMode() && !cooldownOver(player, (PP.getSkillDATS(AbilityType.GREEN_TERRA)*1000), LoadProperties.greenTerraCooldown)){
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getSkillDATS(AbilityType.GREEN_TERRA)*1000), LoadProperties.greenTerraCooldown)+"s)");
return;
}
if(LoadProperties.enableAbilityMessages)
player.sendMessage(mcLocale.getString("Skills.ReadyHoe"));
PP.setHoePreparationATS(System.currentTimeMillis());
PP.setHoePreparationMode(true);
}
}
AbilityType ability = skill.getAbility();
ToolType tool = skill.getTool();
public static void monitorSkills(Player player, PlayerProfile PP, long curTime){
if(PP.getHoePreparationMode() && curTime - (PP.getHoePreparationATS()*1000) >= 4000){
PP.setHoePreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerHoe"));
}
if(PP.getAxePreparationMode() && curTime - (PP.getAxePreparationATS()*1000) >= 4000){
PP.setAxePreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerAxe"));
}
if(PP.getPickaxePreparationMode() && curTime - (PP.getPickaxePreparationATS()*1000) >= 4000){
PP.setPickaxePreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerPickAxe"));
}
if(PP.getSwordsPreparationMode() && curTime - (PP.getSwordsPreparationATS()*1000) >= 4000){
PP.setSwordsPreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerSword"));
}
if(PP.getFistsPreparationMode() && curTime - (PP.getFistsPreparationATS()*1000) >= 4000){
PP.setFistsPreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerFists"));
}
if(PP.getShovelPreparationMode() && curTime - (PP.getShovelPreparationATS()*1000) >= 4000){
PP.setShovelPreparationMode(false);
player.sendMessage(mcLocale.getString("Skills.LowerShovel"));
}
if(!PP.getAbilityUse() || PP.getSuperBreakerMode() || PP.getSerratedStrikesMode() || PP.getTreeFellerMode() || PP.getGreenTerraMode() || PP.getBerserkMode() || PP.getGigaDrillBreakerMode())
return;
/*
* HERBALISM ABILITY
*/
if(mcPermissions.getInstance().herbalismAbility(player)){
if(PP.getGreenTerraMode() && (PP.getSkillDATS(AbilityType.GREEN_TERRA)*1000) <= curTime){
PP.setGreenTerraMode(false);
PP.setGreenTerraInformed(false);
player.sendMessage(mcLocale.getString("Skills.GreenTerraOff"));
}
}
/*
* AXES ABILITY
*/
if(mcPermissions.getInstance().axesAbility(player)){
if(PP.getSkullSplitterMode() && (PP.getSkillDATS(AbilityType.SKULL_SPLIITER)*1000) <= curTime){
PP.setSkullSplitterMode(false);
PP.setSkullSplitterInformed(false);
player.sendMessage(mcLocale.getString("Skills.SkullSplitterOff"));
}
}
/*
* WOODCUTTING ABILITY
*/
if(mcPermissions.getInstance().woodCuttingAbility(player)){
if(PP.getTreeFellerMode() && (PP.getSkillDATS(AbilityType.TREE_FELLER)*1000) <= curTime){
PP.setTreeFellerMode(false);
PP.setTreeFellerInformed(false);
player.sendMessage(mcLocale.getString("Skills.TreeFellerOff"));
}
}
/*
* MINING ABILITY
*/
if(mcPermissions.getInstance().miningAbility(player)){
if(PP.getSuperBreakerMode() && (PP.getSkillDATS(AbilityType.SUPER_BREAKER)*1000) <= curTime){
PP.setSuperBreakerMode(false);
PP.setSuperBreakerInformed(false);
player.sendMessage(mcLocale.getString("Skills.SuperBreakerOff"));
}
}
/*
* EXCAVATION ABILITY
*/
if(mcPermissions.getInstance().excavationAbility(player)){
if(PP.getGigaDrillBreakerMode() && (PP.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER)*1000) <= curTime){
PP.setGigaDrillBreakerMode(false);
PP.setGigaDrillBreakerInformed(false);
player.sendMessage(mcLocale.getString("Skills.GigaDrillBreakerOff"));
}
}
/*
* SWORDS ABILITY
*/
if(mcPermissions.getInstance().swordsAbility(player)){
if(PP.getSerratedStrikesMode() && (PP.getSkillDATS(AbilityType.SERRATED_STRIKES)*1000) <= curTime){
PP.setSerratedStrikesMode(false);
PP.setSerratedStrikesInformed(false);
player.sendMessage(mcLocale.getString("Skills.SerratedStrikesOff"));
}
}
/*
* UNARMED ABILITY
*/
if(mcPermissions.getInstance().unarmedAbility(player)){
if(PP.getBerserkMode() && (PP.getSkillDATS(AbilityType.BERSERK)*1000) <= curTime){
PP.setBerserkMode(false);
PP.setBerserkInformed(false);
player.sendMessage(mcLocale.getString("Skills.BerserkOff"));
}
}
}
public static void abilityActivationCheck(Player player)
{
if(LoadProperties.enableOnlyActivateWhenSneaking && !player.isSneaking())
return;
PlayerProfile PP = Users.getProfile(player);
if(PP != null)
if(ability.getPermissions(player) && tool.inHand(player.getItemInHand()) && !tool.getToolMode(PP))
{
if(!PP.getAbilityUse() || PP.getSuperBreakerMode() || PP.getSerratedStrikesMode() || PP.getTreeFellerMode() || PP.getGreenTerraMode() || PP.getBerserkMode() || PP.getGigaDrillBreakerMode())
return;
if(mcPermissions.getInstance().miningAbility(player) && m.isMiningPick(player.getItemInHand()) && !PP.getPickaxePreparationMode())
{
if(!PP.getSuperBreakerMode() && !cooldownOver(player, (PP.getSkillDATS(AbilityType.SUPER_BREAKER)*1000), LoadProperties.superBreakerCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getSkillDATS(AbilityType.SUPER_BREAKER)*1000), LoadProperties.superBreakerCooldown)+"s)");
return;
}
if(LoadProperties.enableAbilityMessages)
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.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER)*1000), LoadProperties.gigaDrillBreakerCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER)*1000), LoadProperties.gigaDrillBreakerCooldown)+"s)");
return;
}
if(LoadProperties.enableAbilityMessages)
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.getSkillDATS(AbilityType.SERRATED_STRIKES)*1000), LoadProperties.serratedStrikeCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getSkillDATS(AbilityType.SERRATED_STRIKES)*1000), LoadProperties.serratedStrikeCooldown)+"s)");
return;
}
if(LoadProperties.enableAbilityMessages)
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.getSkillDATS(AbilityType.BERSERK)*1000), LoadProperties.berserkCooldown))
{
player.sendMessage(mcLocale.getString("Skills.TooTired")
+ChatColor.YELLOW+" ("+calculateTimeLeft(player, (PP.getSkillDATS(AbilityType.BERSERK)*1000), LoadProperties.berserkCooldown)+"s)");
return;
}
if(LoadProperties.enableAbilityMessages)
player.sendMessage(mcLocale.getString("Skills.ReadyFists"));
PP.setFistsPreparationATS(System.currentTimeMillis());
PP.setFistsPreparationMode(true);
}
if((mcPermissions.getInstance().axesAbility(player) || mcPermissions.getInstance().woodCuttingAbility(player)) && !PP.getAxePreparationMode())
{
if(m.isAxes(player.getItemInHand()))
{
if(LoadProperties.enableAbilityMessages)
player.sendMessage(mcLocale.getString("Skills.ReadyAxe"));
PP.setAxePreparationATS(System.currentTimeMillis());
PP.setAxePreparationMode(true);
}
}
player.sendMessage(mcLocale.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(player, (PP.getSkillDATS(ability) * 1000), ability.getCooldown()) + "s)");
return;
}
if(LoadProperties.enableAbilityMessages)
player.sendMessage(tool.getRaiseTool());
tool.setToolATS(PP, System.currentTimeMillis());
tool.setToolMode(PP, true);
}
public static void monitorSkill(Player player, PlayerProfile PP, long curTime, SkillType skill){
ToolType tool = skill.getTool();
AbilityType ability = skill.getAbility();
if(tool.getToolMode(PP) && curTime - (tool.getToolATS(PP) * 1000) >= 4000)
{
tool.setToolMode(PP, false);
player.sendMessage(tool.getLowerTool());
}
if(ability.getPermissions(player))
{
if(ability.getMode(PP) && (PP.getSkillDATS(ability) * 1000) <= curTime)
{
ability.setMode(PP, false);
ability.setInformed(PP, false);
player.sendMessage(ability.getAbilityOff());
}
}
}
public static void ProcessLeaderboardUpdate(SkillType skillType, Player player)
{
PlayerProfile PP = Users.getProfile(player);
@ -298,11 +126,6 @@ public class Skills
public static void XpCheckSkill(SkillType skillType, Player player)
{
if(skillType == SkillType.ALL) {
XpCheckAll(player);
return;
}
PlayerProfile PP = Users.getProfile(player);
if(PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType))
@ -311,7 +134,7 @@ public class Skills
while(PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType))
{
if(getSkillMaxLevel(skillType) >= PP.getSkillLevel(skillType) + 1)
if(skillType.getMaxLevel() >= PP.getSkillLevel(skillType) + 1)
{
skillups++;
PP.removeXP(skillType, PP.getXpToLevel(skillType));
@ -370,36 +193,7 @@ public class Skills
XpCheckSkill(x, player);
}
}
public static int getSkillMaxLevel(SkillType skillType) {
switch(skillType) {
case ACROBATICS:
return (LoadProperties.levelCapAcrobatics > 0) ? LoadProperties.levelCapAcrobatics : Integer.MAX_VALUE;
case ARCHERY:
return (LoadProperties.levelCapArchery > 0) ? LoadProperties.levelCapArchery : Integer.MAX_VALUE;
case AXES:
return (LoadProperties.levelCapAxes > 0) ? LoadProperties.levelCapAxes : Integer.MAX_VALUE;
case EXCAVATION:
return (LoadProperties.levelCapExcavation > 0) ? LoadProperties.levelCapExcavation : Integer.MAX_VALUE;
case FISHING:
return (LoadProperties.levelCapFishing > 0) ? LoadProperties.levelCapFishing : Integer.MAX_VALUE;
case HERBALISM:
return (LoadProperties.levelCapHerbalism > 0) ? LoadProperties.levelCapHerbalism : Integer.MAX_VALUE;
case MINING:
return (LoadProperties.levelCapMining > 0) ? LoadProperties.levelCapMining : Integer.MAX_VALUE;
case REPAIR:
return (LoadProperties.levelCapRepair > 0) ? LoadProperties.levelCapRepair : Integer.MAX_VALUE;
case SWORDS:
return (LoadProperties.levelCapSwords > 0) ? LoadProperties.levelCapSwords : Integer.MAX_VALUE;
case TAMING:
return (LoadProperties.levelCapTaming > 0) ? LoadProperties.levelCapTaming : Integer.MAX_VALUE;
case UNARMED:
return (LoadProperties.levelCapUnarmed > 0) ? LoadProperties.levelCapUnarmed : Integer.MAX_VALUE;
case WOODCUTTING:
return (LoadProperties.levelCapWoodcutting > 0) ? LoadProperties.levelCapWoodcutting : Integer.MAX_VALUE;
default:
return Integer.MAX_VALUE;
}
}
public static SkillType getSkillType(String skillName)
{
for(SkillType x : SkillType.values())
@ -409,6 +203,7 @@ public class Skills
}
return null;
}
public static boolean isSkill(String skillname){
skillname = skillname.toUpperCase();
for(SkillType x : SkillType.values())
@ -418,19 +213,8 @@ public class Skills
}
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(), new ItemStack(262, 1));
x++;
}
}
plugin.misc.arrowTracker.remove(entity);
}
//We should probably rework this - it's a fairly ugly way to do this, compared to our other command formatting.
public static String getSkillStats(String skillname, Integer level, Integer XP, Integer XPToLevel)
{
ChatColor parColor = ChatColor.DARK_AQUA;
@ -440,6 +224,7 @@ public class Skills
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))
@ -447,13 +232,15 @@ public class Skills
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))
if(mcPermissions.getInstance().excavation(player) || mcPermissions.getInstance().fishing(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))
@ -461,4 +248,34 @@ public class Skills
else
return false;
}
/**
* Check to see if an ability can be activated.
*
* @param player The player activating the ability
* @param type The skill the ability is based on
*/
public static void abilityCheck(Player player, SkillType type)
{
PlayerProfile PP = Users.getProfile(player);
AbilityType ability = type.getAbility();
if(type.getTool().inHand(player.getItemInHand()))
{
if(type.getTool().getToolMode(PP))
type.getTool().setToolMode(PP, false);
int ticks = 2 + (PP.getSkillLevel(type) / 50);
if(!ability.getMode(PP) && cooldownOver(player, PP.getSkillDATS(ability), ability.getCooldown()))
{
player.sendMessage(ability.getAbilityOn());
for(Player y : player.getWorld().getPlayers())
{
if(y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
y.sendMessage(ability.getAbilityPlayer(player));
}
PP.setSkillDATS(ability, System.currentTimeMillis()+(ticks*1000));
ability.setMode(PP, true);
}
}
}
}

View File

@ -27,45 +27,12 @@ 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.AbilityType;
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.getSkillDATS(AbilityType.SERRATED_STRIKES) < 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.setSkillDATS(AbilityType.SERRATED_STRIKES, System.currentTimeMillis()+(ticks*1000));
PP.setSerratedStrikesMode(true);
}
}
}
public static void bleedCheck(Player attacker, LivingEntity x, mcMMO pluginx)
{
PlayerProfile PPa = Users.getProfile(attacker);

View File

@ -21,45 +21,10 @@ 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.AbilityType;
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);
AbilityType ability = AbilityType.BERSERK;
if(player.getItemInHand() == null)
{
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.getSkillDATS(ability), 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.setSkillDATS(ability, System.currentTimeMillis()+(ticks*1000));
PP.setBerserkMode(true);
}
}
}
public static void unarmedBonus(Player attacker, EntityDamageByEntityEvent event)
{