1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +01:00

Call BlockBreakEvent in any way when cancelled or not

Fixes #1194
This commit is contained in:
montlikadani 2021-05-26 21:45:22 +02:00
parent 417738f2e3
commit 8d65bb7b7e
6 changed files with 38 additions and 28 deletions

View File

@ -1306,8 +1306,8 @@ public class Jobs extends JavaPlugin {
}
if ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE) {
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
if (inform && player.canGetPaid(info)) {
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
ActionBarManager.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec));
}
@ -1335,8 +1335,8 @@ public class Jobs extends JavaPlugin {
}
if ((time > System.currentTimeMillis() || bp.isPaid()) && bp.getAction() != DBAction.DELETE) {
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
if (inform && player.canGetPaid(info)) {
int sec = Math.round((time - System.currentTimeMillis()) / 1000L);
ActionBarManager.send(player.getPlayer(), lManager.getMessage("message.blocktimer", "[time]", sec));
}

View File

@ -1493,20 +1493,29 @@ public class ConfigManager {
double income = 0D;
if (sep.length >= 2) {
income = Double.parseDouble(sep[1]);
income = updateValue(CurrencyType.MONEY, income);
try {
income = Double.parseDouble(sep[1]);
income = updateValue(CurrencyType.MONEY, income);
} catch (NumberFormatException e) {
}
}
double points = 0D;
if (sep.length >= 3) {
points = Double.parseDouble(sep[2]);
points = updateValue(CurrencyType.POINTS, points);
try {
points = Double.parseDouble(sep[2]);
points = updateValue(CurrencyType.POINTS, points);
} catch (NumberFormatException e) {
}
}
double experience = 0D;
if (sep.length >= 4) {
experience = Double.parseDouble(sep[3]);
experience = updateValue(CurrencyType.EXP, experience);
try {
experience = Double.parseDouble(sep[3]);
experience = updateValue(CurrencyType.EXP, experience);
} catch (NumberFormatException e) {
}
}
jobInfo.add(new JobInfo(actionType, id, meta, type + subType, income, incomeEquation, experience, expEquation, pointsEquation, points, 1,

View File

@ -67,8 +67,9 @@ public class RestrictedBlockManager {
}
}
if (restrictedBlocksTimer.size() > 0)
Jobs.consoleMsg("&e[Jobs] Loaded " + restrictedBlocksTimer.size() + " protected blocks timers!");
int size = restrictedBlocksTimer.size();
if (size > 0)
Jobs.consoleMsg("&e[Jobs] Loaded " + size + " protected blocks timers!");
cfg.save();
}

View File

@ -65,7 +65,7 @@ public class BlockProtection {
}
public boolean isPaid() {
return paid == null ? true : paid.booleanValue();
return paid == null || paid.booleanValue();
}
public void setPaid(boolean paid) {

View File

@ -48,7 +48,7 @@ public final class JobsPayment14Listener implements Listener {
if (camps.isEmpty()) {
campPlayers.remove(map.getKey());
} else {
campPlayers.replace(map.getKey(), camps);
campPlayers.put(map.getKey(), camps);
}
}
@ -65,25 +65,25 @@ public final class JobsPayment14Listener implements Listener {
return;
List<PlayerCamp> camps = campPlayers.get(event.getPlayer().getUniqueId());
if (camps == null)
return;
if (camps != null) {
if (camps.isEmpty()) {
campPlayers.remove(event.getPlayer().getUniqueId());
return;
}
if (camps.isEmpty()) {
campPlayers.remove(event.getPlayer().getUniqueId());
return;
}
for (PlayerCamp camp : new ArrayList<>(camps)) {
if (camp.getBlock().getLocation().equals(event.getBlock().getLocation())) {
camps.remove(camp);
for (PlayerCamp camp : new ArrayList<>(camps)) {
if (camp.getBlock().getLocation().equals(event.getBlock().getLocation())) {
camps.remove(camp);
if (camps.isEmpty()) {
campPlayers.remove(event.getPlayer().getUniqueId());
} else {
campPlayers.replace(event.getPlayer().getUniqueId(), camps);
}
break;
if (camps.isEmpty()) {
campPlayers.remove(event.getPlayer().getUniqueId());
} else {
campPlayers.put(event.getPlayer().getUniqueId(), camps);
}
break;
}
}
}

View File

@ -362,7 +362,7 @@ public class JobsPaymentListener implements Listener {
Jobs.action(jPlayer, new ItemActionInfo(contents, ActionType.BREW));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) {
final Block block = event.getBlock();