mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-29 04:18:07 +01:00
Double flower protection fix
This commit is contained in:
parent
9e6a5efc17
commit
aa79cb2e1c
@ -12,7 +12,10 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.BlockProtection;
|
||||
import com.gamingmesh.jobs.container.DBAction;
|
||||
|
||||
import net.Zrips.CMILib.Container.CMIBlock;
|
||||
import net.Zrips.CMILib.Container.CMIBlock.Bisect;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
||||
|
||||
public class BlockProtectionManager {
|
||||
|
||||
@ -36,6 +39,21 @@ public class BlockProtectionManager {
|
||||
}
|
||||
|
||||
public void add(Block block, Integer cd) {
|
||||
|
||||
// Assuming that block is bottom part of flower we will add top part to the record too
|
||||
CMIMaterial cmat = CMIMaterial.get(block);
|
||||
switch (cmat) {
|
||||
case LILAC:
|
||||
case SUNFLOWER:
|
||||
case ROSE_BUSH:
|
||||
case PEONY:
|
||||
CMIBlock cmb = new CMIBlock(block);
|
||||
// We are only interested in this being bottom block as this should never trigger for top part of placed block
|
||||
if (cmb.getBisect().equals(Bisect.BOTTOM))
|
||||
add(block.getLocation().clone().add(0, 1, 0), cd, true);
|
||||
break;
|
||||
}
|
||||
|
||||
add(block, cd, true);
|
||||
}
|
||||
|
||||
@ -112,6 +130,21 @@ public class BlockProtectionManager {
|
||||
}
|
||||
|
||||
public BlockProtection remove(Block block) {
|
||||
// In case double plant was destroyed we should remove both blocks from records
|
||||
CMIMaterial cmat = CMIMaterial.get(block);
|
||||
switch (cmat) {
|
||||
case LILAC:
|
||||
case SUNFLOWER:
|
||||
case ROSE_BUSH:
|
||||
case PEONY:
|
||||
CMIBlock cmb = new CMIBlock(block);
|
||||
if (cmb.getBisect().equals(Bisect.BOTTOM))
|
||||
remove(block.getLocation().clone().add(0, 1, 0));
|
||||
else
|
||||
remove(block.getLocation().clone().add(0, -1, 0));
|
||||
break;
|
||||
}
|
||||
|
||||
return remove(block.getLocation());
|
||||
}
|
||||
|
||||
|
@ -555,9 +555,6 @@ public class GeneralConfigManager {
|
||||
"Setting this too low may cause tick lag. Increase this to improve economy performance (at the cost of delays in payment)");
|
||||
economyBatchDelay = c.get("economy-batch-delay", 5);
|
||||
|
||||
// We need this to be atleast 1 or more seconds
|
||||
economyBatchDelay = economyBatchDelay < 1 ? 1 : economyBatchDelay;
|
||||
|
||||
c.addComment("economy-async", "Enable async economy calls.", "Disable this if you have issues with payments or your plugin is not thread safe.");
|
||||
economyAsync = c.get("economy-async", true);
|
||||
|
||||
|
@ -27,7 +27,9 @@ public class BufferedPaymentThread extends Thread {
|
||||
|
||||
public BufferedPaymentThread(int duration) {
|
||||
super("Jobs-BufferedPaymentThread");
|
||||
this.sleep = duration * 1000;
|
||||
// We need this to be atleast 1 or more seconds
|
||||
duration = duration < 1 ? 1 : duration;
|
||||
this.sleep = duration * 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user