Skip to content

Commit 7f02be4

Browse files
committed
Always use fast search method
1 parent 0aa61b2 commit 7f02be4

File tree

3 files changed

+62
-61
lines changed

3 files changed

+62
-61
lines changed

src/main/java/org/maxgamer/quickshop/QuickShop.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,7 @@ private void updateConfig(int selectedVersion) throws IOException {
19211921
getConfig().set("purge.banned", true);
19221922
getConfig().set("purge.skip-op", true);
19231923
getConfig().set("purge.return-create-fee", true);
1924+
getConfig().set("shop.use-fast-shop-search-algorithm",null);
19241925
getConfig().set("config-version", ++selectedVersion);
19251926
}
19261927

src/main/java/org/maxgamer/quickshop/shop/ShopManager.java

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class ShopManager implements Reloadable {
8282
private Trader cacheUnlimitedShopAccount;
8383
@Getter
8484
private PriceLimiter priceLimiter;
85-
private boolean useFastShopSearchAlgorithm;
85+
//private boolean useFastShopSearchAlgorithm;
8686
private boolean useOldCanBuildAlgorithm;
8787
private boolean autoSign;
8888

@@ -95,8 +95,8 @@ public ShopManager(@NotNull QuickShop plugin) {
9595
}
9696

9797
private void init() {
98-
this.useFastShopSearchAlgorithm =
99-
plugin.getConfig().getBoolean("shop.use-fast-shop-search-algorithm", false);
98+
// this.useFastShopSearchAlgorithm =
99+
// plugin.getConfig().getBoolean("shop.use-fast-shop-search-algorithm", false);
100100
Util.debugLog("Loading caching tax account...");
101101
String taxAccount = plugin.getConfig().getString("tax-account", "tax");
102102
if (!taxAccount.isEmpty()) {
@@ -386,64 +386,64 @@ public void createShop(@NotNull Shop shop, @NotNull Info info) {
386386
return null;
387387
}
388388

389-
if (this.useFastShopSearchAlgorithm) {
389+
//if (this.useFastShopSearchAlgorithm) {
390390
return getShopIncludeAttached_Fast(loc, false, useCache);
391-
} else {
392-
return getShopIncludeAttached_Classic(loc);
393-
}
391+
// } else {
392+
// return getShopIncludeAttached_Classic(loc);
393+
// }
394394
}
395395

396-
public @Nullable Shop getShopIncludeAttached_Classic(@NotNull Location loc) {
397-
@Nullable Shop shop;
398-
// Get location's chunk all shops
399-
@Nullable Map<Location, Shop> inChunk = getShops(loc.getChunk());
400-
// Found some shops in this chunk.
401-
if (inChunk != null) {
402-
shop = inChunk.get(loc);
403-
if (shop != null) {
404-
// Okay, shop was founded.
405-
return shop;
406-
}
407-
// Ooops, not founded that shop in this chunk.
408-
}
409-
@Nullable Block secondHalfShop = Util.getSecondHalf(loc.getBlock());
410-
if (secondHalfShop != null) {
411-
inChunk = getShops(secondHalfShop.getChunk());
412-
if (inChunk != null) {
413-
shop = inChunk.get(secondHalfShop.getLocation());
414-
if (shop != null) {
415-
// Okay, shop was founded.
416-
return shop;
417-
}
418-
// Oooops, no any shops matched.
419-
}
420-
}
421-
422-
// only check if is sign
423-
Block block = loc.getBlock();
424-
BlockState state = PaperLib.getBlockState(loc.getBlock(), false).getState();
425-
if (state instanceof Sign) {
426-
// If that chunk nothing we founded, we should check it is attached.
427-
@Nullable Block attachedBlock = Util.getAttached(block);
428-
// Check is attached on some block.
429-
if (attachedBlock == null) {
430-
// Nope
431-
return null;
432-
} else {
433-
// Okay we know it on some blocks.
434-
// We need set new location and chunk.
435-
inChunk = getShops(attachedBlock.getChunk());
436-
// Found some shops in this chunk
437-
if (inChunk != null) {
438-
shop = inChunk.get(attachedBlock.getLocation());
439-
// Okay, shop was founded.
440-
return shop;
441-
// Oooops, no any shops matched.
442-
}
443-
}
444-
}
445-
return null;
446-
}
396+
// public @Nullable Shop getShopIncludeAttached_Classic(@NotNull Location loc) {
397+
// @Nullable Shop shop;
398+
// // Get location's chunk all shops
399+
// @Nullable Map<Location, Shop> inChunk = getShops(loc.getChunk());
400+
// // Found some shops in this chunk.
401+
// if (inChunk != null) {
402+
// shop = inChunk.get(loc);
403+
// if (shop != null) {
404+
// // Okay, shop was founded.
405+
// return shop;
406+
// }
407+
// // Ooops, not founded that shop in this chunk.
408+
// }
409+
// @Nullable Block secondHalfShop = Util.getSecondHalf(loc.getBlock());
410+
// if (secondHalfShop != null) {
411+
// inChunk = getShops(secondHalfShop.getChunk());
412+
// if (inChunk != null) {
413+
// shop = inChunk.get(secondHalfShop.getLocation());
414+
// if (shop != null) {
415+
// // Okay, shop was founded.
416+
// return shop;
417+
// }
418+
// // Oooops, no any shops matched.
419+
// }
420+
// }
421+
//
422+
// // only check if is sign
423+
// Block block = loc.getBlock();
424+
// BlockState state = PaperLib.getBlockState(loc.getBlock(), false).getState();
425+
// if (state instanceof Sign) {
426+
// // If that chunk nothing we founded, we should check it is attached.
427+
// @Nullable Block attachedBlock = Util.getAttached(block);
428+
// // Check is attached on some block.
429+
// if (attachedBlock == null) {
430+
// // Nope
431+
// return null;
432+
// } else {
433+
// // Okay we know it on some blocks.
434+
// // We need set new location and chunk.
435+
// inChunk = getShops(attachedBlock.getChunk());
436+
// // Found some shops in this chunk
437+
// if (inChunk != null) {
438+
// shop = inChunk.get(attachedBlock.getLocation());
439+
// // Okay, shop was founded.
440+
// return shop;
441+
// // Oooops, no any shops matched.
442+
// }
443+
// }
444+
// }
445+
// return null;
446+
// }
447447

448448
public void bakeShopRuntimeRandomUniqueIdCache(@NotNull Shop shop) {
449449
shopRuntimeUUIDCaching.put(shop.getRuntimeRandomUniqueId(), shop);

src/main/resources/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,9 @@ shop:
432432
#THIS MAY BREAK SOMETHING!
433433
allow-free-shop: false
434434

435-
#Use fast algorithm for ShopManager#getShopIncludeAttached,
436-
#This should drastically improve performance.
437-
use-fast-shop-search-algorithm: true
435+
# #Use fast algorithm for ShopManager#getShopIncludeAttached,
436+
# #This should drastically improve performance.
437+
# use-fast-shop-search-algorithm: true
438438

439439
#The shop ongoing fee.
440440
#If the shop owner doesn't have enough money, the shop will automatically be removed.

0 commit comments

Comments
 (0)