1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

Lets record BP when player places block in any situation if bp is set

This commit is contained in:
Zrips 2020-12-17 15:16:30 +02:00
parent 751b57095f
commit a9540c784e
3 changed files with 36 additions and 22 deletions

View File

@ -173,7 +173,7 @@ public class Jobs extends JavaPlugin {
return false;
if (Integer.parseInt(getServer().getPluginManager().getPlugin("PlaceholderAPI")
.getDescription().getVersion().replaceAll("[^\\d]", "")) >= 2100 && new PlaceholderAPIHook(this).register()) {
.getDescription().getVersion().replaceAll("[^\\d]", "")) >= 2100 && new PlaceholderAPIHook(this).register()) {
consoleMsg("&e[Jobs] PlaceholderAPI hooked.");
}
@ -475,12 +475,12 @@ public class Jobs extends JavaPlugin {
PlayerInfo one = it.next();
int id = one.getID();
JobsPlayer jPlayer = getPlayerManager().getJobsPlayerOffline(
one,
playersJobs.get(id),
playersPoints.get(id),
playersLogs.get(id),
playersArchives.get(id),
playersLimits.get(id));
one,
playersJobs.get(id),
playersPoints.get(id),
playersLogs.get(id),
playersArchives.get(id),
playersLimits.get(id));
if (jPlayer != null)
getPlayerManager().addPlayerToCache(jPlayer);
}
@ -1101,7 +1101,7 @@ public class Jobs extends JavaPlugin {
// JobsPayment event
JobsExpGainEvent jobsExpGainEvent = new JobsExpGainEvent(jPlayer.getPlayer(), prog.getJob(), expAmount,
block, ent, victim, info);
block, ent, victim, info);
Bukkit.getServer().getPluginManager().callEvent(jobsExpGainEvent);
// If event is canceled, don't do anything
expAmount = jobsExpGainEvent.isCancelled() ? 0D : jobsExpGainEvent.getExp();
@ -1202,7 +1202,6 @@ public class Jobs extends JavaPlugin {
if (bp != null) {
Long time = bp.getTime();
Integer cd = getBpManager().getBlockDelayTime(block);
if (time != -1L) {
if (time < System.currentTimeMillis() && bp.getAction() != DBAction.DELETE) {
getBpManager().add(block, cd);
@ -1218,6 +1217,10 @@ public class Jobs extends JavaPlugin {
getBpManager().add(block, cd);
return false;
}
// Lets add protection in any case
getBpManager().add(block, cd);
} else if (bp.isPaid().booleanValue() && bp.getTime() == -1L && cd != null && cd == -1) {
getBpManager().add(block, cd);
return false;
@ -1352,16 +1355,16 @@ public class Jobs extends JavaPlugin {
prevpage = currentPage > 1 ? prevpage : currentPage;
RawMessage rm = new RawMessage()
.addText((currentPage > 1 ? lManager.getMessage("command.help.output.prevPage") : lManager.getMessage("command.help.output.prevPageOff")))
.addHover(currentPage > 1 ? "<<<" : ">|")
.addCommand(currentPage > 1 ? cmd + " " + pagePrefix + prevpage : cmd + " " + pagePrefix + pageCount);
.addText((currentPage > 1 ? lManager.getMessage("command.help.output.prevPage") : lManager.getMessage("command.help.output.prevPageOff")))
.addHover(currentPage > 1 ? "<<<" : ">|")
.addCommand(currentPage > 1 ? cmd + " " + pagePrefix + prevpage : cmd + " " + pagePrefix + pageCount);
rm.addText(lManager.getMessage("command.help.output.pageCount", "[current]", currentPage, "[total]", pageCount))
.addHover(lManager.getMessage("command.help.output.pageCountHover", "[totalEntries]", totalEntries));
.addHover(lManager.getMessage("command.help.output.pageCountHover", "[totalEntries]", totalEntries));
rm.addText(pageCount > currentPage ? lManager.getMessage("command.help.output.nextPage") : lManager.getMessage("command.help.output.nextPageOff"))
.addHover(pageCount > currentPage ? ">>>" : "|<")
.addCommand(pageCount > currentPage ? cmd + " " + pagePrefix + nextPage : cmd + " " + pagePrefix + 1);
.addHover(pageCount > currentPage ? ">>>" : "|<")
.addCommand(pageCount > currentPage ? cmd + " " + pagePrefix + nextPage : cmd + " " + pagePrefix + 1);
if (pageCount != 0)
rm.show(sender);

View File

@ -2,6 +2,7 @@ package com.gamingmesh.jobs.commands.list;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
@ -53,12 +54,22 @@ public class bp implements Cmd {
}
}
changedBlocks.add(l.getBlock());
if (bp.getAction() == DBAction.DELETE)
player.sendBlockChange(l, CMIMaterial.RED_STAINED_GLASS.getMaterial(), (byte) 14);
else if (time == -1)
player.sendBlockChange(l, CMIMaterial.RED_STAINED_GLASS.getMaterial(), (byte) 15);
else
player.sendBlockChange(l, CMIMaterial.RED_STAINED_GLASS.getMaterial(), (byte) 0);
if (Version.isCurrentEqualOrHigher(Version.v1_15_R1)) {
if (bp.getAction() == DBAction.DELETE)
player.sendBlockChange(l, CMIMaterial.RED_STAINED_GLASS.getMaterial().createBlockData());
else if (time == -1)
player.sendBlockChange(l, CMIMaterial.BLACK_STAINED_GLASS.getMaterial().createBlockData());
else
player.sendBlockChange(l, CMIMaterial.WHITE_STAINED_GLASS.getMaterial().createBlockData());
} else {
if (bp.getAction() == DBAction.DELETE)
player.sendBlockChange(l, CMIMaterial.RED_STAINED_GLASS.getMaterial(), (byte) 14);
else if (time == -1)
player.sendBlockChange(l, CMIMaterial.RED_STAINED_GLASS.getMaterial(), (byte) 15);
else
player.sendBlockChange(l, CMIMaterial.RED_STAINED_GLASS.getMaterial(), (byte) 0);
}
}
}
}

View File

@ -418,7 +418,7 @@ public class JobsPaymentListener implements Listener {
|| brokenBlock == CMIMaterial.CACTUS.getMaterial() || brokenBlock == CMIMaterial.BAMBOO.getMaterial())) {
return;
}
Jobs.action(Jobs.getPlayerManager().getJobsPlayer(player), bInfo, block);
}