mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-02-09 00:01:19 +01:00
Spread Workload of Barrelchecks to multiple Ticks
This commit is contained in:
parent
dac2bf90af
commit
703edfc8b8
11
config.yml
11
config.yml
@ -263,6 +263,17 @@ distortCommands:
|
|||||||
- /fl
|
- /fl
|
||||||
- /s
|
- /s
|
||||||
- /letter
|
- /letter
|
||||||
|
- /g
|
||||||
|
- /l
|
||||||
|
- /lokal
|
||||||
|
- /local
|
||||||
|
- /mail send
|
||||||
|
- /m
|
||||||
|
- /msg
|
||||||
|
- /w
|
||||||
|
- /whisper
|
||||||
|
- /reply
|
||||||
|
- /r
|
||||||
|
|
||||||
# Distort the Text written on a Sign while drunk [false]
|
# Distort the Text written on a Sign while drunk [false]
|
||||||
distortSignText: false
|
distortSignText: false
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: Brewery
|
name: Brewery
|
||||||
version: 1.2
|
version: 1.3
|
||||||
main: com.dre.brewery.P
|
main: com.dre.brewery.P
|
||||||
authors: [Milan Albrecht, Frank Baumann]
|
authors: [Milan Albrecht, Frank Baumann]
|
||||||
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention]
|
softdepend: [LWC, LogBlock, WorldGuard, GriefPrevention]
|
||||||
|
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<groupId>com.dre</groupId>
|
<groupId>com.dre</groupId>
|
||||||
<artifactId>brewery</artifactId>
|
<artifactId>brewery</artifactId>
|
||||||
<version>1.2</version>
|
<version>1.3</version>
|
||||||
<name>Brewery</name>
|
<name>Brewery</name>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -36,7 +36,7 @@ public class BCauldron {
|
|||||||
|
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
// Check if fire still alive
|
// Check if fire still alive
|
||||||
if (block.getRelative(BlockFace.DOWN).getType() == Material.FIRE || block.getRelative(BlockFace.DOWN).getType() == Material.STATIONARY_LAVA
|
if (!block.getChunk().isLoaded() || block.getRelative(BlockFace.DOWN).getType() == Material.FIRE || block.getRelative(BlockFace.DOWN).getType() == Material.STATIONARY_LAVA
|
||||||
|| block.getRelative(BlockFace.DOWN).getType() == Material.LAVA) {
|
|| block.getRelative(BlockFace.DOWN).getType() == Material.LAVA) {
|
||||||
// add a minute to cooking time
|
// add a minute to cooking time
|
||||||
state++;
|
state++;
|
||||||
|
@ -18,6 +18,7 @@ import org.bukkit.material.MaterialData;
|
|||||||
import org.bukkit.material.Stairs;
|
import org.bukkit.material.Stairs;
|
||||||
import org.bukkit.material.Tree;
|
import org.bukkit.material.Tree;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.dre.brewery.integration.GriefPreventionBarrel;
|
import com.dre.brewery.integration.GriefPreventionBarrel;
|
||||||
import com.dre.brewery.integration.LWCBarrel;
|
import com.dre.brewery.integration.LWCBarrel;
|
||||||
@ -29,12 +30,13 @@ import org.apache.commons.lang.ArrayUtils;
|
|||||||
public class Barrel {
|
public class Barrel {
|
||||||
|
|
||||||
public static CopyOnWriteArrayList<Barrel> barrels = new CopyOnWriteArrayList<Barrel>();
|
public static CopyOnWriteArrayList<Barrel> barrels = new CopyOnWriteArrayList<Barrel>();
|
||||||
|
private static int check = 0;
|
||||||
|
|
||||||
private Block spigot;
|
private Block spigot;
|
||||||
private int[] woodsloc = null; // location of wood Blocks
|
private int[] woodsloc = null; // location of wood Blocks
|
||||||
private int[] stairsloc = null; // location of stair Blocks
|
private int[] stairsloc = null; // location of stair Blocks
|
||||||
private byte signoffset;
|
private byte signoffset;
|
||||||
private boolean checked = false;
|
private boolean checked;
|
||||||
private Inventory inventory;
|
private Inventory inventory;
|
||||||
private float time;
|
private float time;
|
||||||
|
|
||||||
@ -90,26 +92,19 @@ public class Barrel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void onUpdate() {
|
public static void onUpdate() {
|
||||||
Block broken;
|
|
||||||
for (Barrel barrel : barrels) {
|
for (Barrel barrel : barrels) {
|
||||||
if (!barrel.checked) {
|
|
||||||
broken = barrel.getBrokenBlock(false);
|
|
||||||
if (broken != null) {
|
|
||||||
// remove the barrel if it was destroyed
|
|
||||||
barrel.willDestroy();
|
|
||||||
barrel.remove(broken, null);
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
// Dont check this barrel again, its enough to check it once after every restart
|
|
||||||
// as now this is only the backup if we dont register the barrel breaking, as sample
|
|
||||||
// when removing it with some world editor
|
|
||||||
barrel.checked = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Minecraft day is 20 min, so add 1/20 to the time every minute
|
// Minecraft day is 20 min, so add 1/20 to the time every minute
|
||||||
barrel.time += (1.0 / 20.0);
|
barrel.time += (1.0 / 20.0);
|
||||||
}
|
}
|
||||||
|
if (check == 0 && barrels.size() > 0) {
|
||||||
|
Barrel random = barrels.get((int) Math.floor(Math.random() * barrels.size()));
|
||||||
|
if (random != null) {
|
||||||
|
// You have been selected for a random search
|
||||||
|
// We want to check at least one barrel every time
|
||||||
|
random.checked = false;
|
||||||
|
}
|
||||||
|
new BarrelCheck().runTaskTimer(P.p, 1, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermsOpen(Player player, PlayerInteractEvent event) {
|
public boolean hasPermsOpen(Player player, PlayerInteractEvent event) {
|
||||||
@ -894,4 +889,38 @@ public class Barrel {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class BarrelCheck extends BukkitRunnable {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
boolean repeat = true;
|
||||||
|
while (repeat) {
|
||||||
|
if (check < barrels.size()) {
|
||||||
|
Barrel barrel = barrels.get(check);
|
||||||
|
if (!barrel.checked) {
|
||||||
|
Block broken = barrel.getBrokenBlock(false);
|
||||||
|
if (broken != null) {
|
||||||
|
P.p.debugLog("Barrel at " + broken.getWorld().getName() + "/" + broken.getX() + "/" + broken.getY() + "/" + broken.getZ()
|
||||||
|
+ " has been destroyed unexpectedly, contents will drop");
|
||||||
|
// remove the barrel if it was destroyed
|
||||||
|
barrel.willDestroy();
|
||||||
|
barrel.remove(broken, null);
|
||||||
|
} else {
|
||||||
|
// Dont check this barrel again, its enough to check it once after every restart
|
||||||
|
// as now this is only the backup if we dont register the barrel breaking, as sample
|
||||||
|
// when removing it with some world editor
|
||||||
|
barrel.checked = true;
|
||||||
|
}
|
||||||
|
repeat = false;
|
||||||
|
}
|
||||||
|
check++;
|
||||||
|
} else {
|
||||||
|
check = 0;
|
||||||
|
repeat = false;
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user