mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 09:39:40 -05:00
Fixed display many bugs
Former-commit-id: 545ca9cae6131a76872ed6e6a1def932d460d95d [formerly d37aab54dec5b52a45819a24fe0632fbc84b9f7f] Former-commit-id: d083c6558cc2e133a134c301c4860603bd21ce72
This commit is contained in:
1 parent
041cbfd075
commit
a590ecc3df
5 files changed
+39
-10
No files matched your search
@@ -80,9 +80,9 @@ public class DatabaseManager {
|
||||
sqle.printStackTrace();
|
||||
}
|
||||
long tookTime = timer.endTimer();
|
||||
if (tookTime > 300)
|
||||
if (tookTime > 1500)
|
||||
warningSender
|
||||
.sendWarn("Database performance warning: It took to long time (" + tookTime + ") to execute the task, change to a better MySQL server or switch to a local SQLite database!");
|
||||
.sendWarn("Database performance warning: It took too long time (" + tookTime + "ms) to execute the task, change to a better MySQL server or switch to a local SQLite database!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -810,7 +810,7 @@ public class ContainerShop implements Shop {
|
||||
@Override
|
||||
public void checkDisplay() {
|
||||
Util.debugLog("Checking the display...");
|
||||
if (this.displayItem == null)
|
||||
if (!plugin.isDisplay())
|
||||
return;
|
||||
if (!this.displayItem.isSpawned()) {
|
||||
/* Not spawned yet. */
|
||||
|
||||
@@ -3,12 +3,16 @@ package org.maxgamer.quickshop.Shop;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
/**
|
||||
* @author Netherfoam A display item, that spawns a block above the chest and
|
||||
* cannot be interacted with.
|
||||
@@ -105,9 +109,12 @@ public interface DisplayItem {
|
||||
iMeta.setDisplayName("QuickShop DisplayItem");
|
||||
}
|
||||
java.util.List<String> lore = new ArrayList<String>();
|
||||
Gson gson = new Gson();
|
||||
ShopProtectionFlag shopProtectionFlag = new ShopProtectionFlag(shop.getLocation().toString(), Util
|
||||
.serialize(shop.getItem()));
|
||||
String protectFlag = gson.toJson(shopProtectionFlag);
|
||||
for (int i = 0; i < 21; i++) {
|
||||
lore.add("QuickShop DisplayItem#" + shop.getLocation()
|
||||
.toString()); //Create 20 lines lore to make sure no stupid plugin accident remove mark.
|
||||
lore.add(protectFlag); //Create 20 lines lore to make sure no stupid plugin accident remove mark.
|
||||
}
|
||||
iMeta.setLore(lore);
|
||||
itemStack.setItemMeta(iMeta);
|
||||
@@ -128,13 +135,18 @@ public interface DisplayItem {
|
||||
if (iMeta.getDisplayName().toLowerCase().contains("quickshop displayitem"))
|
||||
return true;
|
||||
}
|
||||
if (iMeta.hasLore()) {
|
||||
if (!iMeta.hasLore())
|
||||
return false;
|
||||
List<String> lores = iMeta.getLore();
|
||||
Gson gson = new Gson();
|
||||
for (String lore : lores) {
|
||||
if (lore.toLowerCase().contains("quickshop displayitem"))
|
||||
try {
|
||||
gson.fromJson(lore, ShopProtectionFlag.class);
|
||||
return true;
|
||||
} catch (JsonSyntaxException e) {
|
||||
//Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -153,10 +165,14 @@ public interface DisplayItem {
|
||||
if (!iMeta.hasLore())
|
||||
return false;
|
||||
List<String> lores = iMeta.getLore();
|
||||
Gson gson = new Gson();
|
||||
for (String lore : lores) {
|
||||
if (lore.toLowerCase().contains("quickshop displayitem")) {
|
||||
if (lore.equals("quickshop displayitem#" + shop.getLocation().toString()))
|
||||
try {
|
||||
ShopProtectionFlag shopProtectionFlag = gson.fromJson(lore, ShopProtectionFlag.class);
|
||||
if (shopProtectionFlag.getShopLocation().equals(shop.getLocation().toString()))
|
||||
return true;
|
||||
} catch (JsonSyntaxException e) {
|
||||
//Ignore
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -116,6 +116,8 @@ public class RealDisplayItem implements DisplayItem {
|
||||
.getLocation().toString());
|
||||
entity.remove();
|
||||
removed = true;
|
||||
} else {
|
||||
Util.debugLog(Util.getName(eItem.getItemStack()) + " not a shop displayItem: Failed check shop display.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.maxgamer.quickshop.Shop;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class ShopProtectionFlag {
|
||||
private String shopLocation;
|
||||
private String itemStackString;
|
||||
}
|
||||
Reference in new issue
Block a user