mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 01:49:49 -05:00
Add async detect for display check
Former-commit-id: 58804d1c446e014159b510ae63a3608086439247 [formerly 47130e2fa73f678a9e25d0a45f377777293bc7d0] Former-commit-id: 5ab9dfacccacd4c44070a217dca9b2338714dba5
This commit is contained in:
1 parent
43b1b77e0f
commit
8d40d2470a
1 file changed
+44
-4
@@ -16,10 +16,12 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.Event.*;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Util.AsyncDetector;
|
||||
import org.maxgamer.quickshop.Util.MsgUtil;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
@@ -398,20 +400,58 @@ public class ContainerShop implements Shop {
|
||||
if (!this.displayItem.isSpawned()) {
|
||||
/* Not spawned yet. */
|
||||
Util.debugLog("Target item not spawned, spawning...");
|
||||
this.displayItem.spawn();
|
||||
if (!AsyncDetector.isAsync()) {
|
||||
displayItem.spawn();
|
||||
} else {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
displayItem.spawn();
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
} else {
|
||||
/* If not spawned, we didn't need check these, only check them when we need. */
|
||||
if (this.displayItem.checkDisplayNeedRegen()) {
|
||||
this.displayItem.fixDisplayNeedRegen();
|
||||
if (!AsyncDetector.isAsync()) {
|
||||
displayItem.fixDisplayNeedRegen();
|
||||
} else {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
displayItem.fixDisplayNeedRegen();
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
} else {/* If display was regened, we didn't need check it moved, performance! */
|
||||
if (this.displayItem.checkDisplayIsMoved()) {
|
||||
this.displayItem.fixDisplayMoved();
|
||||
if (!AsyncDetector.isAsync()) {
|
||||
displayItem.fixDisplayMoved();
|
||||
} else {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
displayItem.fixDisplayMoved();
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Dupe is always need check, if enabled display */
|
||||
if (plugin.isDisplay()) {
|
||||
this.displayItem.removeDupe();
|
||||
|
||||
if (!AsyncDetector.isAsync()) {
|
||||
displayItem.removeDupe();
|
||||
} else {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
displayItem.removeDupe();
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user