Replace container watcher task

This commit is contained in:
Warrior committed 2024-07-08 22:17:27 +02:00
1 parent 88a9ab8115
commit e05f0fbdc6
4 files changed
+16 -11

No files matched your search

+3 -3
View File
@@ -101,7 +101,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.13.0</version>
<configuration>
<source>17</source>
<target>17</target>
@@ -114,7 +114,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<version>3.6.0</version>
<configuration>
<finalName>QuickShop</finalName>
<minimizeJar>true</minimizeJar>
@@ -538,7 +538,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.26</version>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
@@ -1126,7 +1126,7 @@ public class QuickShop extends JavaPlugin implements QuickShopAPI {
calendarWatcher = new CalendarWatcher(this);
// shopVaildWatcher.runTaskTimer(this, 0, 20 * 60); // Nobody use it
timerTaskList.add(getServer().getAsyncScheduler().runAtFixedRate(this, signUpdateWatcher, 1, 500, TimeUnit.MILLISECONDS));
timerTaskList.add(getServer().getAsyncScheduler().runAtFixedRate(this, shopContainerWatcher, 1, 250, TimeUnit.MILLISECONDS)); // Nobody use it
//timerTaskList.add(getServer().getAsyncScheduler().runAtFixedRate(this, shopContainerWatcher, 1, 250, TimeUnit.MILLISECONDS)); // Nobody use it
if (logWatcher != null) {
timerTaskList.add(getServer().getAsyncScheduler().runAtFixedRate(this, logWatcher, 250, 250, TimeUnit.MILLISECONDS));
@@ -26,6 +26,7 @@ import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.api.shop.Shop;
import org.maxgamer.quickshop.shop.ContainerShop;
import org.maxgamer.quickshop.util.reload.ReloadResult;
import org.maxgamer.quickshop.util.reload.ReloadStatus;
@@ -49,6 +50,9 @@ public class ChunkListener extends AbstractQSListener {
}
plugin.getServer().getRegionScheduler().runDelayed(plugin, e.getWorld(), e.getChunk().getX(), e.getChunk().getZ(), task -> {
for (Shop shop : inChunk.values()) {
if (shop instanceof ContainerShop cs && !cs.checkContainer())
continue;
shop.onLoad();
}
}, 1);
@@ -1050,7 +1050,7 @@ public class ContainerShop implements Shop {
//Shop manger done this already
//plugin.getShopManager().loadShop(this.getLocation().getWorld().getName(), this);
plugin.getShopManager().getLoadedShops().add(this);
plugin.getShopContainerWatcher().scheduleCheck(this);
//plugin.getShopContainerWatcher().scheduleCheck(this);
// check price restriction
PriceLimiterCheckResult priceRestriction = plugin.getShopManager().getPriceLimiter().check(item, price);
@@ -1536,21 +1536,22 @@ public class ContainerShop implements Shop {
/**
* Check the container still there and we can keep use it.
*/
public void checkContainer() {
public boolean checkContainer() {
Util.ensureThread(this.getLocation(), false);
if (!this.isLoaded) {
return;
}
if (!Util.isLoaded(this.getLocation())) {
return;
if (!this.isLoaded || !Util.isLoaded(this.getLocation())) {
return true;
}
if (!Util.canBeShop(this.getLocation().getBlock())) {
Util.debugLog("Shop at " + this.getLocation() + "@" + this.getLocation().getBlock()
+ " container was missing, deleting...");
plugin.logEvent(new ShopRemoveLog(Util.getNilUniqueId(), "Container invalid", saveToInfoStorage()));
this.onUnload();
this.delete(false);
return false;
}
return true;
}
@Override