mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-02 00:30:07 +01:00
Some optimizations
As suggested by @bm01 in issue #19: - Pass PlayerProfile and current time to monitorSkills - Pass PlayerProfile and current time to watchCooldowns Testing with only one player seems to indicate a near-negligible increase in performance, but could be useful with more users online.
This commit is contained in:
parent
fded7cad96
commit
3fef87923a
@ -37,6 +37,7 @@ public class mcTimer implements Runnable
|
|||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
long curTime = System.currentTimeMillis();
|
||||||
for(Player player : plugin.getServer().getOnlinePlayers())
|
for(Player player : plugin.getServer().getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if(player == null)
|
if(player == null)
|
||||||
@ -49,12 +50,12 @@ public class mcTimer implements Runnable
|
|||||||
/*
|
/*
|
||||||
* MONITOR SKILLS
|
* MONITOR SKILLS
|
||||||
*/
|
*/
|
||||||
Skills.monitorSkills(player);
|
Skills.monitorSkills(player, PP, curTime);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* COOLDOWN MONITORING
|
* COOLDOWN MONITORING
|
||||||
*/
|
*/
|
||||||
Skills.watchCooldowns(player);
|
Skills.watchCooldowns(player, PP, curTime);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PLAYER BLEED MONITORING
|
* PLAYER BLEED MONITORING
|
||||||
|
@ -77,33 +77,32 @@ public class Skills
|
|||||||
return (int) (((deactivatedTimeStamp + (cooldown * 1000)) - System.currentTimeMillis())/1000);
|
return (int) (((deactivatedTimeStamp + (cooldown * 1000)) - System.currentTimeMillis())/1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void watchCooldowns(Player player){
|
public static void watchCooldowns(Player player, PlayerProfile PP, long curTime){
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
if(!PP.getGreenTerraInformed() && curTime - (PP.getGreenTerraDeactivatedTimeStamp()*1000) >= (LoadProperties.greenTerraCooldown * 1000)){
|
||||||
if(!PP.getGreenTerraInformed() && System.currentTimeMillis() - (PP.getGreenTerraDeactivatedTimeStamp()*1000) >= (LoadProperties.greenTerraCooldown * 1000)){
|
|
||||||
PP.setGreenTerraInformed(true);
|
PP.setGreenTerraInformed(true);
|
||||||
player.sendMessage(mcLocale.getString("Skills.YourGreenTerra"));
|
player.sendMessage(mcLocale.getString("Skills.YourGreenTerra"));
|
||||||
}
|
}
|
||||||
if(!PP.getTreeFellerInformed() && System.currentTimeMillis() - (PP.getTreeFellerDeactivatedTimeStamp()*1000) >= (LoadProperties.greenTerraCooldown * 1000)){
|
if(!PP.getTreeFellerInformed() && curTime - (PP.getTreeFellerDeactivatedTimeStamp()*1000) >= (LoadProperties.greenTerraCooldown * 1000)){
|
||||||
PP.setTreeFellerInformed(true);
|
PP.setTreeFellerInformed(true);
|
||||||
player.sendMessage(mcLocale.getString("Skills.YourTreeFeller"));
|
player.sendMessage(mcLocale.getString("Skills.YourTreeFeller"));
|
||||||
}
|
}
|
||||||
if(!PP.getSuperBreakerInformed() && System.currentTimeMillis() - (PP.getSuperBreakerDeactivatedTimeStamp()*1000) >= (LoadProperties.superBreakerCooldown * 1000)){
|
if(!PP.getSuperBreakerInformed() && curTime - (PP.getSuperBreakerDeactivatedTimeStamp()*1000) >= (LoadProperties.superBreakerCooldown * 1000)){
|
||||||
PP.setSuperBreakerInformed(true);
|
PP.setSuperBreakerInformed(true);
|
||||||
player.sendMessage(mcLocale.getString("Skills.YourSuperBreaker"));
|
player.sendMessage(mcLocale.getString("Skills.YourSuperBreaker"));
|
||||||
}
|
}
|
||||||
if(!PP.getSerratedStrikesInformed() && System.currentTimeMillis() - (PP.getSerratedStrikesDeactivatedTimeStamp()*1000) >= (LoadProperties.serratedStrikeCooldown * 1000)){
|
if(!PP.getSerratedStrikesInformed() && curTime - (PP.getSerratedStrikesDeactivatedTimeStamp()*1000) >= (LoadProperties.serratedStrikeCooldown * 1000)){
|
||||||
PP.setSerratedStrikesInformed(true);
|
PP.setSerratedStrikesInformed(true);
|
||||||
player.sendMessage(mcLocale.getString("Skills.YourSerratedStrikes"));
|
player.sendMessage(mcLocale.getString("Skills.YourSerratedStrikes"));
|
||||||
}
|
}
|
||||||
if(!PP.getBerserkInformed() && System.currentTimeMillis() - (PP.getBerserkDeactivatedTimeStamp()*1000) >= (LoadProperties.berserkCooldown * 1000)){
|
if(!PP.getBerserkInformed() && curTime - (PP.getBerserkDeactivatedTimeStamp()*1000) >= (LoadProperties.berserkCooldown * 1000)){
|
||||||
PP.setBerserkInformed(true);
|
PP.setBerserkInformed(true);
|
||||||
player.sendMessage(mcLocale.getString("Skills.YourBerserk"));
|
player.sendMessage(mcLocale.getString("Skills.YourBerserk"));
|
||||||
}
|
}
|
||||||
if(!PP.getSkullSplitterInformed() && System.currentTimeMillis() - (PP.getSkullSplitterDeactivatedTimeStamp()*1000) >= (LoadProperties.skullSplitterCooldown * 1000)){
|
if(!PP.getSkullSplitterInformed() && curTime - (PP.getSkullSplitterDeactivatedTimeStamp()*1000) >= (LoadProperties.skullSplitterCooldown * 1000)){
|
||||||
PP.setSkullSplitterInformed(true);
|
PP.setSkullSplitterInformed(true);
|
||||||
player.sendMessage(mcLocale.getString("Skills.YourSkullSplitter"));
|
player.sendMessage(mcLocale.getString("Skills.YourSkullSplitter"));
|
||||||
}
|
}
|
||||||
if(!PP.getGigaDrillBreakerInformed() && System.currentTimeMillis() - (PP.getGigaDrillBreakerDeactivatedTimeStamp()*1000) >= (LoadProperties.gigaDrillBreakerCooldown * 1000)){
|
if(!PP.getGigaDrillBreakerInformed() && curTime - (PP.getGigaDrillBreakerDeactivatedTimeStamp()*1000) >= (LoadProperties.gigaDrillBreakerCooldown * 1000)){
|
||||||
PP.setGigaDrillBreakerInformed(true);
|
PP.setGigaDrillBreakerInformed(true);
|
||||||
player.sendMessage(mcLocale.getString("Skills.YourGigaDrillBreaker"));
|
player.sendMessage(mcLocale.getString("Skills.YourGigaDrillBreaker"));
|
||||||
}
|
}
|
||||||
@ -126,104 +125,100 @@ public class Skills
|
|||||||
PP.setHoePreparationMode(true);
|
PP.setHoePreparationMode(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void monitorSkills(Player player){
|
public static void monitorSkills(Player player, PlayerProfile PP, long curTime){
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
if(PP.getHoePreparationMode() && curTime - (PP.getHoePreparationATS()*1000) >= 4000){
|
||||||
if(PP != null)
|
PP.setHoePreparationMode(false);
|
||||||
{
|
player.sendMessage(mcLocale.getString("Skills.LowerHoe"));
|
||||||
if(PP.getHoePreparationMode() && System.currentTimeMillis() - (PP.getHoePreparationATS()*1000) >= 4000){
|
}
|
||||||
PP.setHoePreparationMode(false);
|
if(PP.getAxePreparationMode() && curTime - (PP.getAxePreparationATS()*1000) >= 4000){
|
||||||
player.sendMessage(mcLocale.getString("Skills.LowerHoe"));
|
PP.setAxePreparationMode(false);
|
||||||
}
|
player.sendMessage(mcLocale.getString("Skills.LowerAxe"));
|
||||||
if(PP.getAxePreparationMode() && System.currentTimeMillis() - (PP.getAxePreparationATS()*1000) >= 4000){
|
}
|
||||||
PP.setAxePreparationMode(false);
|
if(PP.getPickaxePreparationMode() && curTime - (PP.getPickaxePreparationATS()*1000) >= 4000){
|
||||||
player.sendMessage(mcLocale.getString("Skills.LowerAxe"));
|
PP.setPickaxePreparationMode(false);
|
||||||
}
|
player.sendMessage(mcLocale.getString("Skills.LowerPickAxe"));
|
||||||
if(PP.getPickaxePreparationMode() && System.currentTimeMillis() - (PP.getPickaxePreparationATS()*1000) >= 4000){
|
}
|
||||||
PP.setPickaxePreparationMode(false);
|
if(PP.getSwordsPreparationMode() && curTime - (PP.getSwordsPreparationATS()*1000) >= 4000){
|
||||||
player.sendMessage(mcLocale.getString("Skills.LowerPickAxe"));
|
PP.setSwordsPreparationMode(false);
|
||||||
}
|
player.sendMessage(mcLocale.getString("Skills.LowerSword"));
|
||||||
if(PP.getSwordsPreparationMode() && System.currentTimeMillis() - (PP.getSwordsPreparationATS()*1000) >= 4000){
|
}
|
||||||
PP.setSwordsPreparationMode(false);
|
if(PP.getFistsPreparationMode() && curTime - (PP.getFistsPreparationATS()*1000) >= 4000){
|
||||||
player.sendMessage(mcLocale.getString("Skills.LowerSword"));
|
PP.setFistsPreparationMode(false);
|
||||||
}
|
player.sendMessage(mcLocale.getString("Skills.LowerFists"));
|
||||||
if(PP.getFistsPreparationMode() && System.currentTimeMillis() - (PP.getFistsPreparationATS()*1000) >= 4000){
|
}
|
||||||
PP.setFistsPreparationMode(false);
|
if(PP.getShovelPreparationMode() && curTime - (PP.getShovelPreparationATS()*1000) >= 4000){
|
||||||
player.sendMessage(mcLocale.getString("Skills.LowerFists"));
|
PP.setShovelPreparationMode(false);
|
||||||
}
|
player.sendMessage(mcLocale.getString("Skills.LowerShovel"));
|
||||||
if(PP.getShovelPreparationMode() && System.currentTimeMillis() - (PP.getShovelPreparationATS()*1000) >= 4000){
|
}
|
||||||
PP.setShovelPreparationMode(false);
|
|
||||||
player.sendMessage(mcLocale.getString("Skills.LowerShovel"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* HERBALISM ABILITY
|
* HERBALISM ABILITY
|
||||||
*/
|
*/
|
||||||
if(mcPermissions.getInstance().herbalismAbility(player)){
|
if(mcPermissions.getInstance().herbalismAbility(player)){
|
||||||
if(PP.getGreenTerraMode() && (PP.getGreenTerraDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
|
if(PP.getGreenTerraMode() && (PP.getGreenTerraDeactivatedTimeStamp()*1000) <= curTime){
|
||||||
PP.setGreenTerraMode(false);
|
PP.setGreenTerraMode(false);
|
||||||
PP.setGreenTerraInformed(false);
|
PP.setGreenTerraInformed(false);
|
||||||
player.sendMessage(mcLocale.getString("Skills.GreenTerraOff"));
|
player.sendMessage(mcLocale.getString("Skills.GreenTerraOff"));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*
|
}
|
||||||
* AXES ABILITY
|
/*
|
||||||
*/
|
* AXES ABILITY
|
||||||
if(mcPermissions.getInstance().axesAbility(player)){
|
*/
|
||||||
if(PP.getSkullSplitterMode() && (PP.getSkullSplitterDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
|
if(mcPermissions.getInstance().axesAbility(player)){
|
||||||
PP.setSkullSplitterMode(false);
|
if(PP.getSkullSplitterMode() && (PP.getSkullSplitterDeactivatedTimeStamp()*1000) <= curTime){
|
||||||
PP.setSkullSplitterInformed(false);
|
PP.setSkullSplitterMode(false);
|
||||||
player.sendMessage(mcLocale.getString("Skills.SkullSplitterOff"));
|
PP.setSkullSplitterInformed(false);
|
||||||
}
|
player.sendMessage(mcLocale.getString("Skills.SkullSplitterOff"));
|
||||||
}
|
}
|
||||||
/*
|
}
|
||||||
* WOODCUTTING ABILITY
|
/*
|
||||||
*/
|
* WOODCUTTING ABILITY
|
||||||
if(mcPermissions.getInstance().woodCuttingAbility(player)){
|
*/
|
||||||
if(PP.getTreeFellerMode() && (PP.getTreeFellerDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
|
if(mcPermissions.getInstance().woodCuttingAbility(player)){
|
||||||
PP.setTreeFellerMode(false);
|
if(PP.getTreeFellerMode() && (PP.getTreeFellerDeactivatedTimeStamp()*1000) <= curTime){
|
||||||
PP.setTreeFellerInformed(false);
|
PP.setTreeFellerMode(false);
|
||||||
player.sendMessage(mcLocale.getString("Skills.TreeFellerOff"));
|
PP.setTreeFellerInformed(false);
|
||||||
}
|
player.sendMessage(mcLocale.getString("Skills.TreeFellerOff"));
|
||||||
}
|
}
|
||||||
/*
|
}
|
||||||
* MINING ABILITY
|
/*
|
||||||
*/
|
* MINING ABILITY
|
||||||
if(mcPermissions.getInstance().miningAbility(player)){
|
*/
|
||||||
if(PP.getSuperBreakerMode() && (PP.getSuperBreakerDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
|
if(mcPermissions.getInstance().miningAbility(player)){
|
||||||
PP.setSuperBreakerMode(false);
|
if(PP.getSuperBreakerMode() && (PP.getSuperBreakerDeactivatedTimeStamp()*1000) <= curTime){
|
||||||
PP.setSuperBreakerInformed(false);
|
PP.setSuperBreakerMode(false);
|
||||||
player.sendMessage(mcLocale.getString("Skills.SuperBreakerOff"));
|
PP.setSuperBreakerInformed(false);
|
||||||
}
|
player.sendMessage(mcLocale.getString("Skills.SuperBreakerOff"));
|
||||||
}
|
}
|
||||||
/*
|
}
|
||||||
* EXCAVATION ABILITY
|
/*
|
||||||
*/
|
* EXCAVATION ABILITY
|
||||||
if(mcPermissions.getInstance().excavationAbility(player)){
|
*/
|
||||||
if(PP.getGigaDrillBreakerMode() && (PP.getGigaDrillBreakerDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
|
if(mcPermissions.getInstance().excavationAbility(player)){
|
||||||
PP.setGigaDrillBreakerMode(false);
|
if(PP.getGigaDrillBreakerMode() && (PP.getGigaDrillBreakerDeactivatedTimeStamp()*1000) <= curTime){
|
||||||
PP.setGigaDrillBreakerInformed(false);
|
PP.setGigaDrillBreakerMode(false);
|
||||||
player.sendMessage(mcLocale.getString("Skills.GigaDrillBreakerOff"));
|
PP.setGigaDrillBreakerInformed(false);
|
||||||
}
|
player.sendMessage(mcLocale.getString("Skills.GigaDrillBreakerOff"));
|
||||||
}
|
}
|
||||||
/*
|
}
|
||||||
* SWORDS ABILITY
|
/*
|
||||||
*/
|
* SWORDS ABILITY
|
||||||
if(mcPermissions.getInstance().swordsAbility(player)){
|
*/
|
||||||
if(PP.getSerratedStrikesMode() && (PP.getSerratedStrikesDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
|
if(mcPermissions.getInstance().swordsAbility(player)){
|
||||||
PP.setSerratedStrikesMode(false);
|
if(PP.getSerratedStrikesMode() && (PP.getSerratedStrikesDeactivatedTimeStamp()*1000) <= curTime){
|
||||||
PP.setSerratedStrikesInformed(false);
|
PP.setSerratedStrikesMode(false);
|
||||||
player.sendMessage(mcLocale.getString("Skills.SerratedStrikesOff"));
|
PP.setSerratedStrikesInformed(false);
|
||||||
}
|
player.sendMessage(mcLocale.getString("Skills.SerratedStrikesOff"));
|
||||||
}
|
}
|
||||||
/*
|
}
|
||||||
* UNARMED ABILITY
|
/*
|
||||||
*/
|
* UNARMED ABILITY
|
||||||
if(mcPermissions.getInstance().unarmedAbility(player)){
|
*/
|
||||||
if(PP.getBerserkMode() && (PP.getBerserkDeactivatedTimeStamp()*1000) <= System.currentTimeMillis()){
|
if(mcPermissions.getInstance().unarmedAbility(player)){
|
||||||
PP.setBerserkMode(false);
|
if(PP.getBerserkMode() && (PP.getBerserkDeactivatedTimeStamp()*1000) <= curTime){
|
||||||
PP.setBerserkInformed(false);
|
PP.setBerserkMode(false);
|
||||||
player.sendMessage(mcLocale.getString("Skills.BerserkOff"));
|
PP.setBerserkInformed(false);
|
||||||
}
|
player.sendMessage(mcLocale.getString("Skills.BerserkOff"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user