mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 01:49:49 -05:00
Optimize the logic for ShopContainerWatcher
Former-commit-id: 15c20591f87c5673ca2ff45e23703413c9bb9a54
This commit is contained in:
1 parent
4a1f050b38
commit
56ccbe9130
2 files changed
+3
-4
No files matched your search
@@ -558,7 +558,7 @@ public class QuickShop extends JavaPlugin {
|
||||
Util.debugLog("Registering shop watcher...");
|
||||
shopVaildWatcher.runTaskTimer(this, 0, 20 * 60);
|
||||
signUpdateWatcher.runTaskTimer(this,0,120);
|
||||
shopContainerWatcher.runTaskTimer(this,0,20);
|
||||
shopContainerWatcher.runTaskTimer(this,0,5);
|
||||
if (logWatcher != null) {
|
||||
logWatcher.runTaskTimerAsynchronously(this, 10, 10);
|
||||
getLogger().info("Log actions is enabled, actions will log in the qs.log file!");
|
||||
|
||||
@@ -45,14 +45,13 @@ public class ShopContainerWatcher extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
long beginTime = System.currentTimeMillis();
|
||||
Shop shop = checkQueue.poll();
|
||||
while (shop != null) {
|
||||
int cost = 0;
|
||||
if(shop instanceof ContainerShop){
|
||||
((ContainerShop) shop).checkContainer();
|
||||
cost ++;
|
||||
}
|
||||
if(cost > 15){
|
||||
if(System.currentTimeMillis() - beginTime > 45){ //Don't let quickshop eat more than 45 ms per tick.
|
||||
break;
|
||||
}
|
||||
shop = checkQueue.poll();
|
||||
|
||||
Reference in new issue
Block a user