mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 01:49:49 -05:00
#Fix 174
Former-commit-id: cee5290e78eca098974c8d27f9e30d1aea2c493f [formerly cc72045b087dfd558ca7183d37dff504138b3a81] Former-commit-id: d1d419ddbf32186c6ffae9b4f15694296426a049
This commit is contained in:
1 parent
740e04ee1c
commit
c1acf182fd
3 files changed
+27
-33
No files matched your search
@@ -27,10 +27,7 @@ import org.maxgamer.quickshop.Shop.ShopLoader;
|
||||
import org.maxgamer.quickshop.Shop.ShopManager;
|
||||
import org.maxgamer.quickshop.Util.Timer;
|
||||
import org.maxgamer.quickshop.Util.*;
|
||||
import org.maxgamer.quickshop.Watcher.DisplayWatcher;
|
||||
import org.maxgamer.quickshop.Watcher.LogWatcher;
|
||||
import org.maxgamer.quickshop.Watcher.SyncTaskWatcher;
|
||||
import org.maxgamer.quickshop.Watcher.UpdateWatcher;
|
||||
import org.maxgamer.quickshop.Watcher.*;
|
||||
|
||||
//import com.griefcraft.lwc.LWCPlugin;
|
||||
@Getter
|
||||
@@ -136,6 +133,7 @@ public class QuickShop extends JavaPlugin {
|
||||
private ShopManager shopManager;
|
||||
private ShopProtectionListener shopProtectListener;
|
||||
private SyncTaskWatcher syncTaskWatcher;
|
||||
private ShopVaildWatcher shopVaildWatcher;
|
||||
/**
|
||||
* Use SpoutPlugin to get item / block names
|
||||
*/
|
||||
@@ -426,6 +424,7 @@ public class QuickShop extends JavaPlugin {
|
||||
shopProtectListener = new ShopProtectionListener(this);
|
||||
displayWatcher = new DisplayWatcher(this);
|
||||
syncTaskWatcher = new SyncTaskWatcher(this);
|
||||
shopVaildWatcher = new ShopVaildWatcher(this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(blockListener, this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(playerListener, this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(chatListener, this);
|
||||
@@ -449,12 +448,15 @@ public class QuickShop extends JavaPlugin {
|
||||
getLogger().info("QuickShop Loaded! " + enableTimer.endTimer() + " ms.");
|
||||
/* Delay the Ecoonomy system load, give a chance to let economy system regiser. */
|
||||
/* And we have a listener to listen the ServiceRegisterEvent :) */
|
||||
Util.debugLog("Loading economy system...");
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadEcon();
|
||||
}
|
||||
}.runTaskLater(this, 1);
|
||||
Util.debugLog("Registering shop watcher...");
|
||||
shopVaildWatcher.runTaskTimer(this,0,20*60);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -904,6 +906,7 @@ public class QuickShop extends JavaPlugin {
|
||||
}
|
||||
if (selectedVersion == 46) {
|
||||
getConfig().set("shop.use-protection-checking-filter", true);
|
||||
getConfig().set("shop.max-shops-checks-in-once",100);
|
||||
getConfig().set("config-version", 47);
|
||||
selectedVersion = 47;
|
||||
}
|
||||
|
||||
@@ -1,56 +1,44 @@
|
||||
package org.maxgamer.quickshop.Watcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.quickshop.Shop.ShopChunk;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
/**
|
||||
* @author Netherfoam Maintains the display items, restoring them when needed.
|
||||
* Also deletes invalid items.
|
||||
* Check the shops after server booted up, make sure shop can correct self-deleted when container lost.
|
||||
*/
|
||||
@Deprecated
|
||||
public class ShopVaildWatcher implements Runnable {
|
||||
public class ShopVaildWatcher extends BukkitRunnable {
|
||||
private QuickShop plugin;
|
||||
private Queue<Shop> checkQueue = new LinkedList<>();
|
||||
|
||||
@Deprecated
|
||||
public ShopVaildWatcher(@NotNull QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
List<Shop> toRemove = new ArrayList<>();
|
||||
for (Entry<String, HashMap<ShopChunk, HashMap<Location, Shop>>> inWorld : plugin.getShopManager().getShops().entrySet()) {
|
||||
// This world
|
||||
World world = Bukkit.getWorld(inWorld.getKey());
|
||||
if (world == null) {
|
||||
continue; // world not loaded.
|
||||
int checkedShops = 0;
|
||||
int maxCheckShops = plugin.getConfig().getInt("shop.max-shops-checks-in-once");
|
||||
Shop shop = checkQueue.poll();
|
||||
while (shop != null){
|
||||
if(shop.isLoaded() && !shop.isValid()){
|
||||
shop.delete();
|
||||
Util.debugLog("Removed shop at "+shop.getLocation()+" cause the container is missing or not a usable container.");
|
||||
}
|
||||
for (Entry<ShopChunk, HashMap<Location, Shop>> inChunk : inWorld.getValue().entrySet()) {
|
||||
if (!world.isChunkLoaded(inChunk.getKey().getX(), inChunk.getKey().getZ())) {
|
||||
// If the chunk is not loaded, next chunk!
|
||||
continue;
|
||||
}
|
||||
for (Shop shop : inChunk.getValue().values()) {
|
||||
// Validate the shop.
|
||||
if (!shop.isValid()) {
|
||||
toRemove.add(shop);
|
||||
}
|
||||
}
|
||||
checkedShops ++;
|
||||
if(checkedShops >= maxCheckShops){
|
||||
Util.debugLog("Shop check reached the limit, force exit and wait next check window.");
|
||||
}
|
||||
}
|
||||
// Now we can remove it.
|
||||
for (Shop shop : toRemove) {
|
||||
shop.delete();
|
||||
shop = checkQueue.poll();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -236,6 +236,9 @@ shop:
|
||||
# - PLUGIN##LISTENER##EVENT
|
||||
#Example: - QuickShop##org.maxgamer.Listeners.BlockListener##org.bukkit.event.block.BlockPlaceEvent
|
||||
|
||||
#How many shops can be checked in once? (Container exists check)
|
||||
max-shops-checks-in-once: 100
|
||||
|
||||
#Add display name to the spawned DisplayItem entity?
|
||||
display-item-use-name: true
|
||||
|
||||
|
||||
Reference in new issue
Block a user