diff --git a/.gitignore b/.gitignore index 915cecb3d6..a5f18b9331 100644 --- a/.gitignore +++ b/.gitignore @@ -118,3 +118,4 @@ run/ /${rootDir}/build-artifacts/quickshop-hikari-6.2.0.7-shaded.pom /${rootDir}/build-artifacts/quickshop-hikari-6.2.0.7-shaded-sources.pom /${rootDir}/build-artifacts/quickshop-hikari-6.2.0.7-shaded-test-sources.pom +.paper-nms/ diff --git a/addon/list/src/main/java/com/ghostchu/quickshop/addon/list/command/SubCommand_List.java b/addon/list/src/main/java/com/ghostchu/quickshop/addon/list/command/SubCommand_List.java index 3022bf1864..2c271339e9 100644 --- a/addon/list/src/main/java/com/ghostchu/quickshop/addon/list/command/SubCommand_List.java +++ b/addon/list/src/main/java/com/ghostchu/quickshop/addon/list/command/SubCommand_List.java @@ -48,7 +48,7 @@ public void onCommand(final Player sender, @NotNull final String commandLabel, @ quickshop.text().of(sender, "not-a-number", parser.getArgs().get(1)).send(); return; } - page = Integer.parseInt(parser.getArgs().get(2)); + page = Integer.parseInt(parser.getArgs().get(1)); } lookupOther(sender, parser.getArgs().get(0), page); } else { diff --git a/addon/webui/pom.xml b/addon/webui/pom.xml deleted file mode 100644 index b3531e248c..0000000000 --- a/addon/webui/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - 4.0.0 - - com.ghostchu - quickshop-hikari - 6.0.0.0-SNAPSHOT - ../../pom.xml - - com.ghostchu.quickshop.addon - webui - takari-jar - - Addon-WebUI - - An web interface to showcase your QuickShop-Hikari activities - - 17 - UTF-8 - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - org.apache.maven.plugins - maven-shade-plugin - - - - - src/main/resources - true - - - - - - - - org.spigotmc - spigot-api - - - com.ghostchu - quickshop-bukkit - ${project.parent.version} - provided - - - - org.apache.commons - commons-lang3 - 3.14.0 - provided - - - - - - - - - io.vertx - vertx-core - 4.5.3 - - - io.vertx - vertx-web - 4.4.0 - - - - diff --git a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/Main.java b/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/Main.java deleted file mode 100644 index fe2103d086..0000000000 --- a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/Main.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.ghostchu.quickshop.addon.webui; - -import com.ghostchu.quickshop.QuickShop; -import com.ghostchu.quickshop.addon.webui.handler.global.Recent; -import com.ghostchu.quickshop.addon.webui.handler.shop.ServerShopsListing; -import com.ghostchu.quickshop.addon.webui.handler.shop.ShopDetails; -import com.ghostchu.quickshop.addon.webui.handler.shop.ShopHistory; -import com.ghostchu.quickshop.addon.webui.handler.user.UserHistory; -import com.ghostchu.quickshop.addon.webui.handler.user.UserShopsListing; -import io.vertx.core.Vertx; -import io.vertx.core.VertxOptions; -import io.vertx.core.http.HttpServer; -import io.vertx.ext.web.Router; -import io.vertx.ext.web.RoutingContext; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.java.JavaPlugin; - -public final class Main extends JavaPlugin implements Listener { - - static Main instance; - private QuickShop plugin; - private Vertx vertx; - - @Override - public void onLoad() { - - instance = this; - } - - @Override - public void onDisable() { - - HandlerList.unregisterAll((Plugin)this); - } - - @Override - - public void onEnable() { - - saveDefaultConfig(); - plugin = QuickShop.getInstance(); - vertx = Vertx.vertx(new VertxOptions().setUseDaemonThread(true)); - HttpServer server = vertx.createHttpServer(); - Router restAPI = Router.router(vertx); - registerRoute(restAPI); - server.requestHandler(restAPI).listen(plugin.getConfig().getInt("httpd.port")); - } - - @SuppressWarnings("ResultOfMethodCallIgnored") - private void registerRoute(Router restAPI) { - - restAPI.get("/static/*").handler(this::handleStaticAssets); - restAPI.get("/localized").handler(this::handleFrontendRequestLocalizedFiles); - restAPI.get("/global/recent").handler(Recent::new); - restAPI.get("/user/shops").handler(UserShopsListing::new); - restAPI.get("/user/history").handler(UserHistory::new); - restAPI.get("/user/transaction").handler(UserHistory::new); - restAPI.get("/shops").handler(ServerShopsListing::new); - restAPI.get("/shop/:id").handler(ShopDetails::new); - restAPI.get("/shop/:id/history").handler(ShopHistory::new); - } - - - private void handleFrontendRequestLocalizedFiles(RoutingContext routingContext) { - - } - - private void handleStaticAssets(RoutingContext ctx) { - - } -} diff --git a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/GeneralHandler.java b/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/GeneralHandler.java deleted file mode 100644 index 774b9e9fbf..0000000000 --- a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/GeneralHandler.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.ghostchu.quickshop.addon.webui.handler; - -public interface GeneralHandler { - -} diff --git a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/global/Recent.java b/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/global/Recent.java deleted file mode 100644 index 98d2723a05..0000000000 --- a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/global/Recent.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.ghostchu.quickshop.addon.webui.handler.global; - -import com.ghostchu.quickshop.addon.webui.handler.GeneralHandler; -import io.vertx.ext.web.RoutingContext; - -public class Recent implements GeneralHandler { - - public Recent(RoutingContext ctx) { - - } -} diff --git a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/shop/ServerShopsListing.java b/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/shop/ServerShopsListing.java deleted file mode 100644 index d786ae2332..0000000000 --- a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/shop/ServerShopsListing.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.ghostchu.quickshop.addon.webui.handler.shop; - -import com.ghostchu.quickshop.addon.webui.handler.GeneralHandler; -import io.vertx.ext.web.RoutingContext; - -public class ServerShopsListing implements GeneralHandler { - - public ServerShopsListing(RoutingContext ctx) { - - } -} diff --git a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/shop/ShopDetails.java b/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/shop/ShopDetails.java deleted file mode 100644 index 7e920478c0..0000000000 --- a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/shop/ShopDetails.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.ghostchu.quickshop.addon.webui.handler.shop; - -import com.ghostchu.quickshop.addon.webui.handler.GeneralHandler; -import io.vertx.ext.web.RoutingContext; - -public class ShopDetails implements GeneralHandler { - - public ShopDetails(RoutingContext ctx) { - - } -} diff --git a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/shop/ShopHistory.java b/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/shop/ShopHistory.java deleted file mode 100644 index f3cfeb4222..0000000000 --- a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/shop/ShopHistory.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.ghostchu.quickshop.addon.webui.handler.shop; - -import com.ghostchu.quickshop.addon.webui.handler.GeneralHandler; -import io.vertx.ext.web.RoutingContext; - -public class ShopHistory implements GeneralHandler { - - public ShopHistory(RoutingContext ctx) { - - } -} diff --git a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/user/UserHistory.java b/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/user/UserHistory.java deleted file mode 100644 index 5f1269dcef..0000000000 --- a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/user/UserHistory.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.ghostchu.quickshop.addon.webui.handler.user; - -import com.ghostchu.quickshop.addon.webui.handler.GeneralHandler; -import io.vertx.ext.web.RoutingContext; - -public class UserHistory implements GeneralHandler { - - public UserHistory(RoutingContext ctx) { - - } -} diff --git a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/user/UserShopsListing.java b/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/user/UserShopsListing.java deleted file mode 100644 index 81ec3d7f3b..0000000000 --- a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/user/UserShopsListing.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.ghostchu.quickshop.addon.webui.handler.user; - -import com.ghostchu.quickshop.addon.webui.handler.GeneralHandler; -import io.vertx.ext.web.RoutingContext; - -public class UserShopsListing implements GeneralHandler { - - public UserShopsListing(RoutingContext ctx) { - - } -} diff --git a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/user/UserTransaction.java b/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/user/UserTransaction.java deleted file mode 100644 index ee9d9f5cc3..0000000000 --- a/addon/webui/src/main/java/com/ghostchu/quickshop/addon/webui/handler/user/UserTransaction.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.ghostchu.quickshop.addon.webui.handler.user; - -import com.ghostchu.quickshop.addon.webui.handler.GeneralHandler; -import io.vertx.ext.web.RoutingContext; - -public class UserTransaction implements GeneralHandler { - - public UserTransaction(RoutingContext ctx) { - - } -} diff --git a/addon/webui/src/main/resources/config.yml b/addon/webui/src/main/resources/config.yml deleted file mode 100644 index 6206eb4627..0000000000 --- a/addon/webui/src/main/resources/config.yml +++ /dev/null @@ -1,4 +0,0 @@ -config-version: 1 -httpd: - port: 55608 - workerPoolSize: \ No newline at end of file diff --git a/addon/webui/src/main/resources/plugin.yml b/addon/webui/src/main/resources/plugin.yml deleted file mode 100644 index de66a9429c..0000000000 --- a/addon/webui/src/main/resources/plugin.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: qsaddon-${project.artifactId} -version: '${project.version}' -main: com.ghostchu.quickshop.addon.${project.artifactId}.Main -api-version: 1.18 -depend: - - QuickShop-Hikari -authors: [ Ghost_chu ] \ No newline at end of file diff --git a/compatibility/advancedchests/.gitignore b/compatibility/advancedchests/.gitignore deleted file mode 100644 index 4788b4b454..0000000000 --- a/compatibility/advancedchests/.gitignore +++ /dev/null @@ -1,113 +0,0 @@ -# User-specific stuff -.idea/ - -*.iml -*.ipr -*.iws - -# IntelliJ -out/ - -# Compiled class file -*.class - -# Log file -*.log - -# BlueJ files -*.ctxt - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -# Windows thumbnail cache files -Thumbs.db -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -target/ - -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next - -release.properties -dependency-reduced-pom.xml -buildNumber.properties -.mvn/timing.properties -.mvn/wrapper/maven-wrapper.jar -.flattened-pom.xml - -# Common working directory -run/ diff --git a/compatibility/advancedchests/pom.xml b/compatibility/advancedchests/pom.xml deleted file mode 100644 index dc57c1da19..0000000000 --- a/compatibility/advancedchests/pom.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - 4.0.0 - - com.ghostchu - quickshop-hikari - 5.0.0.0 - ../../pom.xml - - com.ghostchu.quickshop.compatibility - advancedchests - takari-jar - - Compat-AdvancedChests - - - 17 - UTF-8 - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - org.apache.maven.plugins - maven-shade-plugin - - - - - src/main/resources - true - - - - - - - jitpack.io - https://jitpack.io - - - - - - org.spigotmc - spigot-api - - - com.github.DeadSilenceIV - AdvancedChestsAPI - 3.2-BETA - provided - - - com.ghostchu.quickshop.compatibility - common - ${project.parent.version} - compile - - - com.ghostchu - quickshop-bukkit - ${project.parent.version} - provided - - - diff --git a/compatibility/advancedchests/src/main/java/com/ghostchu/quickshop/compatibility/advancedchests/AdvancedChestsInventoryManager.java b/compatibility/advancedchests/src/main/java/com/ghostchu/quickshop/compatibility/advancedchests/AdvancedChestsInventoryManager.java deleted file mode 100644 index 8b2a10f95a..0000000000 --- a/compatibility/advancedchests/src/main/java/com/ghostchu/quickshop/compatibility/advancedchests/AdvancedChestsInventoryManager.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.ghostchu.quickshop.compatibility.advancedchests; - -import com.ghostchu.quickshop.api.inventory.InventoryWrapper; -import com.ghostchu.quickshop.api.inventory.InventoryWrapperManager; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.jetbrains.annotations.NotNull; -import us.lynuxcraft.deadsilenceiv.advancedchests.AdvancedChestsAPI; -import us.lynuxcraft.deadsilenceiv.advancedchests.chest.AdvancedChest; - -import java.util.UUID; - -public class AdvancedChestsInventoryManager implements InventoryWrapperManager { - - private final Main plugin; - - public AdvancedChestsInventoryManager(Main plugin) { - - this.plugin = plugin; - } - - /** - * Locate an Inventory with symbol link NOTICE: This can be call multiple times, and maybe - * multiple InventoryWrapper will exist in same time. You must be sure all wrapper can be process - * any request in any time. - * - * @param symbolLink symbol link that created by InventoryWrapperManager#mklink - * - * @return Symbol link - * - * @throws IllegalArgumentException If symbol link invalid - */ - @Override - public @NotNull InventoryWrapper locate(@NotNull String symbolLink) throws IllegalArgumentException { - - String[] spilt = symbolLink.split(";"); - if(spilt.length < 5) { - throw new IllegalArgumentException("Invalid symbol link: " + symbolLink); - } - UUID aChestUniqueId = UUID.fromString(spilt[0]); - String worldName = spilt[1]; - int x = Integer.parseInt(spilt[2]); - int y = Integer.parseInt(spilt[3]); - int z = Integer.parseInt(spilt[4]); - Location location = new Location(Bukkit.getWorld(worldName), x, y, z); - AdvancedChest achest = AdvancedChestsAPI.getChestManager().getAdvancedChest(location); - if(achest == null) { - throw new IllegalArgumentException("Cannot found AdvancedChest at " + location + " with UUID " + aChestUniqueId + "."); - } - return new AdvancedChestsWrapper(achest, plugin); - } - - /** - * Create a symbol link for storage. - * - * @param wrapper Storage wrapper - * - * @return Symbol Link that used for locate the Inventory - * - * @throws IllegalArgumentException If cannot create symbol link for target Inventory. - */ - @Override - public @NotNull String mklink(@NotNull InventoryWrapper wrapper) throws IllegalArgumentException { - - if(wrapper instanceof AdvancedChestsWrapper advancedChestsWrapper) { - AdvancedChest achest = advancedChestsWrapper.getAdvancedChest(); - Location achestLoc = achest.getLocation(); - return achest.getUniqueId().toString() + ";" + achestLoc.getWorld().getName() + ";" + achestLoc.getBlockX() + ";" + achestLoc.getBlockY() + ";" + achestLoc.getBlockZ(); - } - throw new IllegalArgumentException("Cannot create symbol link for target Inventory: " + wrapper.getClass().getName()); - } -} diff --git a/compatibility/advancedchests/src/main/java/com/ghostchu/quickshop/compatibility/advancedchests/AdvancedChestsWrapper.java b/compatibility/advancedchests/src/main/java/com/ghostchu/quickshop/compatibility/advancedchests/AdvancedChestsWrapper.java deleted file mode 100644 index 963110cf53..0000000000 --- a/compatibility/advancedchests/src/main/java/com/ghostchu/quickshop/compatibility/advancedchests/AdvancedChestsWrapper.java +++ /dev/null @@ -1,275 +0,0 @@ -package com.ghostchu.quickshop.compatibility.advancedchests; - -import com.ghostchu.quickshop.api.QuickShopAPI; -import com.ghostchu.quickshop.api.inventory.InventoryWrapper; -import com.ghostchu.quickshop.api.inventory.InventoryWrapperIterator; -import com.ghostchu.quickshop.api.inventory.InventoryWrapperManager; -import com.ghostchu.quickshop.api.inventory.InventoryWrapperType; -import com.ghostchu.quickshop.util.logger.Log; -import org.apache.commons.lang3.ArrayUtils; -import org.bukkit.Location; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import us.lynuxcraft.deadsilenceiv.advancedchests.chest.AdvancedChest; -import us.lynuxcraft.deadsilenceiv.advancedchests.chest.gui.page.ChestPage; - -import java.util.*; - -public class AdvancedChestsWrapper implements InventoryWrapper { - - private final Main plugin; - private final AdvancedChest advancedChest; - - public AdvancedChestsWrapper(AdvancedChest achest, Main plugin) { - - this.plugin = plugin; - this.advancedChest = achest; - } - - - /** - * Return the iterator for this inventory It's not thread-safe, please use that in main-thread - * - * @return the iterator for this inventory - */ - @Override - public @NotNull InventoryWrapperIterator iterator() { - - ItemStack[] stacks = new ItemStack[0]; - for(Map.Entry> entry : getAdvancedChestPages().entrySet()) { - stacks = ArrayUtils.addAll(stacks, entry.getValue().getItems()); - } - return InventoryWrapperIterator.ofItemStacks(stacks); - } - - /** - * Clear the inventory - */ - @Override - public void clear() { - - for(Map.Entry> entry : getAdvancedChestPages().entrySet()) { - ItemStack[] stacks = entry.getValue().getItems(); - Arrays.fill(stacks, null); - entry.getValue().setContent(Arrays.stream(stacks).toList()); - } - } - - @Override - public @NotNull ItemStack[] createSnapshot() { - - ItemStack[] stacks = new ItemStack[0]; - for(Map.Entry> entry : getAdvancedChestPages().entrySet()) { - int id = entry.getKey(); - ChestPage page = entry.getValue(); - int[] inputSlots = page.getInputSlots(); - ItemStack[] itemsCloneInPage = new ItemStack[inputSlots.length]; - for(int inputSlot : inputSlots) { - ItemStack stack = page.getBukkitInventory().getItem(inputSlot); - if(stack != null) { - itemsCloneInPage[inputSlot] = stack.clone(); - } else { - itemsCloneInPage[inputSlot] = null; - } - } - stacks = ArrayUtils.addAll(stacks, itemsCloneInPage); - } - return stacks; - } - - @NotNull - private Map> getAdvancedChestPages() { - //noinspection unchecked - return (Map>)advancedChest.getPages(); - } - - /** - * Gets the Inventory Wrapper Manager - * - * @return Wrapper Manager - */ - @Override - public @NotNull InventoryWrapperManager getWrapperManager() { - - return plugin.getManager(); - } - - /** - * Gets the block or entity belonging to the open inventory - * - * @return The holder of the inventory; null if it has no holder. - */ - @Override - public @Nullable InventoryHolder getHolder() { - - return new AdvancedChestsInventoryHolder(advancedChest); - } - - /** - * Gets the Inventory Type - * - * @return The Inventory Type - */ - @Override - public @NotNull InventoryWrapperType getInventoryType() { - - return InventoryWrapperType.PLUGIN; - } - - /** - * Get the location of the block or entity which corresponds to this inventory. May return null if - * this container was custom created or is a virtual / subcontainer. - * - * @return location or null if not applicable. - */ - @Override - public @Nullable Location getLocation() { - - return null; - } - - @Override - public boolean restoreSnapshot(@NotNull ItemStack[] snapshot) { - - setContents(snapshot); - return true; - } - - /** - * Set the contents of inventory - * - * @param itemStacks the contents you want to set - */ - @Override - public void setContents(ItemStack[] itemStacks) { - - Deque deque = new ArrayDeque<>(); - for(ItemStack itemStack : itemStacks) { - if(itemStack != null) { - deque.add(itemStack); - } - } - for(Map.Entry> entry : getAdvancedChestPages().entrySet()) { - ChestPage page = entry.getValue(); - int[] inputSlots = page.getInputSlots(); - for(int inputSlot : inputSlots) { - if(deque.isEmpty()) { - break; - } - ItemStack stack = deque.pop(); - if(stack.getType().isAir() || stack.getAmount() == 0) { - page.getBukkitInventory().setItem(inputSlot, null); - } else { - page.getBukkitInventory().setItem(inputSlot, stack); - } - } - } - } - - public AdvancedChest getAdvancedChest() { - - return advancedChest; - } - - @Override - public @NotNull Map addItem(ItemStack... itemStacks) { - - if(itemStacks.length == 0) { - return Collections.emptyMap(); - } - ItemStack[] contents = createSnapshot(); - InventoryWrapperIterator iterator = InventoryWrapperIterator.ofItemStacks(contents); - Map integerItemStackMap = new HashMap<>(); - AddProcess: - for(int i = 0; i < itemStacks.length; i++) { - ItemStack itemStackToAdd = itemStacks[i]; - while(iterator.hasNext()) { - ItemStack itemStack = iterator.next(); - if(itemStack == null) { - iterator.setCurrent(itemStackToAdd.clone()); - itemStackToAdd.setAmount(0); - continue AddProcess; - } else { - if(itemStack.isSimilar(itemStackToAdd)) { - int couldAdd = itemStack.getMaxStackSize() - Math.min(itemStack.getMaxStackSize(), itemStack.getAmount()); - int actuallyAdd = Math.min(itemStackToAdd.getAmount(), couldAdd); - itemStack.setAmount(itemStack.getAmount() + actuallyAdd); - int needsNow = itemStackToAdd.getAmount() - actuallyAdd; - itemStackToAdd.setAmount(needsNow); - iterator.setCurrent(itemStack); - if(needsNow == 0) { - continue AddProcess; - } - } - } - } - if(itemStackToAdd.getAmount() != 0) { - integerItemStackMap.put(i, itemStackToAdd); - } - } - setContents(contents); - return integerItemStackMap; - } - - @Override - public @NotNull Map removeItem(ItemStack... itemStacks) { - - if(itemStacks.length == 0) { - return Collections.emptyMap(); - } - ItemStack[] contents = createSnapshot(); - InventoryWrapperIterator iterator = InventoryWrapperIterator.ofItemStacks(contents); - Map integerItemStackMap = new HashMap<>(); - RemoveProcess: - for(int i = 0; i < itemStacks.length; i++) { - ItemStack itemStackToRemove = itemStacks[i]; - while(iterator.hasNext()) { - ItemStack itemStack = iterator.next(); - // TODO: Need lots of verification, it cause mismatch between items under non-Bukkit item matcher - if(itemStack != null && QuickShopAPI.getInstance().getItemMatcher().matches(itemStackToRemove, itemStack)) { - int couldRemove = itemStack.getAmount(); - int actuallyRemove = Math.min(itemStackToRemove.getAmount(), couldRemove); - itemStack.setAmount(itemStack.getAmount() - actuallyRemove); - int needsNow = itemStackToRemove.getAmount() - actuallyRemove; - Log.debug("couldRemove = " + couldRemove + " actuallyRemove = " + actuallyRemove + " needsNow = " + needsNow); - itemStackToRemove.setAmount(needsNow); - iterator.setCurrent(itemStack); - if(needsNow == 0) { - continue RemoveProcess; - } - } - } - if(itemStackToRemove.getAmount() != 0) { - integerItemStackMap.put(i, itemStackToRemove); - } - } - setContents(contents); - return integerItemStackMap; - } - - static class AdvancedChestsInventoryHolder implements InventoryHolder { - - private final AdvancedChest achest; - - public AdvancedChestsInventoryHolder(AdvancedChest achest) { - - this.achest = achest; - } - - public AdvancedChest getAdvancedChest() { - - return achest; - } - - @NotNull - @Override - public Inventory getInventory() { - - return null; - } - } - -} diff --git a/compatibility/advancedchests/src/main/java/com/ghostchu/quickshop/compatibility/advancedchests/Main.java b/compatibility/advancedchests/src/main/java/com/ghostchu/quickshop/compatibility/advancedchests/Main.java deleted file mode 100644 index b32ab93e91..0000000000 --- a/compatibility/advancedchests/src/main/java/com/ghostchu/quickshop/compatibility/advancedchests/Main.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.ghostchu.quickshop.compatibility.advancedchests; - -import com.ghostchu.quickshop.QuickShop; -import com.ghostchu.quickshop.api.event.ShopCreateEvent; -import com.ghostchu.quickshop.api.inventory.InventoryWrapper; -import com.ghostchu.quickshop.api.shop.Shop; -import com.ghostchu.quickshop.common.util.CommonUtil; -import com.ghostchu.quickshop.compatibility.CompatibilityModule; -import com.ghostchu.quickshop.obj.QUserImpl; -import org.bukkit.Location; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryCloseEvent; -import org.jetbrains.annotations.Nullable; -import us.lynuxcraft.deadsilenceiv.advancedchests.AdvancedChestsAPI; -import us.lynuxcraft.deadsilenceiv.advancedchests.chest.AdvancedChest; -import us.lynuxcraft.deadsilenceiv.advancedchests.events.ChestRemoveEvent; -import us.lynuxcraft.deadsilenceiv.advancedchests.utils.ChunkLocation; - -import java.util.Map; - -public final class Main extends CompatibilityModule implements Listener { - - public AdvancedChestsInventoryManager manager; - - public AdvancedChestsInventoryManager getManager() { - - return manager; - } - - - @Override - public void onLoad() { - - super.onLoad(); - manager = new AdvancedChestsInventoryManager(this); - getApi().getInventoryWrapperRegistry().register(this, manager); - } - - @Override - public void onEnable() { - - super.onEnable(); - } - - @Override - public void init() { - // There no init stuffs need to do - } - - @Nullable - public AdvancedChest locateAdvancedChest(Location location) { - - AdvancedChest result = AdvancedChestsAPI.getChestManager().getAdvancedChest(location); - if(result == null) { - result = AdvancedChestsAPI.getChestManager().getNonLoadableChest(location); - } - return result; - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onShopCreated(ShopCreateEvent event) { - - Location createdPos = event.getShop().getLocation(); - AdvancedChest advancedChests = locateAdvancedChest(createdPos); - if(advancedChests == null) { - return; - } - - if(!QuickShop.getPermissionManager().hasPermission(event.getCreator(), "quickshop.create.advancedchests")) { - event.setCancelled(true, getApi().getTextManager().of(event.getCreator(), "compat.advancedchests.permission-denied").forLocale()); - return; - } - Shop shop = event.getShop(); - shop.setInventory(new AdvancedChestsWrapper(advancedChests, this), manager); - getApi().getTextManager().of(event.getCreator(), "compat.advancedchests.created").send(); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onAdvancedChestRemoved(ChestRemoveEvent event) { - - AdvancedChest advancedChests = event.getChest(); - ChunkLocation chunkLocation = advancedChests.getChunkLocation(); - Map shops = getApi().getShopManager().getShops(chunkLocation.getWorld().getName(), chunkLocation.getX(), chunkLocation.getZ()); - if(shops == null) return; - for(Shop shop : shops.values()) { - InventoryWrapper inventory = shop.getInventory(); - if(inventory == null) continue; - if(inventory.getHolder() instanceof AdvancedChestsWrapper advancedChestsWrapper) { - if(advancedChestsWrapper.getAdvancedChest().getUniqueId().equals(advancedChests.getUniqueId())) { - recordDeletion(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "AdvancedChests", false), shop, "AdvancedChest Removed"); - getApi().getShopManager().deleteShop(shop); - } - } - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onInventoryClose(InventoryCloseEvent e) { - - AdvancedChest advancedChests = AdvancedChestsAPI.getInventoryManager().getAdvancedChest(e.getInventory()); - if(advancedChests == null) return; - for(Shop shop : getApi().getShopManager().getLoadedShops()) { - InventoryWrapper inventory = shop.getInventory(); - if(inventory == null) continue; - if(inventory instanceof AdvancedChestsWrapper advancedChestsWrapper) { - if(advancedChestsWrapper.getAdvancedChest().getUniqueId().equals(advancedChests.getUniqueId())) { - shop.setSignText(getApi().getTextManager().findRelativeLanguages(e.getPlayer())); - } - } - } - } -} diff --git a/compatibility/advancedchests/src/main/resources/config.yml b/compatibility/advancedchests/src/main/resources/config.yml deleted file mode 100644 index 1e42e54df5..0000000000 --- a/compatibility/advancedchests/src/main/resources/config.yml +++ /dev/null @@ -1,4 +0,0 @@ -messages: - description: Switch a shop to use owner's EnderChest inventory. - to-echest: Successfully linked this shop Inventory with your EnderChest! - to-chest: Successfully linked this shop Inventory to it's container! \ No newline at end of file diff --git a/compatibility/advancedchests/src/main/resources/plugin.yml b/compatibility/advancedchests/src/main/resources/plugin.yml deleted file mode 100644 index d4546e4ebb..0000000000 --- a/compatibility/advancedchests/src/main/resources/plugin.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: qscompat-${project.artifactId} -version: '${project.version}' -main: com.ghostchu.quickshop.compatibility.${project.artifactId}.Main -api-version: 1.18 -depend: [ AdvancedChests, QuickShop-Hikari ] -permissions: - quickshop.create.advancedchests: - description: Allows the player to create a shop on an AdvancedChests chest. - default: op \ No newline at end of file diff --git a/compatibility/advancedregionmarket/src/main/java/com/ghostchu/quickshop/compatibility/advancedregionmarket/Main.java b/compatibility/advancedregionmarket/src/main/java/com/ghostchu/quickshop/compatibility/advancedregionmarket/Main.java index 8182609195..c3d20ff174 100644 --- a/compatibility/advancedregionmarket/src/main/java/com/ghostchu/quickshop/compatibility/advancedregionmarket/Main.java +++ b/compatibility/advancedregionmarket/src/main/java/com/ghostchu/quickshop/compatibility/advancedregionmarket/Main.java @@ -1,7 +1,10 @@ package com.ghostchu.quickshop.compatibility.advancedregionmarket; import com.ghostchu.quickshop.api.shop.Shop; +import com.ghostchu.quickshop.common.util.CommonUtil; import com.ghostchu.quickshop.compatibility.CompatibilityModule; +import com.ghostchu.quickshop.obj.QUserImpl; +import com.ghostchu.quickshop.util.logging.container.ShopRemoveLog; import net.alex9849.arm.events.RemoveRegionEvent; import net.alex9849.arm.events.RestoreRegionEvent; import net.alex9849.arm.regions.Region; @@ -15,6 +18,7 @@ import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -33,33 +37,13 @@ public void onShopNeedDeletion(final RemoveRegionEvent event) { private void handleDeletion(final Region region) { - final Vector minPoint = region.getRegion().getMinPoint(); - final Vector maxPoint = region.getRegion().getMaxPoint(); - final World world = region.getRegionworld(); - final Set chuckLocations = new HashSet<>(); + final List shops = getApi().getShopManager().getAllShops(); + for(final Shop shop : shops) { - for(int x = minPoint.getBlockX(); x <= maxPoint.getBlockX() + 16; x += 16) { - for(int z = minPoint.getBlockZ(); z <= maxPoint.getBlockZ() + 16; z += 16) { - chuckLocations.add(world.getChunkAt(x >> 4, z >> 4)); - } - } - - - final HashMap shopMap = new HashMap<>(); - - for(final Chunk chunk : chuckLocations) { - final Map shopsInChunk = getApi().getShopManager().getShops(chunk); - if(shopsInChunk != null) { - shopMap.putAll(shopsInChunk); - } - } - for(final Map.Entry shopEntry : shopMap.entrySet()) { - final Location shopLocation = shopEntry.getKey(); + final Location shopLocation = shop.getLocation(); if(region.getRegion().contains(shopLocation.getBlockX(), shopLocation.getBlockY(), shopLocation.getBlockZ())) { - final Shop shop = shopEntry.getValue(); - if(shop != null) { - getApi().getShopManager().deleteShop(shop); - } + + getApi().getShopManager().deleteShop(shop); } } } diff --git a/compatibility/bentobox/src/main/java/com/ghostchu/quickshop/compatibility/bentobox/Main.java b/compatibility/bentobox/src/main/java/com/ghostchu/quickshop/compatibility/bentobox/Main.java index 7cbe0da198..116a57e190 100644 --- a/compatibility/bentobox/src/main/java/com/ghostchu/quickshop/compatibility/bentobox/Main.java +++ b/compatibility/bentobox/src/main/java/com/ghostchu/quickshop/compatibility/bentobox/Main.java @@ -53,6 +53,7 @@ public void onIslandKick(final world.bentobox.bentobox.api.events.team.TeamKickE if(!deleteShopOnLeave) { return; } + getShops(event.getIsland()).forEach(shop->{ if(event.getPlayerUUID().equals(shop.getOwner().getUniqueId())) { recordDeletion(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "BentoBox", false), shop, "Player " + event.getPlayerUUID() + " was kicked from the island"); diff --git a/compatibility/griefprevention/src/main/java/com/ghostchu/quickshop/compatibility/griefprevention/Main.java b/compatibility/griefprevention/src/main/java/com/ghostchu/quickshop/compatibility/griefprevention/Main.java index 0a18e0c0b5..84b734d18e 100644 --- a/compatibility/griefprevention/src/main/java/com/ghostchu/quickshop/compatibility/griefprevention/Main.java +++ b/compatibility/griefprevention/src/main/java/com/ghostchu/quickshop/compatibility/griefprevention/Main.java @@ -112,15 +112,11 @@ public void onClaimExpired(final ClaimExpirationEvent event) { // If it is the main claim, then we will delete all the shops that were inside of it. private void handleMainClaimUnclaimedOrExpired(final Claim claim, final String logMessage) { - for(final Chunk chunk : claim.getChunks()) { - final Map shops = getApi().getShopManager().getShops(chunk); - if(shops != null) { - for(final Shop shop : shops.values()) { - if(claim.contains(shop.getLocation(), false, false)) { - getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "GriefPrevention", false), String.format("[%s Integration]Shop %s deleted caused by [System] Claim/SubClaim Unclaimed/Expired: " + logMessage, this.getName(), shop), shop.saveToInfoStorage())); - getApi().getShopManager().deleteShop(shop); - } - } + final List shops = getApi().getShopManager().getAllShops(); + for(final Shop shop : shops) { + if(claim.contains(shop.getLocation(), false, false)) { + getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "GriefPrevention", false), String.format("[%s Integration]Shop %s deleted caused by [System] Claim/SubClaim Unclaimed/Expired: " + logMessage, this.getName(), shop), shop.saveToInfoStorage())); + getApi().getShopManager().deleteShop(shop); } } } @@ -130,16 +126,12 @@ private void handleMainClaimUnclaimedOrExpired(final Claim claim, final String l // A shop will be removed if the old claim contains it but the new claim doesn't. private void handleMainClaimResized(final Claim oldClaim, final Claim newClaim) { - for(final Chunk chunk : oldClaim.getChunks()) { - final Map shops = getApi().getShopManager().getShops(chunk); - if(shops != null) { - for(final Shop shop : shops.values()) { - if(oldClaim.contains(shop.getLocation(), false, false) && - !newClaim.contains(shop.getLocation(), false, false)) { - getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "GriefPrevention", false), String.format("[%s Integration]Shop %s deleted caused by [Single] Claim Resized: ", this.getName(), shop), shop.saveToInfoStorage())); - getApi().getShopManager().deleteShop(shop); - } - } + final List shops = getApi().getShopManager().getAllShops(); + for(final Shop shop : shops) { + if(oldClaim.contains(shop.getLocation(), false, false) && + !newClaim.contains(shop.getLocation(), false, false)) { + getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "GriefPrevention", false), String.format("[%s Integration]Shop %s deleted caused by [Single] Claim Resized: ", this.getName(), shop), shop.saveToInfoStorage())); + getApi().getShopManager().deleteShop(shop); } } } @@ -156,17 +148,13 @@ private void handleSubClaimResized(final Claim oldClaim, final Claim newClaim) { private void handleSubClaimResizedHelper(final Claim claimVerifyChunks, final Claim claimVerifyShop) { - for(final Chunk chunk : claimVerifyChunks.getChunks()) { - final Map shops = getApi().getShopManager().getShops(chunk); - if(shops != null) { - for(final Shop shop : shops.values()) { - if(!claimVerifyChunks.getOwnerID().equals(shop.getOwner().getUniqueId()) && - claimVerifyChunks.contains(shop.getLocation(), false, false) && - !claimVerifyShop.contains(shop.getLocation(), false, false)) { - getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "GriefPrevention", false), String.format("[%s Integration]Shop %s deleted caused by [Single] SubClaim Resized: ", this.getName(), shop), shop.saveToInfoStorage())); - getApi().getShopManager().deleteShop(shop); - } - } + final List shops = getApi().getShopManager().getAllShops(); + for(final Shop shop : shops) { + if(!claimVerifyChunks.getOwnerID().equals(shop.getOwner().getUniqueId()) && + claimVerifyChunks.contains(shop.getLocation(), false, false) && + !claimVerifyShop.contains(shop.getLocation(), false, false)) { + getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "GriefPrevention", false), String.format("[%s Integration]Shop %s deleted caused by [Single] SubClaim Resized: ", this.getName(), shop), shop.saveToInfoStorage())); + getApi().getShopManager().deleteShop(shop); } } } @@ -197,25 +185,20 @@ private void handleClaimTrustChanged(final Claim claim, final TrustChangedEvent if(event.isGiven()) { return; } - for(final Chunk chunk : claim.getChunks()) { - final Map shops = getApi().getShopManager().getShops(chunk); - if(shops == null) { + final List shops = getApi().getShopManager().getAllShops(); + for(final Shop shop : shops) { + if(claim.getOwnerID().equals(shop.getOwner().getUniqueId())) { continue; } - for(final Shop shop : shops.values()) { - if(claim.getOwnerID().equals(shop.getOwner().getUniqueId())) { - continue; - } - if(event.getIdentifier().equals(shop.getOwner().getUniqueIdIfRealPlayer().orElse(CommonUtil.getNilUniqueId()).toString())) { - getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(event.getChanger()), String.format("[%s Integration]Shop %s deleted caused by [Single] Claim/SubClaim Trust Changed", this.getName(), shop), shop.saveToInfoStorage())); - getApi().getShopManager().deleteShop(shop); - } else if(event.getIdentifier().contains(shop.getOwner().getUniqueIdIfRealPlayer().orElse(CommonUtil.getNilUniqueId()).toString())) { - getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(event.getChanger()), String.format("[%s Integration]Shop %s deleted caused by [Group] Claim/SubClaim Trust Changed", this.getName(), shop), shop.saveToInfoStorage())); - getApi().getShopManager().deleteShop(shop); - } else if("all".equals(event.getIdentifier()) || "public".equals(event.getIdentifier())) { - getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(event.getChanger()), String.format("[%s Integration]Shop %s deleted caused by [All/Public] Claim/SubClaim Trust Changed", this.getName(), shop), shop.saveToInfoStorage())); - getApi().getShopManager().deleteShop(shop); - } + if(event.getIdentifier().equals(shop.getOwner().getUniqueIdIfRealPlayer().orElse(CommonUtil.getNilUniqueId()).toString())) { + getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(event.getChanger()), String.format("[%s Integration]Shop %s deleted caused by [Single] Claim/SubClaim Trust Changed", this.getName(), shop), shop.saveToInfoStorage())); + getApi().getShopManager().deleteShop(shop); + } else if(event.getIdentifier().contains(shop.getOwner().getUniqueIdIfRealPlayer().orElse(CommonUtil.getNilUniqueId()).toString())) { + getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(event.getChanger()), String.format("[%s Integration]Shop %s deleted caused by [Group] Claim/SubClaim Trust Changed", this.getName(), shop), shop.saveToInfoStorage())); + getApi().getShopManager().deleteShop(shop); + } else if("all".equals(event.getIdentifier()) || "public".equals(event.getIdentifier())) { + getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(event.getChanger()), String.format("[%s Integration]Shop %s deleted caused by [All/Public] Claim/SubClaim Trust Changed", this.getName(), shop), shop.saveToInfoStorage())); + getApi().getShopManager().deleteShop(shop); } } } @@ -239,16 +222,12 @@ public void onClaimUnclaimed(final ClaimDeletedEvent event) { // But we will remove all the others. private void handleSubClaimUnclaimed(final Claim subClaim) { - for(final Chunk chunk : subClaim.getChunks()) { - final Map shops = getApi().getShopManager().getShops(chunk); - if(shops != null) { - for(final Shop shop : shops.values()) { - if(!subClaim.getOwnerID().equals(shop.getOwner().getUniqueId()) && - subClaim.contains(shop.getLocation(), false, false)) { - getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "GriefPrevention", false), String.format("[%s Integration]Shop %s deleted caused by [Single] SubClaim Unclaimed", this.getName(), shop), shop.saveToInfoStorage())); - getApi().getShopManager().deleteShop(shop); - } - } + final List shops = getApi().getShopManager().getAllShops(); + for(final Shop shop : shops) { + if(!subClaim.getOwnerID().equals(shop.getOwner().getUniqueId()) && + subClaim.contains(shop.getLocation(), false, false)) { + getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "GriefPrevention", false), String.format("[%s Integration]Shop %s deleted caused by [Single] SubClaim Unclaimed", this.getName(), shop), shop.saveToInfoStorage())); + getApi().getShopManager().deleteShop(shop); } } } @@ -308,16 +287,13 @@ public void onSubClaimCreated(final ClaimCreatedEvent event) { if(event.getClaim().parent == null) { return; } - for(final Chunk chunk : event.getClaim().getChunks()) { - final Map shops = getApi().getShopManager().getShops(chunk); - if(shops != null) { - for(final Shop shop : shops.values()) { - if(!event.getClaim().getOwnerID().equals(shop.getOwner().getUniqueId()) && - event.getClaim().contains(shop.getLocation(), false, false)) { - getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "GriefPrevention", false), String.format("[%s Integration]Shop %s deleted caused by [Single] SubClaim Created", this.getName(), shop), shop.saveToInfoStorage())); - getApi().getShopManager().deleteShop(shop); - } - } + + final List shops = getApi().getShopManager().getAllShops(); + for(final Shop shop : shops) { + if(!event.getClaim().getOwnerID().equals(shop.getOwner().getUniqueId()) && + event.getClaim().contains(shop.getLocation(), false, false)) { + getApi().logEvent(new ShopRemoveLog(QUserImpl.createFullFilled(CommonUtil.getNilUniqueId(), "GriefPrevention", false), String.format("[%s Integration]Shop %s deleted caused by [Single] SubClaim Created", this.getName(), shop), shop.saveToInfoStorage())); + getApi().getShopManager().deleteShop(shop); } } } diff --git a/compatibility/nocheatplus/.gitignore b/compatibility/nocheatplus/.gitignore deleted file mode 100644 index 4788b4b454..0000000000 --- a/compatibility/nocheatplus/.gitignore +++ /dev/null @@ -1,113 +0,0 @@ -# User-specific stuff -.idea/ - -*.iml -*.ipr -*.iws - -# IntelliJ -out/ - -# Compiled class file -*.class - -# Log file -*.log - -# BlueJ files -*.ctxt - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -# Windows thumbnail cache files -Thumbs.db -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -target/ - -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next - -release.properties -dependency-reduced-pom.xml -buildNumber.properties -.mvn/timing.properties -.mvn/wrapper/maven-wrapper.jar -.flattened-pom.xml - -# Common working directory -run/ diff --git a/compatibility/nocheatplus/pom.xml b/compatibility/nocheatplus/pom.xml deleted file mode 100644 index b286ebf9b4..0000000000 --- a/compatibility/nocheatplus/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - 4.0.0 - - com.ghostchu - quickshop-hikari - 4.1.0.3 - ../../pom.xml - - com.ghostchu.quickshop.compatibility - nocheatplus - takari-jar - - Compat-NoCheatPlus - - - UTF-8 - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.apache.maven.plugins - maven-shade-plugin - - - - - - src/main/resources - true - - - - - - - org.spigotmc - spigot-api - - - fr.neatmonster - nocheatplus - 3.17-SNAPSHOT - provided - - - com.ghostchu - quickshop-bukkit - ${project.parent.version} - provided - - - com.ghostchu.quickshop.compatibility - common - ${project.parent.version} - compile - - - diff --git a/compatibility/nocheatplus/src/main/java/com/ghostchu/quickshop/compatibility/nocheatplus/Main.java b/compatibility/nocheatplus/src/main/java/com/ghostchu/quickshop/compatibility/nocheatplus/Main.java deleted file mode 100644 index 8d6f145ee5..0000000000 --- a/compatibility/nocheatplus/src/main/java/com/ghostchu/quickshop/compatibility/nocheatplus/Main.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.ghostchu.quickshop.compatibility.nocheatplus; - -import com.ghostchu.quickshop.api.event.ProtectionCheckStatus; -import com.ghostchu.quickshop.api.event.ShopProtectionCheckEvent; -import com.ghostchu.quickshop.compatibility.CompatibilityModule; -import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; - -public final class Main extends CompatibilityModule implements Listener { - - @Override - public void init() { - - } - - @EventHandler(ignoreCancelled = true) - public void onFakeEventBegin(ShopProtectionCheckEvent event) { - - if(event.getStatus() == ProtectionCheckStatus.BEGIN) { - NCPExemptionManager.exemptPermanently(event.getPlayer().getUniqueId()); - } else if(event.getStatus() == ProtectionCheckStatus.END) { - NCPExemptionManager.unexempt(event.getPlayer().getUniqueId()); - } - } -} diff --git a/compatibility/nocheatplus/src/main/resources/plugin.yml b/compatibility/nocheatplus/src/main/resources/plugin.yml deleted file mode 100644 index 9efda81ac5..0000000000 --- a/compatibility/nocheatplus/src/main/resources/plugin.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: qscompat-${project.artifactId} -version: '${project.version}' -main: com.ghostchu.quickshop.compatibility.${project.artifactId}.Main -api-version: 1.18 -depend: - - NoCheatPlus - - QuickShop-Hikari diff --git a/compatibility/nova/.gitignore b/compatibility/nova/.gitignore deleted file mode 100644 index 4788b4b454..0000000000 --- a/compatibility/nova/.gitignore +++ /dev/null @@ -1,113 +0,0 @@ -# User-specific stuff -.idea/ - -*.iml -*.ipr -*.iws - -# IntelliJ -out/ - -# Compiled class file -*.class - -# Log file -*.log - -# BlueJ files -*.ctxt - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -# Windows thumbnail cache files -Thumbs.db -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - -target/ - -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next - -release.properties -dependency-reduced-pom.xml -buildNumber.properties -.mvn/timing.properties -.mvn/wrapper/maven-wrapper.jar -.flattened-pom.xml - -# Common working directory -run/ diff --git a/compatibility/nova/pom.xml b/compatibility/nova/pom.xml deleted file mode 100644 index f48b7733b5..0000000000 --- a/compatibility/nova/pom.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - 4.0.0 - - com.ghostchu - quickshop-hikari - 1.1.3.4 - ../../pom.xml - - com.ghostchu.quickshop.compatibility - nova - takari-jar - - Compat-Nova - - - 17 - UTF-8 - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - org.apache.maven.plugins - maven-shade-plugin - - - - - src/main/resources - true - - - - - - - org.spigotmc - spigot-api - - - com.ghostchu - quickshop-bukkit - ${project.parent.version} - provided - - - com.ghostchu.quickshop.compatibility - common - ${project.parent.version} - compile - - - xyz.xenondevs.nova - Nova - 0.8.6 - system - ${project.basedir}/lib/Nova-0.8.6.jar - - - diff --git a/compatibility/nova/src/main/java/com/ghostchu/quickshop/compatibility/nova/Main.java b/compatibility/nova/src/main/java/com/ghostchu/quickshop/compatibility/nova/Main.java deleted file mode 100644 index c7ac2cf562..0000000000 --- a/compatibility/nova/src/main/java/com/ghostchu/quickshop/compatibility/nova/Main.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file is a part of project QuickShop, the name is Nova.java - * Copyright (C) Ghost_chu and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -package com.ghostchu.quickshop.compatibility.nova; - -import com.ghostchu.quickshop.api.shop.AbstractDisplayItem; -import com.ghostchu.quickshop.api.shop.Shop; -import com.ghostchu.quickshop.compatibility.CompatibilityModule; -import org.bukkit.Location; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.event.Listener; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import xyz.xenondevs.nova.api.protection.ProtectionIntegration; - -public final class Main extends CompatibilityModule implements Listener, ProtectionIntegration { - - @Override - public boolean canBreak(@NotNull OfflinePlayer offlinePlayer, @Nullable ItemStack itemStack, @NotNull Location location) { - - Shop shop = getApi().getShopManager().getShopIncludeAttached(location); - if(shop == null) { return true; } - return shop.getOwner().equals(offlinePlayer.getUniqueId()); - } - - @Override - public boolean canHurtEntity(@NotNull OfflinePlayer offlinePlayer, @NotNull Entity entity, @Nullable ItemStack itemStack) { - - if(itemStack != null) { - if(AbstractDisplayItem.checkIsGuardItemStack(itemStack)) { return false; } - } - if(entity instanceof Item item) { - return !AbstractDisplayItem.checkIsGuardItemStack(item.getItemStack()); - } - return true; // We don't care that - } - - @Override - public boolean canInteractWithEntity(@NotNull OfflinePlayer offlinePlayer, @NotNull Entity entity, @Nullable ItemStack itemStack) { - - if(itemStack != null) { - if(AbstractDisplayItem.checkIsGuardItemStack(itemStack)) { return false; } - } - if(entity instanceof Item item) { - return !AbstractDisplayItem.checkIsGuardItemStack(item.getItemStack()); - } - return true; // We don't care that - } - - @Override - public boolean canPlace(@NotNull OfflinePlayer offlinePlayer, @NotNull ItemStack itemStack, @NotNull Location location) { - - Shop shop = getApi().getShopManager().getShopIncludeAttached(location); - if(shop == null) { return true; } - return shop.getOwner().equals(offlinePlayer.getUniqueId()); - } - - @Override - public boolean canUseBlock(@NotNull OfflinePlayer offlinePlayer, @Nullable ItemStack itemStack, @NotNull Location location) { - - Shop shop = getApi().getShopManager().getShopIncludeAttached(location); - if(shop == null) { return true; } - return shop.getOwner().equals(offlinePlayer.getUniqueId()); - } - - @Override - public boolean canUseItem(@NotNull OfflinePlayer offlinePlayer, @NotNull ItemStack itemStack, @NotNull Location location) { - - Shop shop = getApi().getShopManager().getShopIncludeAttached(location); - if(shop == null) { return true; } - return shop.getOwner().equals(offlinePlayer.getUniqueId()); - } - - public void init() { - // There no init stuffs need to do - } - - @Override - public void onEnable() { - - xyz.xenondevs.nova.api.Nova.getNova().registerProtectionIntegration(this); - super.onEnable(); - } -} diff --git a/compatibility/nova/src/main/resources/config.yml b/compatibility/nova/src/main/resources/config.yml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/compatibility/nova/src/main/resources/plugin.yml b/compatibility/nova/src/main/resources/plugin.yml deleted file mode 100644 index a789abdede..0000000000 --- a/compatibility/nova/src/main/resources/plugin.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: qscompat-${project.artifactId} -version: '${project.version}' -main: com.ghostchu.quickshop.compatibility.${project.artifactId}.Main -api-version: 1.18 -depend: [ Nova, QuickShop-Hikari ] diff --git a/pom.xml b/pom.xml index a0f5975f4b..7faf0114db 100644 --- a/pom.xml +++ b/pom.xml @@ -415,7 +415,6 @@ compatibility/bungeecord compatibility/velocity compatibility/clearlag - compatibility/worldguard compatibility/worldedit compatibility/openinv @@ -446,7 +445,6 @@ addon/bluemap addon/displaycontrol addon/reremake-migrator - diff --git a/quickshop-api/src/main/java/com/ghostchu/quickshop/api/database/bean/DataRecord.java b/quickshop-api/src/main/java/com/ghostchu/quickshop/api/database/bean/DataRecord.java index 1538832c65..927776e6bf 100644 --- a/quickshop-api/src/main/java/com/ghostchu/quickshop/api/database/bean/DataRecord.java +++ b/quickshop-api/src/main/java/com/ghostchu/quickshop/api/database/bean/DataRecord.java @@ -26,6 +26,9 @@ public interface DataRecord { @NotNull String getItem(); + @NotNull + String getEncoded(); + @Nullable String getName(); diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/database/DataTables.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/database/DataTables.java index 395d130401..1e584e766f 100644 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/database/DataTables.java +++ b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/database/DataTables.java @@ -27,7 +27,7 @@ public enum DataTables { table.addColumn("owner", "VARCHAR(128) NOT NULL"); // SHOP DATA OWNER (ALL-ZERO if this is a server shop) table.addColumn("item", "TEXT NOT NULL"); // SHOP DATA ITEM INFO - //table.addColumn("new_item", "TEXT NOT NULL"); // SHOP DATA ITEM INFO + table.addColumn("encoded", "TEXT NOT NULL"); // SHOP DATA ITEM INFO table.addColumn("name", "TEXT"); // SHOP NAME table.addColumn("type", "INT NOT NULL DEFAULT 0"); // SHOP TYPE (see ShopType enum) diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/database/SimpleDatabaseHelperV2.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/database/SimpleDatabaseHelperV2.java index ab27125b72..1c0bd8f728 100644 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/database/SimpleDatabaseHelperV2.java +++ b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/database/SimpleDatabaseHelperV2.java @@ -59,7 +59,7 @@ public class SimpleDatabaseHelperV2 implements DatabaseHelper { @NotNull private final String prefix; - private final int LATEST_DATABASE_VERSION = 16; + private final int LATEST_DATABASE_VERSION = 17; public SimpleDatabaseHelperV2(@NotNull final QuickShop plugin, @NotNull final SQLManager manager, @NotNull final String prefix) throws Exception { @@ -213,14 +213,14 @@ private void upgradeBenefit() { return manager; } - private void addNewItemColumn() { + private void addEncodedColumn() { fastBackup(); try { getManager().alterTable(DataTables.DATA.getName()) - .addColumn("new_item", "TEXT NOT NULL") + .addColumn("encoded", "TEXT NOT NULL") .execute(); } catch(final SQLException e) { - Log.debug("Failed to add new_item " + DataTables.DATA.getName() + "! Err:" + e.getMessage()); + Log.debug("Failed to add encoded " + DataTables.DATA.getName() + "! Err:" + e.getMessage()); } } @@ -936,7 +936,7 @@ public void upgrade() { int currentDatabaseVersion = parent.getDatabaseVersion(); if(currentDatabaseVersion == -1) { - currentDatabaseVersion = 11; + currentDatabaseVersion = 17; } if(currentDatabaseVersion > parent.LATEST_DATABASE_VERSION) { throw new IllegalStateException("The database version is newer than this build supported."); @@ -990,11 +990,12 @@ public void upgrade() { parent.makeBackup(); currentDatabaseVersion = 16; } - /*if(currentDatabaseVersion == 16) { + + if(currentDatabaseVersion == 16) { logger.info("Data upgrading: Creating a new column... new_item for enhanced item storage."); - parent.addNewItemColumn(); + parent.addEncodedColumn(); currentDatabaseVersion = 17; - }*/ + } parent.setDatabaseVersion(currentDatabaseVersion).join(); } diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/database/bean/SimpleDataRecord.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/database/bean/SimpleDataRecord.java index 3572b96caf..4f7a42a756 100644 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/database/bean/SimpleDataRecord.java +++ b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/database/bean/SimpleDataRecord.java @@ -20,6 +20,7 @@ public class SimpleDataRecord implements DataRecord { private final QUser owner; private final String item; + private final String encoded; private final String name; private final int type; private final String currency; @@ -35,11 +36,15 @@ public class SimpleDataRecord implements DataRecord { private final String benefit; - public SimpleDataRecord(final QUser owner, final String item, final String name, final int type, final String currency, final double price, final boolean unlimited, final boolean hologram, final QUser taxAccount, final String permissions, final String extra, final String inventoryWrapper, final String inventorySymbolLink, final Date createTime, final String benefit) { + public SimpleDataRecord(final QUser owner, final String item, final String encoded, final String name, + final int type, final String currency, final double price, final boolean unlimited, + final boolean hologram, final QUser taxAccount, final String permissions, + final String extra, final String inventoryWrapper, final String inventorySymbolLink, + final Date createTime, final String benefit) { this.owner = owner; this.item = item; - //this.newItem = newItem; + this.encoded = encoded; this.name = name; this.type = type; this.currency = currency; @@ -59,7 +64,7 @@ public SimpleDataRecord(final PlayerFinder finder, final ResultSet set) throws S this.owner = QUserImpl.deserialize(finder, set.getString("owner"), QuickExecutor.getSecondaryProfileIoExecutor()); this.item = set.getString("item"); - //this.newItem = set.getString("new_item"); + this.encoded = set.getString("encoded"); this.name = set.getString("name"); this.type = set.getInt("type"); this.currency = set.getString("currency"); @@ -90,7 +95,7 @@ public Map generateParams() { final Map map = new LinkedHashMap<>(); map.put("owner", owner.serialize()); map.put("item", item); - //map.put("new_item", newItem); + map.put("encoded", encoded); map.put("name", name); map.put("type", type); map.put("currency", currency); @@ -147,6 +152,12 @@ public String getCurrency() { return item; } + @Override + public @NotNull String getEncoded() { + + return encoded; + } + @Override public String getName() { diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/ContainerShop.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/ContainerShop.java index c98be6116d..b8da49ffb9 100644 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/ContainerShop.java +++ b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/ContainerShop.java @@ -4,18 +4,18 @@ import com.ghostchu.quickshop.QuickShop; import com.ghostchu.quickshop.ServiceInjector; import com.ghostchu.quickshop.api.economy.Benefit; -import com.ghostchu.quickshop.api.event.modification.ShopAuthorizeCalculateEvent; -import com.ghostchu.quickshop.api.event.modification.ShopClickEvent; -import com.ghostchu.quickshop.api.event.inventory.ShopInventoryCalculateEvent; -import com.ghostchu.quickshop.api.event.inventory.ShopInventoryChangedEvent; import com.ghostchu.quickshop.api.event.details.ShopItemChangeEvent; -import com.ghostchu.quickshop.api.event.modification.ShopLoadEvent; import com.ghostchu.quickshop.api.event.details.ShopOwnerNameGettingEvent; import com.ghostchu.quickshop.api.event.details.ShopPlayerGroupSetEvent; -import com.ghostchu.quickshop.api.event.general.ShopSignUpdateEvent; +import com.ghostchu.quickshop.api.event.details.ShopTypeChangeEvent; import com.ghostchu.quickshop.api.event.economy.ShopTaxAccountChangeEvent; import com.ghostchu.quickshop.api.event.economy.ShopTaxAccountGettingEvent; -import com.ghostchu.quickshop.api.event.details.ShopTypeChangeEvent; +import com.ghostchu.quickshop.api.event.general.ShopSignUpdateEvent; +import com.ghostchu.quickshop.api.event.inventory.ShopInventoryCalculateEvent; +import com.ghostchu.quickshop.api.event.inventory.ShopInventoryChangedEvent; +import com.ghostchu.quickshop.api.event.modification.ShopAuthorizeCalculateEvent; +import com.ghostchu.quickshop.api.event.modification.ShopClickEvent; +import com.ghostchu.quickshop.api.event.modification.ShopLoadEvent; import com.ghostchu.quickshop.api.event.modification.ShopUnloadEvent; import com.ghostchu.quickshop.api.event.modification.ShopUpdateEvent; import com.ghostchu.quickshop.api.inventory.InventoryWrapper; @@ -1629,6 +1629,7 @@ public void setShopBenefit(@NotNull final Benefit benefit) { return new SimpleDataRecord( getOwner(), Util.serialize(getItem()), + plugin.getPlatform().encodeStack(getItem()), getShopName(), getShopType().toID(), getCurrency(), diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/ShopLoader.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/ShopLoader.java index 9c9f9855e0..e2657a6026 100644 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/ShopLoader.java +++ b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/ShopLoader.java @@ -107,7 +107,7 @@ public void loadShops(@Nullable final String worldName) { Util.mainThreadRun(()->shopsLoadInNextTick.forEach(shop->{ try { plugin.getShopManager().loadShop(shop); - } catch(Throwable e) { + } catch(final Throwable e) { plugin.logger().error("Failed to load shop {}.", shop.getShopId(), e); } })); @@ -170,12 +170,14 @@ private ShopLoadResult loadSingleShop(final InfoRecord infoRecord, final DataRec final Shop shop; final DataRawDatabaseInfo rawInfo = new DataRawDatabaseInfo(dataRecord); final Location location = new Location(Bukkit.getWorld(infoRecord.getWorld()), x, y, z); + + final ItemStack stack = (rawInfo.getNewItem() == null)? rawInfo.getItem() : rawInfo.getNewItem(); try { shop = new ContainerShop(plugin, infoRecord.getShopId(), location, rawInfo.getPrice(), - rawInfo.getItem(), + stack, rawInfo.getOwner(), rawInfo.isUnlimited(), rawInfo.getType(), @@ -188,7 +190,7 @@ private ShopLoadResult loadSingleShop(final InfoRecord infoRecord, final DataRec rawInfo.getName(), rawInfo.getPermissions(), rawInfo.getBenefits()); - } catch(Exception e) { + } catch(final Exception e) { if(e instanceof IllegalStateException) { plugin.logger().warn("Failed to load the shop, skipping...", e); } @@ -310,6 +312,7 @@ public static class DataRawDatabaseInfo { private String invSymbolLink; private long createTime; private ItemStack item; + private ItemStack newItem; private boolean needUpdate = false; private Benefit benefits; @@ -334,6 +337,7 @@ public static class DataRawDatabaseInfo { this.invWrapper = dataRecord.getInventoryWrapper(); this.benefits = SimpleBenefit.deserialize(dataRecord.getBenefit()); final String permissionJson = dataRecord.getPermissions(); + if(!StringUtils.isEmpty(permissionJson) && CommonUtil.isJson(permissionJson)) { final Type typeToken = new TypeToken>() { }.getType(); @@ -341,7 +345,12 @@ public static class DataRawDatabaseInfo { } else { this.permissions = new HashMap<>(); } + this.item = deserializeItem(dataRecord.getItem()); + + if(!dataRecord.getEncoded().isEmpty()) { + this.newItem = QuickShop.getInstance().getPlatform().decodeStack(dataRecord.getEncoded()); + } this.extra = deserializeExtra(extraStr); } @@ -349,7 +358,7 @@ public static class DataRawDatabaseInfo { try { return Util.deserialize(itemConfig); - } catch(Exception e) { + } catch(final Exception e) { QuickShop.getInstance().logger().warn("Failed load shop data, because target config can't deserialize the ItemStack", e); Log.debug("Failed to load data to the ItemStack: " + itemConfig); return null; @@ -364,7 +373,7 @@ public static class DataRawDatabaseInfo { YamlConfiguration yamlConfiguration = new YamlConfiguration(); try { yamlConfiguration.loadFromString(extraString); - } catch(InvalidConfigurationException e) { + } catch(final InvalidConfigurationException e) { yamlConfiguration = new YamlConfiguration(); needUpdate = true; } @@ -391,7 +400,7 @@ public static class ShopDatabaseInfo { try { this.shopId = origin.getInt("id"); this.dataId = origin.getInt("data"); - } catch(Exception ex) { + } catch(final Exception ex) { ex.printStackTrace(); } } @@ -415,7 +424,7 @@ public static class ShopMappingInfo { this.y = origin.getInt("y"); this.z = origin.getInt("z"); this.world = origin.getString("world"); - } catch(Exception ex) { + } catch(final Exception ex) { ex.printStackTrace(); } } diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/inventory/BukkitListenerDrivenInventoryListener.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/inventory/BukkitListenerDrivenInventoryListener.java deleted file mode 100644 index d2ffebbae4..0000000000 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/inventory/BukkitListenerDrivenInventoryListener.java +++ /dev/null @@ -1,15 +0,0 @@ -//package com.ghostchu.quickshop.shop.inventory; -// -//import org.bukkit.Location; -//import org.jetbrains.annotations.ApiStatus; -// -//@ApiStatus.Internal -//public interface BukkitListenerDrivenInventoryListener { -// // This listener to fix for: -// //https://discord.com/channels/942378696415797298/942378809632649256/1156394450570969089 -// //https://discord.com/channels/942378696415797298/942378809632649256/1207787041992216586 -// //https://discord.com/channels/942378696415797298/942378809632649256/1207783977352437881 -// //https://discord.com/channels/942378696415797298/942378809632649256/1208807999003562044 -// //https://discord.com/channels/942378696415797298/942378809632649256/1221584126432514110 -// boolean notify(Location updated); // May call from async thread -//} diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/inventory/BukkitListenerDrivenInventoryWrapper.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/inventory/BukkitListenerDrivenInventoryWrapper.java deleted file mode 100644 index d368e582e3..0000000000 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/inventory/BukkitListenerDrivenInventoryWrapper.java +++ /dev/null @@ -1,127 +0,0 @@ -//package com.ghostchu.quickshop.shop.inventory; -// -//import com.ghostchu.quickshop.QuickShop; -//import com.ghostchu.quickshop.api.inventory.InventoryWrapper; -//import com.ghostchu.quickshop.api.inventory.InventoryWrapperIterator; -//import com.ghostchu.quickshop.api.inventory.InventoryWrapperManager; -//import com.ghostchu.quickshop.api.inventory.InventoryWrapperType; -//import com.ghostchu.quickshop.common.util.JsonUtil; -//import org.bukkit.Location; -//import org.bukkit.inventory.Inventory; -//import org.bukkit.inventory.InventoryHolder; -//import org.bukkit.inventory.ItemStack; -//import org.jetbrains.annotations.ApiStatus; -//import org.jetbrains.annotations.NotNull; -//import org.jetbrains.annotations.Nullable; -// -//import java.util.HashMap; -//import java.util.Map; -// -//@ApiStatus.Internal -//public class BukkitListenerDrivenInventoryWrapper implements InventoryWrapper, BukkitListenerDrivenInventoryListener { -// private final Inventory inventory; -// private final InventoryWrapperManager manager; -// private final Location location; -// private boolean needUpdate; -// -// public BukkitListenerDrivenInventoryWrapper(@NotNull Inventory inventory, Location location) { -// this.inventory = inventory; -// this.manager = QuickShop.getInstance().getInventoryWrapperManager(); -// this.location = location.clone(); -// QuickShop.getInstance().getInvWrapperUpdateManager().registerListener(this); -// } -// -// @Override -// public boolean notify(Location updated) { -// if (location.equals(updated)) { -// needUpdate = true; -// return true; -// } -// return false; -// } -// -// -// @Override -// public @NotNull InventoryWrapperIterator iterator() { -// return InventoryWrapperIterator.ofBukkitInventory(inventory); -// } -// -// @Override -// public void clear() { -// inventory.clear(); -// } -// -// @Override -// public @NotNull ItemStack[] createSnapshot() { -// ItemStack[] content = this.inventory.getContents(); -// ItemStack[] snapshot = new ItemStack[content.length]; -// for (int i = 0; i < content.length; i++) { -// if (content[i] != null) { -// snapshot[i] = content[i].clone(); -// } else { -// snapshot[i] = null; -// } -// -// } -// return snapshot; -// } -// -// @Override -// public @NotNull InventoryWrapperManager getWrapperManager() { -// return this.manager; -// } -// -// @Override -// public InventoryHolder getHolder() { -// return inventory.getHolder(); -// } -// -// @Override -// public @NotNull InventoryWrapperType getInventoryType() { -// return InventoryWrapperType.BUKKIT; -// } -// -// @Override -// public @Nullable Location getLocation() { -// return inventory.getLocation(); -// } -// -// @Override -// public boolean isValid() { -// if (this.inventory.getHolder() != null) { -// return true; -// } else { -// return this.inventory instanceof InventoryHolder; -// } -// } -// -// @Override -// public boolean isNeedUpdate() { -// return needUpdate; -// } -// -// @Override -// public boolean restoreSnapshot(@NotNull ItemStack[] snapshot) { -// this.inventory.setContents(snapshot); -// return true; -// } -// -// @Override -// public @NotNull Map addItem(ItemStack... itemStacks) { -// return inventory.addItem(itemStacks); -// } -// -// @Override -// public void setContents(ItemStack[] itemStacks) { -// inventory.setStorageContents(itemStacks); -// } -// -// @Override -// public String toString() { -// Map map = new HashMap<>(); -// map.put("inventory", inventory.toString()); -// map.put("location", location.toString()); -// map.put("inventoryType", inventory.getClass().getName()); -// return JsonUtil.getGson().toJson(map); -// } -//} diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/inventory/InventoryWrapperUpdateManager.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/inventory/InventoryWrapperUpdateManager.java deleted file mode 100644 index dc3d267ebe..0000000000 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/shop/inventory/InventoryWrapperUpdateManager.java +++ /dev/null @@ -1,75 +0,0 @@ -//package com.ghostchu.quickshop.shop.inventory; -// -//import com.ghostchu.quickshop.QuickShop; -//import com.ghostchu.quickshop.listener.AbstractQSListener; -//import com.ghostchu.quickshop.util.Util; -//import com.ghostchu.quickshop.util.logger.Log; -//import com.google.common.collect.Lists; -//import org.bukkit.Bukkit; -//import org.bukkit.Location; -//import org.bukkit.Material; -//import org.bukkit.block.Block; -//import org.bukkit.block.BlockState; -//import org.bukkit.event.EventHandler; -//import org.bukkit.event.EventPriority; -//import org.bukkit.event.block.BlockPlaceEvent; -//import org.bukkit.inventory.DoubleChestInventory; -//import org.bukkit.inventory.InventoryHolder; -// -//import java.lang.ref.WeakReference; -//import java.util.ArrayList; -//import java.util.Iterator; -//import java.util.List; -// -//public class InventoryWrapperUpdateManager extends AbstractQSListener { -// private final List checkList = Lists.newArrayList(Material.CHEST, Material.TRAPPED_CHEST); -// private final List> registeredListeners = new ArrayList<>(); -// -// public InventoryWrapperUpdateManager(QuickShop plugin) { -// super(plugin); -// } -// -// private synchronized void notifyAllListeners(Location... locs) { -// synchronized (registeredListeners) { -// Iterator> it = registeredListeners.iterator(); -// while (it.hasNext()) { -// WeakReference ref = it.next(); -// BukkitListenerDrivenInventoryListener listener = ref.get(); -// if (listener == null) { -// it.remove(); -// continue; -// } -// for (Location loc : locs) { -// try { -// if (listener.notify(loc)) { -// Log.debug("Successfully notified listener " + listener + " which need to be update"); -// } -// } catch (Throwable e) { -// plugin.logger().warn("Failed to notify inventory possible update to listener: {}", listener, e); -// } -// } -// } -// } -// } -// -// public void registerListener(BukkitListenerDrivenInventoryListener listener) { -// this.registeredListeners.add(new WeakReference<>(listener)); -// } -// -// @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) -// public void onInventoryRelatedBlockPlaced(BlockPlaceEvent event) { -// Block placed = event.getBlockPlaced(); -// if (!checkList.contains(placed.getType())) { -// return; -// } -// // Delay 1 tick to allow chest merge -// QuickShop.folia().getImpl().runLater(() -> { -// BlockState state = placed.getState(); -// if (state instanceof InventoryHolder holder) { -// if (holder.getInventory() instanceof DoubleChestInventory doubleChestInventory) { -// Util.asyncThreadRun(() -> notifyAllListeners(doubleChestInventory.getLeftSide().getLocation(), doubleChestInventory.getRightSide().getLocation())); -// } -// } -// }, 1L); -// } -//} diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/util/paste/HelpChatPastebinPaster.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/util/paste/HelpChatPastebinPaster.java deleted file mode 100644 index f15a79fbd7..0000000000 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/util/paste/HelpChatPastebinPaster.java +++ /dev/null @@ -1,80 +0,0 @@ -///* -// * This file is a part of project QuickShop, the name is HelpChatPastebinPaster.java -// * Copyright (C) Ghost_chu and contributors -// * -// * This program is free software: you can redistribute it and/or modify it -// * under the terms of the GNU General Public License as published by the -// * Free Software Foundation, either version 3 of the License, or -// * (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, but WITHOUT -// * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// * for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program. If not, see . -// * -// */ -// -//package com.ghostchu.quickshop.util.paste; -// -//import com.ghostchu.quickshop.common.util.JsonUtil; -//import kong.unirest.HttpResponse; -//import kong.unirest.Unirest; -//import lombok.AllArgsConstructor; -//import lombok.Data; -//import lombok.NoArgsConstructor; -//import org.jetbrains.annotations.NotNull; -// -//import java.io.IOException; -// -///** -// * Paste the paste through https://paste.helpch.at/ -// * -// * @author Ghost_chu -// */ -//public class HelpChatPastebinPaster implements PasteInterface { -// @Override -// @NotNull -// public String pasteTheText(@NotNull String text) throws IOException { -// HttpResponse response = Unirest.post("https://paste.helpch.at/documents") -// .body(text) -// .asString(); -// if (response.isSuccess()) { -// String json = response.getBody(); -// Response resp = JsonUtil.getGson().fromJson(json, Response.class); -// return "https://paste.helpch.at/" + resp.getKey(); -// } else { -// throw new IOException(response.getStatus() + " " + response.getStatusText() + ": " + response.getBody()); -// } -// } -// -// @Override -// public String pasteTheTextJson(@NotNull String text) throws Exception { -// HttpResponse response = Unirest.post("https://paste.helpch.at/documents") -// .body(JsonUtil.getGson().toJson(new JsonPadding(text))) -// .asString(); -// if (response.isSuccess()) { -// String json = response.getBody(); -// Response resp = JsonUtil.getGson().fromJson(json, Response.class); -// return "https://paste.helpch.at/documents/" + resp.getKey(); -// } else { -// throw new IOException(response.getStatus() + " " + response.getStatusText() + ": " + response.getBody()); -// } -// } -// -// @NoArgsConstructor -// @Data -// static class Response { -// private String key; -// } -// -// @AllArgsConstructor -// @Data -// static class JsonPadding { -// private final String _paster = "QuickShop"; -// private String data; -// } -//} -// diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/util/paste/PastebinPaster.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/util/paste/PastebinPaster.java deleted file mode 100644 index 02c480ff66..0000000000 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/util/paste/PastebinPaster.java +++ /dev/null @@ -1,51 +0,0 @@ -///* -// * This file is a part of project QuickShop, the name is PastebinPaster.java -// * Copyright (C) Ghost_chu and contributors -// * -// * This program is free software: you can redistribute it and/or modify it -// * under the terms of the GNU General Public License as published by the -// * Free Software Foundation, either version 3 of the License, or -// * (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, but WITHOUT -// * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// * for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program. If not, see . -// * -// */ -// -//package com.ghostchu.quickshop.util.paste; -// -//import kong.unirest.HttpResponse; -//import kong.unirest.Unirest; -//import org.jetbrains.annotations.NotNull; -// -//import java.io.IOException; -// -//public class PastebinPaster implements PasteInterface { -// private final static String DEVELOPER_KEY = "kYoezdaN6Gg9c2VnY78NcpylWRwdzQdk"; -// -// @Override -// public String pasteTheText(@NotNull String text) throws Exception { -// HttpResponse response = Unirest.post("https://pastebin.com/api/api_post.php") -// .field("api_option","paste") -// .field("api_dev_key",DEVELOPER_KEY) -// .field("api_paste_name","quickshop.paste") -// .field("api_paste_expire_date", "1Y") -// .field("api_paste_code", text) -// .asString(); -// if(response.isSuccess()){ -// return response.getBody(); -// }else{ -// throw new IOException(response.getStatus() + " " + response.getStatusText() + ": " + response.getBody()); -// } -// } -// -// @Override -// public String pasteTheTextDirect(@NotNull String text) throws Exception { -// return null; -// } -//} diff --git a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/util/paste/UbuntuPaster.java b/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/util/paste/UbuntuPaster.java deleted file mode 100644 index 81341e7555..0000000000 --- a/quickshop-bukkit/src/main/java/com/ghostchu/quickshop/util/paste/UbuntuPaster.java +++ /dev/null @@ -1,77 +0,0 @@ -///* -// * This file is a part of project QuickShop, the name is UbuntuPaster.java -// * Copyright (C) Ghost_chu and contributors -// * -// * This program is free software: you can redistribute it and/or modify it -// * under the terms of the GNU General Public License as published by the -// * Free Software Foundation, either version 3 of the License, or -// * (at your option) any later version. -// * -// * This program is distributed in the hope that it will be useful, but WITHOUT -// * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// * for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program. If not, see . -// * -// */ -// -//package com.ghostchu.quickshop.util.paste; -// -//import org.jetbrains.annotations.NotNull; -//import com.ghostchu.quickshop.util.Util; -// -//import java.io.BufferedReader; -//import java.io.IOException; -//import java.io.InputStreamReader; -//import java.io.PrintWriter; -//import java.net.URL; -//import java.net.URLConnection; -//import java.net.URLEncoder; -//import java.nio.charset.StandardCharsets; -// -//public class UbuntuPaster implements PasteInterface { -// /** -// * Paste a text to paste.ubuntu.com -// * -// * @param text The text you want paste. -// * @return Target paste URL. -// * @throws IOException the throws -// */ -// @Override -// @NotNull -// public String pasteTheText(@NotNull String text) throws IOException { -// URL url = new URL("https://paste.ubuntu.com"); -// URLConnection conn = url.openConnection(); -// conn.setRequestProperty("accept", "*/*"); -// conn.setRequestProperty("connection", "Keep-Alive"); -// conn.setRequestProperty( -// "user-agent", -// "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"); -// conn.setDoOutput(true); -// conn.setDoInput(true); -// conn.setConnectTimeout(50000); -// conn.setReadTimeout(100000); -// -// PrintWriter out = new PrintWriter(conn.getOutputStream()); -// // poster=aaaaaaa&syntax=text&expiration=&content=%21%40 -// String builder = -// "poster=" -// + "QuickShop Paster" -// + "&syntax=text" -// + "&expiration=week" -// + "&content=" -// + URLEncoder.encode(text, StandardCharsets.UTF_8); -// out.print(builder); -// out.flush(); // Drop -// -// BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8)); -// Log.debug("Request Completed: " + conn.getURL()); -// String link = conn.getURL().toString(); -// in.close(); -// out.close(); -// return link; -// } -// -//}