mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 03:04:44 +02:00
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:
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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()){
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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,226 +55,61 @@ 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();
|
||||
|
||||
if(!PP.getAbilityUse() || PP.getSuperBreakerMode() || PP.getSerratedStrikesMode() || PP.getTreeFellerMode() || PP.getGreenTerraMode() || PP.getBerserkMode() || PP.getGigaDrillBreakerMode())
|
||||
return;
|
||||
|
||||
if(ability.getPermissions(player) && tool.inHand(player.getItemInHand()) && !tool.getToolMode(PP))
|
||||
{
|
||||
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 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"));
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user