mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-18 05:11:32 +01:00
Use GlobalBlockTimer when we cant get cooldown value if its enabled
This commit is contained in:
parent
d72f7d5f91
commit
820e88c573
@ -51,6 +51,7 @@ public class BlockProtectionManager {
|
||||
// }
|
||||
|
||||
public void add(Block block, Integer cd) {
|
||||
Debug.D("adding block timer " + cd);
|
||||
add(block, cd, true);
|
||||
}
|
||||
|
||||
@ -153,8 +154,6 @@ public class BlockProtectionManager {
|
||||
return null;
|
||||
String v = loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ();
|
||||
BlockProtection Bp = chunk.get(v);
|
||||
if (Bp == null)
|
||||
return null;
|
||||
return Bp;
|
||||
}
|
||||
|
||||
@ -173,34 +172,9 @@ public class BlockProtectionManager {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Integer getBlockDelayTime(Block block) {
|
||||
Integer c = Jobs.getRestrictedBlockManager().restrictedBlocksTimer.get(block.getTypeId());
|
||||
return c == null ? 0 : c;
|
||||
Integer time = Jobs.getRestrictedBlockManager().restrictedBlocksTimer.get(block.getTypeId());
|
||||
if (time == null && Jobs.getGCManager().useGlobalTimer)
|
||||
time = Jobs.getGCManager().globalblocktimer;
|
||||
return time;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean checkVegybreak(Block block, Player player) {
|
||||
if (!Jobs.getRestrictedBlockManager().restrictedBlocksTimer.containsKey(block.getTypeId()))
|
||||
return false;
|
||||
if (CheckVegyTimer(block, Jobs.getRestrictedBlockManager().restrictedBlocksTimer.get(block.getTypeId()), player))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean CheckVegyTimer(Block block, int time, Player player) {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (!block.hasMetadata(JobsPaymentListener.VegyMetadata))
|
||||
return false;
|
||||
long BlockTime = block.getMetadata(JobsPaymentListener.VegyMetadata).get(0).asLong();
|
||||
|
||||
if (currentTime >= BlockTime + time * 1000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().BossBarShowOnEachAction) {
|
||||
int sec = Math.round((((BlockTime + time * 1000) - currentTime)) / 1000);
|
||||
Jobs.getActionBar().send(player, Jobs.getLanguage().getMessage("message.blocktimer", "[time]", sec));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,8 @@ public class RestrictedBlockManager {
|
||||
c.getW().addComment("blocksTimer", "Block protected by timer in sec",
|
||||
"Category name can be any you like to be easily recognized",
|
||||
"id can be actual block id (use /jobs blockinfo to get correct id) or use block name",
|
||||
"By setting time to -1 will keep block protected until global cleanup, mainly used for structure blocks like diamond");
|
||||
"By setting time to -1 will keep block protected until global cleanup, mainly used for structure blocks like diamond",
|
||||
"If you want to have default value for all blocks, enale GlobalBlockTimer in generalConfig file");
|
||||
|
||||
if (!c.getC().isConfigurationSection("blocksTimer")) {
|
||||
c.getC().addDefault("blocksTimer.Sapling.id", 6);
|
||||
|
Loading…
Reference in New Issue
Block a user