Move the timer to be async if we're using bukkit's timer.

This should improve the performance of the plugin even more, because it
won't do any database calls while inside the loop which is what was
usually the hang up time.

This is completely untested and possibly could throw tons of errors.
This commit is contained in:
graywolf336
2014-07-21 19:11:12 -05:00
parent e4f32559b6
commit b63773c7a9
6 changed files with 54 additions and 28 deletions

View File

@ -99,7 +99,7 @@ public class JailPayCommand implements Command {
if(amt >= bill) {
pm.pay((Player) sender, bill);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASED, String.valueOf(bill)));
jm.getPlugin().getPrisonerManager().releasePrisoner((Player) sender, p);
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
}else {
long minutes = pm.getMinutesPayingFor(amt);
pm.pay((Player) sender, amt);
@ -112,7 +112,7 @@ public class JailPayCommand implements Command {
if(amt >= bill) {
pm.pay((Player) sender, bill);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASED, String.valueOf(bill)));
jm.getPlugin().getPrisonerManager().releasePrisoner((Player) sender, p);
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
}else {
//You haven't provided enough money to get them out
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEYPROVIDED));
@ -169,7 +169,7 @@ public class JailPayCommand implements Command {
if(amt >= bill) {
pm.pay((Player) sender, bill);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getLastKnownName() }));
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayer(p.getUUID()), p);
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
}else {
long minutes = pm.getMinutesPayingFor(amt);
pm.pay((Player) sender, amt);
@ -182,7 +182,7 @@ public class JailPayCommand implements Command {
if(amt >= bill) {
pm.pay((Player) sender, bill);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getLastKnownName() }));
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayer(p.getUUID()), p);
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
}else {
//You haven't provided enough money to get them out
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEYPROVIDED));