2012-01-09 20:00:13 +01:00
|
|
|
/*
|
|
|
|
This file is part of mcMMO.
|
|
|
|
|
|
|
|
mcMMO is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
mcMMO is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package com.gmail.nossr50.runnables;
|
|
|
|
import org.bukkit.entity.*;
|
|
|
|
|
2012-01-28 07:24:29 +01:00
|
|
|
import com.gmail.nossr50.Combat;
|
2012-01-09 20:00:13 +01:00
|
|
|
import com.gmail.nossr50.Users;
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
2012-02-27 23:28:32 +01:00
|
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
2012-02-21 00:54:30 +01:00
|
|
|
import com.gmail.nossr50.locale.mcLocale;
|
2012-01-09 20:00:13 +01:00
|
|
|
import com.gmail.nossr50.skills.Skills;
|
|
|
|
import com.gmail.nossr50.skills.Swords;
|
|
|
|
|
|
|
|
|
|
|
|
public class mcTimer implements Runnable
|
|
|
|
{
|
|
|
|
private final mcMMO plugin;
|
|
|
|
int thecount = 1;
|
|
|
|
|
|
|
|
public mcTimer(final mcMMO plugin)
|
|
|
|
{
|
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void run()
|
|
|
|
{
|
2012-01-29 03:13:40 +01:00
|
|
|
long curTime = System.currentTimeMillis();
|
2012-01-09 20:00:13 +01:00
|
|
|
for(Player player : plugin.getServer().getOnlinePlayers())
|
|
|
|
{
|
|
|
|
if(player == null)
|
|
|
|
continue;
|
|
|
|
PlayerProfile PP = Users.getProfile(player);
|
|
|
|
|
|
|
|
if(PP == null)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MONITOR SKILLS
|
|
|
|
*/
|
2012-02-27 23:28:32 +01:00
|
|
|
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);
|
2012-01-09 20:00:13 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* COOLDOWN MONITORING
|
|
|
|
*/
|
2012-02-27 23:28:32 +01:00
|
|
|
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);
|
2012-01-09 20:00:13 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* PLAYER BLEED MONITORING
|
|
|
|
*/
|
|
|
|
if(thecount % 2 == 0 && PP.getBleedTicks() >= 1)
|
|
|
|
{
|
2012-02-21 00:54:30 +01:00
|
|
|
//Never kill with Bleeding
|
|
|
|
if(player.getHealth() - 2 < 0)
|
|
|
|
{
|
|
|
|
if(player.getHealth() - 1 > 0)
|
|
|
|
Combat.dealDamage(player, 1);
|
|
|
|
} else
|
|
|
|
Combat.dealDamage(player, 2);
|
|
|
|
|
2012-01-09 20:00:13 +01:00
|
|
|
PP.decreaseBleedTicks();
|
2012-02-21 00:54:30 +01:00
|
|
|
|
|
|
|
if(PP.getBleedTicks() == 0)
|
|
|
|
player.sendMessage(mcLocale.getString("Swords.StoppedBleeding"));
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NON-PLAYER BLEED MONITORING
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(thecount % 2 == 0)
|
|
|
|
Swords.bleedSimulate(plugin);
|
|
|
|
|
|
|
|
//SETUP FOR HP REGEN/BLEED
|
|
|
|
thecount++;
|
|
|
|
if(thecount >= 81)
|
|
|
|
thecount = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|