T getOrSet(@NotNull String path, @NotNull T fallback);
-
- /**
- * Gets location
- *
- * @param path location path to get
- * @return {@link Location}
- */
- @NotNull Location getLocation(@NotNull String path);
-
- /**
- * Sets location into the path
- *
- * @param path location path to set
- * @param location {@link Location}
- */
- void setLocation(@NotNull String path, @NotNull Location location);
-
- /**
- * Pattern:
- *
- * path: (material): 'DIAMOND' [amount]: 1 [data]: 0 [display-name]: 'Diamond Sword'
- * [enchants]: DAMAGE_ALL: 10 FIRE_ASPECT: 2 [lore]: - 'Lore 1' - 'Lore 2'
- *
- * @param path itemstack path to get
- * @return {@link ItemStack}
- */
- @NotNull ItemStack getCustomItemStack(@NotNull String path);
-
- /**
- * Sets custom itemstack to path
- *
- * @param path itemstack path to set
- * @param itemStack {@link ItemStack}
- */
- void setCustomItemStack(@NotNull String path, @NotNull ItemStack itemStack);
-
- /**
- * Gets string
- *
- * @param path string path to get
- * @return {@link String}
- */
- @NotNull Optional getString(@NotNull String path);
-
- /**
- * Sets object to path
- *
- * @param path object path to set
- * @param object {@link Object}
- */
- void set(@NotNull String path, @Nullable Object object);
-
- /**
- * Gets string list
- *
- * @param path string list path to get
- * @return string list
- */
- @NotNull List getStringList(@NotNull String path);
-
- /**
- * Gets int
- *
- * @param path integer path to get
- * @return {@link Integer}
- */
- int getInt(@NotNull String path);
-
- /**
- * Gets double
- *
- * @param path double path to get
- * @return {@link Double}
- */
- double getDouble(@NotNull String path);
-
- /**
- * Gets long
- *
- * @param path long path to get
- * @return {@link Integer}
- */
- long getLong(@NotNull String path);
-
- /**
- * Gets byte
- *
- * @param path byte path to get
- * @return {@link Byte}
- */
- byte getByte(@NotNull String path);
-
- /**
- * Gets short
- *
- * @param path short path to get
- * @return {@link Short}
- */
- short getShort(@NotNull String path);
-
- /**
- * Gets boolean
- *
- * @param path boolean path to get
- * @return {@link Boolean}
- */
- boolean getBoolean(@NotNull String path);
-
- /**
- * Creates configuration section into path
- *
- * @param path configuration section path to create
- * @return {@link ConfigurationSection}
- */
- @NotNull ConfigurationSection createSection(@NotNull String path);
-
- /**
- * Gets configuration section from path
- *
- * @param path configurations section path to get
- * @return if there isn't section returns {@link MckFileConfiguration}
- */
- @NotNull ConfigurationSection getSection(@NotNull String path);
-
- /**
- * Gets configuration section from path if there is no section It will create
- *
- * @param path configurations section path to get
- * @return {@link ConfigurationSection}
- */
- @NotNull ConfigurationSection getOrCreateSection(@NotNull String path);
-
-}
+///*
+// * This file is a part of project QuickShop, the name is IFile.java
+// * Copyright (C) PotatoCraft Studio 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 org.maxgamer.quickshop.fileportlek.old;
+//
+//import org.bukkit.Location;
+//import org.bukkit.configuration.ConfigurationSection;
+//import org.bukkit.configuration.InvalidConfigurationException;
+//import org.bukkit.inventory.ItemStack;
+//import org.jetbrains.annotations.NotNull;
+//import org.jetbrains.annotations.Nullable;
+//import org.maxgamer.quickshop.mock.MckFileConfiguration;
+//
+//import java.io.InputStream;
+//import java.util.List;
+//import java.util.Optional;
+//
+//public interface IFile {
+//
+// /**
+// * Creates yml file on the path
+// */
+// void create();
+//
+// @NotNull InputStream getInputStream();
+//
+// /**
+// * Reloads file
+// */
+// void reload();
+//
+// /**
+// * Saves file
+// */
+// void save();
+//
+// /**
+// * @return the string of the file
+// */
+// @NotNull String saveToString();
+//
+// /**
+// * Loads from the data
+// *
+// * @param data the data
+// * @throws InvalidConfigurationException if config is invalid
+// */
+// void loadFromString(@NotNull String data) throws InvalidConfigurationException;
+//
+// /**
+// * Gets the object
+// *
+// * @param path object path to get
+// * @return if path does not exist returns null
+// */
+// @Nullable Object get(@NotNull String path);
+//
+// /**
+// * Gets the object with fallback
+// *
+// * @param path object path to get
+// * @param fallback fallback object to get if path does not exist
+// * @return if path does not exist returns fallback object
+// */
+// @Nullable Object get(@NotNull String path, @Nullable Object fallback);
+//
+// /**
+// * Gets or sets the object
+// *
+// * @param path object path to get
+// * @param fallback fallback object to get if path does not exist
+// * @param object type
+// * @return if path does not exist returns and set the path with fallback object
+// */
+// @NotNull T getOrSet(@NotNull String path, @NotNull T fallback);
+//
+// /**
+// * Gets location
+// *
+// * @param path location path to get
+// * @return {@link Location}
+// */
+// @NotNull Location getLocation(@NotNull String path);
+//
+// /**
+// * Sets location into the path
+// *
+// * @param path location path to set
+// * @param location {@link Location}
+// */
+// void setLocation(@NotNull String path, @NotNull Location location);
+//
+// /**
+// * Pattern:
+// *
+// * path: (material): 'DIAMOND' [amount]: 1 [data]: 0 [display-name]: 'Diamond Sword'
+// * [enchants]: DAMAGE_ALL: 10 FIRE_ASPECT: 2 [lore]: - 'Lore 1' - 'Lore 2'
+// *
+// * @param path itemstack path to get
+// * @return {@link ItemStack}
+// */
+// @NotNull ItemStack getCustomItemStack(@NotNull String path);
+//
+// /**
+// * Sets custom itemstack to path
+// *
+// * @param path itemstack path to set
+// * @param itemStack {@link ItemStack}
+// */
+// void setCustomItemStack(@NotNull String path, @NotNull ItemStack itemStack);
+//
+// /**
+// * Gets string
+// *
+// * @param path string path to get
+// * @return {@link String}
+// */
+// @NotNull Optional getString(@NotNull String path);
+//
+// /**
+// * Sets object to path
+// *
+// * @param path object path to set
+// * @param object {@link Object}
+// */
+// void set(@NotNull String path, @Nullable Object object);
+//
+// /**
+// * Gets string list
+// *
+// * @param path string list path to get
+// * @return string list
+// */
+// @NotNull List getStringList(@NotNull String path);
+//
+// /**
+// * Gets int
+// *
+// * @param path integer path to get
+// * @return {@link Integer}
+// */
+// int getInt(@NotNull String path);
+//
+// /**
+// * Gets double
+// *
+// * @param path double path to get
+// * @return {@link Double}
+// */
+// double getDouble(@NotNull String path);
+//
+// /**
+// * Gets long
+// *
+// * @param path long path to get
+// * @return {@link Integer}
+// */
+// long getLong(@NotNull String path);
+//
+// /**
+// * Gets byte
+// *
+// * @param path byte path to get
+// * @return {@link Byte}
+// */
+// byte getByte(@NotNull String path);
+//
+// /**
+// * Gets short
+// *
+// * @param path short path to get
+// * @return {@link Short}
+// */
+// short getShort(@NotNull String path);
+//
+// /**
+// * Gets boolean
+// *
+// * @param path boolean path to get
+// * @return {@link Boolean}
+// */
+// boolean getBoolean(@NotNull String path);
+//
+// /**
+// * Creates configuration section into path
+// *
+// * @param path configuration section path to create
+// * @return {@link ConfigurationSection}
+// */
+// @NotNull ConfigurationSection createSection(@NotNull String path);
+//
+// /**
+// * Gets configuration section from path
+// *
+// * @param path configurations section path to get
+// * @return if there isn't section returns {@link MckFileConfiguration}
+// */
+// @NotNull ConfigurationSection getSection(@NotNull String path);
+//
+// /**
+// * Gets configuration section from path if there is no section It will create
+// *
+// * @param path configurations section path to get
+// * @return {@link ConfigurationSection}
+// */
+// @NotNull ConfigurationSection getOrCreateSection(@NotNull String path);
+//
+//}
diff --git a/src/main/java/org/maxgamer/quickshop/fileportlek/old/JSONFile.java b/src/main/java/org/maxgamer/quickshop/fileportlek/old/JSONFile.java
index 0f3a0c2fb..e777e315a 100644
--- a/src/main/java/org/maxgamer/quickshop/fileportlek/old/JSONFile.java
+++ b/src/main/java/org/maxgamer/quickshop/fileportlek/old/JSONFile.java
@@ -1,64 +1,64 @@
-/*
- * This file is a part of project QuickShop, the name is JSONFile.java
- * Copyright (C) PotatoCraft Studio 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 org.maxgamer.quickshop.fileportlek.old;
-
-import com.dumptruckman.bukkit.configuration.json.JsonConfiguration;
-import org.bukkit.configuration.InvalidConfigurationException;
-import org.bukkit.plugin.Plugin;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.util.logging.Level;
-
-public class JSONFile extends FileEnvelope {
-
- public JSONFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath, boolean loadDefault) {
- super(plugin, file, resourcePath.endsWith(".json") ? resourcePath : resourcePath + ".json", loadDefault);
- }
-
- public JSONFile(@NotNull final Plugin plugin, @NotNull final String fileName) {
- this(plugin, "", fileName);
- }
-
- public JSONFile(@NotNull final Plugin plugin, @NotNull final String resourcePath, @NotNull final String fileName) {
- this(plugin, new File(plugin.getDataFolder().getAbsolutePath() + (resourcePath.startsWith(File.separator) ? resourcePath : File.separator + resourcePath), fileName.endsWith(".json") ? fileName : fileName + ".json"), resourcePath.isEmpty() ? fileName : resourcePath.endsWith(File.separator) ? resourcePath + fileName : resourcePath + File.separator + fileName);
- }
-
- public JSONFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath) {
- super(plugin, file, resourcePath.endsWith(".json") ? resourcePath : resourcePath + ".json", true);
- }
-
- @Override
- public void reload() {
- fileConfiguration = HumanReadableJsonConfiguration.loadConfiguration(file);
- if (loadDefault) {
- try {
- JsonConfiguration defaultConfig = new HumanReadableJsonConfiguration();
- defaultConfig.load(new InputStreamReader(getInputStream(), StandardCharsets.UTF_8));
- fileConfiguration.setDefaults(defaultConfig);
- } catch (IOException | InvalidConfigurationException e) {
- plugin.getLogger().log(Level.SEVERE, "Could not load json file " + resourcePath, e);
- }
- }
- }
-}
+///*
+// * This file is a part of project QuickShop, the name is JSONFile.java
+// * Copyright (C) PotatoCraft Studio 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 org.maxgamer.quickshop.fileportlek.old;
+//
+//import com.dumptruckman.bukkit.configuration.json.JsonConfiguration;
+//import org.bukkit.configuration.InvalidConfigurationException;
+//import org.bukkit.plugin.Plugin;
+//import org.jetbrains.annotations.NotNull;
+//
+//import java.io.File;
+//import java.io.IOException;
+//import java.io.InputStreamReader;
+//import java.nio.charset.StandardCharsets;
+//import java.util.logging.Level;
+//
+//public class JSONFile extends FileEnvelope {
+//
+// public JSONFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath, boolean loadDefault) {
+// super(plugin, file, resourcePath.endsWith(".json") ? resourcePath : resourcePath + ".json", loadDefault);
+// }
+//
+// public JSONFile(@NotNull final Plugin plugin, @NotNull final String fileName) {
+// this(plugin, "", fileName);
+// }
+//
+// public JSONFile(@NotNull final Plugin plugin, @NotNull final String resourcePath, @NotNull final String fileName) {
+// this(plugin, new File(plugin.getDataFolder().getAbsolutePath() + (resourcePath.startsWith(File.separator) ? resourcePath : File.separator + resourcePath), fileName.endsWith(".json") ? fileName : fileName + ".json"), resourcePath.isEmpty() ? fileName : resourcePath.endsWith(File.separator) ? resourcePath + fileName : resourcePath + File.separator + fileName);
+// }
+//
+// public JSONFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath) {
+// super(plugin, file, resourcePath.endsWith(".json") ? resourcePath : resourcePath + ".json", true);
+// }
+//
+// @Override
+// public void reload() {
+// fileConfiguration = HumanReadableJsonConfiguration.loadConfiguration(file);
+// if (loadDefault) {
+// try {
+// JsonConfiguration defaultConfig = new HumanReadableJsonConfiguration();
+// defaultConfig.load(new InputStreamReader(getInputStream(), StandardCharsets.UTF_8));
+// fileConfiguration.setDefaults(defaultConfig);
+// } catch (IOException | InvalidConfigurationException e) {
+// plugin.getLogger().log(Level.SEVERE, "Could not load json file " + resourcePath, e);
+// }
+// }
+// }
+//}
diff --git a/src/main/java/org/maxgamer/quickshop/fileportlek/old/YAMLFile.java b/src/main/java/org/maxgamer/quickshop/fileportlek/old/YAMLFile.java
index 37b76ff6c..30a1fe0f1 100644
--- a/src/main/java/org/maxgamer/quickshop/fileportlek/old/YAMLFile.java
+++ b/src/main/java/org/maxgamer/quickshop/fileportlek/old/YAMLFile.java
@@ -1,55 +1,55 @@
-/*
- * This file is a part of project QuickShop, the name is YAMLFile.java
- * Copyright (C) PotatoCraft Studio 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 org.maxgamer.quickshop.fileportlek.old;
-
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.plugin.Plugin;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.File;
-import java.io.InputStreamReader;
-
-public class YAMLFile extends FileEnvelope {
-
- public YAMLFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath, boolean loadDefault) {
- super(plugin, file, resourcePath.endsWith(".yml") ? resourcePath : resourcePath + ".yml", loadDefault);
- }
-
- public YAMLFile(@NotNull final Plugin plugin, @NotNull final String fileName) {
- this(plugin, "", fileName);
- }
-
- public YAMLFile(@NotNull final Plugin plugin, @NotNull final String resourcePath, @NotNull final String fileName) {
- this(plugin, new File(plugin.getDataFolder().getAbsolutePath() + (resourcePath.startsWith(File.separator) ? resourcePath : File.separator + resourcePath), fileName.endsWith(".yml") ? fileName : fileName + ".yml"), resourcePath.isEmpty() ? fileName : resourcePath.endsWith(File.separator) ? resourcePath + fileName : resourcePath + File.separator + fileName);
- }
-
- public YAMLFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath) {
- super(plugin, file, resourcePath.endsWith(".yml") ? resourcePath : resourcePath + ".yml", true);
- }
-
- @Override
- public void reload() {
- fileConfiguration = YamlConfiguration.loadConfiguration(file);
- if (loadDefault) {
- fileConfiguration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getInputStream())));
- }
- }
-
-}
+///*
+// * This file is a part of project QuickShop, the name is YAMLFile.java
+// * Copyright (C) PotatoCraft Studio 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 org.maxgamer.quickshop.fileportlek.old;
+//
+//import org.bukkit.configuration.file.YamlConfiguration;
+//import org.bukkit.plugin.Plugin;
+//import org.jetbrains.annotations.NotNull;
+//
+//import java.io.File;
+//import java.io.InputStreamReader;
+//
+//public class YAMLFile extends FileEnvelope {
+//
+// public YAMLFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath, boolean loadDefault) {
+// super(plugin, file, resourcePath.endsWith(".yml") ? resourcePath : resourcePath + ".yml", loadDefault);
+// }
+//
+// public YAMLFile(@NotNull final Plugin plugin, @NotNull final String fileName) {
+// this(plugin, "", fileName);
+// }
+//
+// public YAMLFile(@NotNull final Plugin plugin, @NotNull final String resourcePath, @NotNull final String fileName) {
+// this(plugin, new File(plugin.getDataFolder().getAbsolutePath() + (resourcePath.startsWith(File.separator) ? resourcePath : File.separator + resourcePath), fileName.endsWith(".yml") ? fileName : fileName + ".yml"), resourcePath.isEmpty() ? fileName : resourcePath.endsWith(File.separator) ? resourcePath + fileName : resourcePath + File.separator + fileName);
+// }
+//
+// public YAMLFile(@NotNull final Plugin plugin, @NotNull final File file, @NotNull final String resourcePath) {
+// super(plugin, file, resourcePath.endsWith(".yml") ? resourcePath : resourcePath + ".yml", true);
+// }
+//
+// @Override
+// public void reload() {
+// fileConfiguration = YamlConfiguration.loadConfiguration(file);
+// if (loadDefault) {
+// fileConfiguration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getInputStream())));
+// }
+// }
+//
+//}
diff --git a/src/main/java/org/maxgamer/quickshop/integration/IntegrationHelper.java b/src/main/java/org/maxgamer/quickshop/integration/IntegrationHelper.java
index 6b7694da6..4972b1bb0 100644
--- a/src/main/java/org/maxgamer/quickshop/integration/IntegrationHelper.java
+++ b/src/main/java/org/maxgamer/quickshop/integration/IntegrationHelper.java
@@ -25,12 +25,13 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.jetbrains.annotations.NotNull;
import org.maxgamer.quickshop.QuickShop;
-import org.maxgamer.quickshop.integration.Fabledskyblock.FabledIntegration;
+import org.maxgamer.quickshop.integration.fabledskyblock.FabledIntegration;
import org.maxgamer.quickshop.integration.factionsuuid.FactionsUUIDIntegration;
import org.maxgamer.quickshop.integration.griefprevention.GriefPreventionIntegration;
import org.maxgamer.quickshop.integration.lands.LandsIntegration;
import org.maxgamer.quickshop.integration.plotsquared.PlotSquaredIntegrationProxy;
import org.maxgamer.quickshop.integration.residence.ResidenceIntegration;
+import org.maxgamer.quickshop.integration.superiorskyblock.SuperiorSkyblock2Integration;
import org.maxgamer.quickshop.integration.towny.TownyIntegration;
import org.maxgamer.quickshop.integration.worldguard.WorldGuardIntegration;
import org.maxgamer.quickshop.util.Util;
@@ -54,6 +55,7 @@ public class IntegrationHelper extends QuickShopInstanceHolder {
integratedPluginNameMap.put("Towny", TownyIntegration.class);
integratedPluginNameMap.put("WorldGuard", WorldGuardIntegration.class);
integratedPluginNameMap.put("FabledSkyblock", FabledIntegration.class);
+ integratedPluginNameMap.put("SuperiorSkyblock", SuperiorSkyblock2Integration.class);
}
private final Map integrations = new HashMap<>(7);
diff --git a/src/main/java/org/maxgamer/quickshop/integration/FabledSkyblock/FabledIntegration.java b/src/main/java/org/maxgamer/quickshop/integration/fabledskyblock/FabledIntegration.java
similarity index 78%
rename from src/main/java/org/maxgamer/quickshop/integration/FabledSkyblock/FabledIntegration.java
rename to src/main/java/org/maxgamer/quickshop/integration/fabledskyblock/FabledIntegration.java
index bbf6e3388..b6a0274e2 100644
--- a/src/main/java/org/maxgamer/quickshop/integration/FabledSkyblock/FabledIntegration.java
+++ b/src/main/java/org/maxgamer/quickshop/integration/fabledskyblock/FabledIntegration.java
@@ -1,4 +1,23 @@
-package org.maxgamer.quickshop.integration.Fabledskyblock;
+/*
+ * This file is a part of project QuickShop, the name is FabledIntegration.java
+ * Copyright (C) PotatoCraft Studio 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 org.maxgamer.quickshop.integration.fabledskyblock;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.island.Island;
diff --git a/src/main/java/org/maxgamer/quickshop/integration/superiorskyblock/SuperiorSkyblock2Integration.java b/src/main/java/org/maxgamer/quickshop/integration/superiorskyblock/SuperiorSkyblock2Integration.java
new file mode 100644
index 000000000..245f9caaf
--- /dev/null
+++ b/src/main/java/org/maxgamer/quickshop/integration/superiorskyblock/SuperiorSkyblock2Integration.java
@@ -0,0 +1,164 @@
+/*
+ * This file is a part of project QuickShop, the name is SuperiorSkyblock2Integration.java
+ * Copyright (C) PotatoCraft Studio 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 org.maxgamer.quickshop.integration.superiorskyblock;
+
+import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI;
+import com.bgsoftware.superiorskyblock.api.events.IslandChunkResetEvent;
+import com.bgsoftware.superiorskyblock.api.events.IslandKickEvent;
+import com.bgsoftware.superiorskyblock.api.events.IslandQuitEvent;
+import com.bgsoftware.superiorskyblock.api.island.Island;
+import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.jetbrains.annotations.NotNull;
+import org.maxgamer.quickshop.QuickShop;
+import org.maxgamer.quickshop.integration.IntegrateStage;
+import org.maxgamer.quickshop.integration.IntegrationStage;
+import org.maxgamer.quickshop.integration.QSIntegratedPlugin;
+import org.maxgamer.quickshop.shop.Shop;
+
+import java.util.Map;
+
+@IntegrationStage(loadStage = IntegrateStage.onEnableAfter)
+public class SuperiorSkyblock2Integration extends QSIntegratedPlugin implements Listener {
+ private final boolean onlyOwnerCanCreateShop;
+ private final boolean deleteShopOnMemberLeave;
+
+ public SuperiorSkyblock2Integration(QuickShop plugin) {
+ super(plugin);
+ onlyOwnerCanCreateShop = plugin.getConfig().getBoolean("integration.superiorskyblock.owner-create-only");
+ deleteShopOnMemberLeave = plugin.getConfig().getBoolean("integration.superiorskyblock.delete-shop-on-member-leave");
+
+ }
+
+ /**
+ * Return the integrated plugin name.
+ * For example, Residence
+ *
+ * @return integrated plugin
+ */
+ @Override
+ public @NotNull String getName() {
+ return "SuperiorSkyblock";
+ }
+
+ /**
+ * Check if a player can create shop here
+ *
+ * @param player the player want to create shop
+ * @param location shop location
+ * @return If you can create shop here
+ */
+ @Override
+ public boolean canCreateShopHere(@NotNull Player player, @NotNull Location location) {
+ Island island = SuperiorSkyblockAPI.getIslandAt(location);
+ SuperiorPlayer superiorPlayer = SuperiorSkyblockAPI.getPlayer(player);
+ if (island == null) {
+ return false;
+ }
+ if (onlyOwnerCanCreateShop) {
+ return island.getOwner().equals(superiorPlayer);
+ } else {
+ if (island.getOwner().equals(superiorPlayer))
+ return true;
+ return island.isMember(superiorPlayer);
+ }
+ }
+
+ /**
+ * Check if a player can trade with shop here
+ *
+ * @param player the player want to trade with shop
+ * @param location shop location
+ * @return If you can trade with shop here
+ */
+ @Override
+ public boolean canTradeShopHere(@NotNull Player player, @NotNull Location location) {
+ return true;
+ }
+
+ /**
+ * Loading logic
+ * Execute Stage defined by IntegrationStage
+ */
+ @Override
+ public void load() {
+ if (plugin.getConfig().getBoolean("integration.superiorskyblock.delete-shop-on-member-leave")) {
+ Bukkit.getPluginManager().registerEvents(this, plugin);
+ }
+ }
+
+ /**
+ * Unloding logic
+ * Will execute when Quickshop unloading
+ */
+ @Override
+ public void unload() {
+ IslandQuitEvent.getHandlerList().unregister(this);
+ IslandKickEvent.getHandlerList().unregister(this);
+ IslandChunkResetEvent.getHandlerList().unregister(this);
+ }
+
+ @EventHandler
+ public void deleteShops(com.bgsoftware.superiorskyblock.api.events.IslandQuitEvent event) {
+ event.getIsland().getAllChunks().forEach((chunk) -> {
+ Map shops = plugin.getShopManager().getShops(chunk);
+ if (shops != null && !shops.isEmpty()) {
+ shops.forEach((location, shop) -> {
+ if (shop.getOwner().equals(event.getPlayer().getUniqueId())) {
+ plugin.log("[SuperiorSkyBlock2 Integration]Shop " + shop + " deleted caused by ShopOwnerQuitFromIsland");
+ shop.delete();
+ }
+ });
+ }
+ });
+ }
+
+ @EventHandler
+ public void deleteShops(com.bgsoftware.superiorskyblock.api.events.IslandKickEvent event) {
+ event.getIsland().getAllChunks().forEach((chunk) -> {
+ Map shops = plugin.getShopManager().getShops(chunk);
+ if (shops != null && !shops.isEmpty()) {
+ shops.forEach((location, shop) -> {
+ if (shop.getOwner().equals(event.getTarget().getUniqueId())) {
+ plugin.log("[SuperiorSkyBlock2 Integration]Shop " + shop + " deleted caused by ShopOwnerKickedFromIsland");
+ shop.delete();
+ }
+ });
+ }
+ });
+
+ }
+
+ @EventHandler
+ public void deleteShops(com.bgsoftware.superiorskyblock.api.events.IslandChunkResetEvent event) {
+ Map shops = plugin.getShopManager().getShops(event.getWorld().getName(), event.getChunkX(), event.getChunkZ());
+ if (shops != null && !shops.isEmpty()) {
+ shops.forEach((location, shop) -> {
+ plugin.log("[SuperiorSkyBlock2 Integration]Shop " + shop + " deleted caused by IslandChunkReset.");
+ shop.delete();
+ });
+ }
+ }
+
+}
diff --git a/src/main/java/org/maxgamer/quickshop/listener/DisplayBugFixListener.java b/src/main/java/org/maxgamer/quickshop/listener/DisplayBugFixListener.java
deleted file mode 100644
index 1172ff918..000000000
--- a/src/main/java/org/maxgamer/quickshop/listener/DisplayBugFixListener.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * This file is a part of project QuickShop, the name is DisplayBugFixListener.java
- * Copyright (C) PotatoCraft Studio 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 org.maxgamer.quickshop.listener;
-
-import org.bukkit.entity.ArmorStand;
-import org.bukkit.entity.Entity;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.block.BlockCanBuildEvent;
-import org.maxgamer.quickshop.QuickShop;
-import org.maxgamer.quickshop.shop.DisplayItem;
-import org.maxgamer.quickshop.shop.DisplayType;
-import org.maxgamer.quickshop.util.Util;
-
-import java.util.Collection;
-
-
-public class DisplayBugFixListener extends QSListener {
- public DisplayBugFixListener(QuickShop plugin) {
- super(plugin);
- }
-
- @EventHandler(ignoreCancelled = true)
- public void canBuild(BlockCanBuildEvent e) {
- if (!plugin.isDisplay()
- || DisplayItem.getNowUsing() != DisplayType.ARMORSTAND
- || e.isBuildable()) {
- return;
- }
-
- final Collection entities =
- e.getBlock().getWorld().getNearbyEntities(e.getBlock().getLocation(), 1.0, 1, 1.0);
-
- for (final Entity entity : entities) {
- if (!(entity instanceof ArmorStand)
- || !DisplayItem.checkIsGuardItemStack(((ArmorStand) entity).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
- continue;
- }
-
- e.setBuildable(true);
- Util.debugLog(
- "Re-set the allowed build flag here because it found the cause of the display-item blocking it before.");
- return;
- }
- }
-
-}
diff --git a/src/main/java/org/maxgamer/quickshop/listener/DisplayProtectionListener.java b/src/main/java/org/maxgamer/quickshop/listener/DisplayProtectionListener.java
index ec4fd64c2..955fec10b 100644
--- a/src/main/java/org/maxgamer/quickshop/listener/DisplayProtectionListener.java
+++ b/src/main/java/org/maxgamer/quickshop/listener/DisplayProtectionListener.java
@@ -20,12 +20,10 @@
package org.maxgamer.quickshop.listener;
import org.bukkit.Location;
-import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
-import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.event.entity.ItemDespawnEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
@@ -81,20 +79,20 @@ public class DisplayProtectionListener extends ProtectionListenerBase {
+ " , QuickShop already cancel it.");
}
}
-
- @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
- public void entity(EntityDamageEvent event) {
- if (!(event.getEntity() instanceof ArmorStand)) {
- return;
- }
- if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
- return;
- }
- if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
- return;
- }
- event.setCancelled(true);
- }
+//
+// @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
+// public void entity(EntityDamageEvent event) {
+// if (!(event.getEntity() instanceof ArmorStand)) {
+// return;
+// }
+// if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
+// return;
+// }
+// if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
+// return;
+// }
+// event.setCancelled(true);
+// }
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
diff --git a/src/main/java/org/maxgamer/quickshop/listener/EnhanceDisplayProtectionListener.java b/src/main/java/org/maxgamer/quickshop/listener/EnhanceDisplayProtectionListener.java
index 6e22c509e..6f02fa1cd 100644
--- a/src/main/java/org/maxgamer/quickshop/listener/EnhanceDisplayProtectionListener.java
+++ b/src/main/java/org/maxgamer/quickshop/listener/EnhanceDisplayProtectionListener.java
@@ -25,7 +25,6 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Furnace;
-import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
@@ -34,8 +33,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
-import org.bukkit.event.entity.EntityDeathEvent;
-import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.inventory.*;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
@@ -46,7 +43,6 @@ import org.jetbrains.annotations.NotNull;
import org.maxgamer.quickshop.Cache;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.shop.DisplayItem;
-import org.maxgamer.quickshop.shop.DisplayType;
import org.maxgamer.quickshop.shop.Shop;
import org.maxgamer.quickshop.util.MsgUtil;
import org.maxgamer.quickshop.util.Util;
@@ -251,44 +247,44 @@ public class EnhanceDisplayProtectionListener extends ProtectionListenerBase imp
}
}
- @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
- public void entity(EntityDeathEvent event) {
- if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
- return;
- }
- if (!(event.getEntity() instanceof ArmorStand)) {
- return;
- }
- if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
- return;
- }
- event.setDroppedExp(0);
- event.getDrops().clear();
- }
+// @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
+// public void entity(EntityDeathEvent event) {
+// if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
+// return;
+// }
+// if (!(event.getEntity() instanceof ArmorStand)) {
+// return;
+// }
+// if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
+// return;
+// }
+// event.setDroppedExp(0);
+// event.getDrops().clear();
+// }
- @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
- public void entity(EntityInteractEvent event) {
- if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
- return;
- }
- if (!(event.getEntity() instanceof ArmorStand)) {
- return;
- }
- if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
- return;
- }
- event.setCancelled(true);
- final Entity entity = event.getEntity();
- if (entity instanceof InventoryHolder) {
- Util.inventoryCheck(((InventoryHolder) entity).getInventory());
- }
- sendAlert(
- "[DisplayGuard] Entity "
- + event.getEntityType().name()
- + " # "
- + event.getEntity().getLocation()
- + " trying interact the hold displayItem's entity.");
- }
+// @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
+// public void entity(EntityInteractEvent event) {
+// if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
+// return;
+// }
+// if (!(event.getEntity() instanceof ArmorStand)) {
+// return;
+// }
+// if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) { //FIXME: Update this when drop 1.13 supports
+// return;
+// }
+// event.setCancelled(true);
+// final Entity entity = event.getEntity();
+// if (entity instanceof InventoryHolder) {
+// Util.inventoryCheck(((InventoryHolder) entity).getInventory());
+// }
+// sendAlert(
+// "[DisplayGuard] Entity "
+// + event.getEntityType().name()
+// + " # "
+// + event.getEntity().getLocation()
+// + " trying interact the hold displayItem's entity.");
+// }
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void inventory(InventoryClickEvent event) {
diff --git a/src/main/java/org/maxgamer/quickshop/listener/PlayerListener.java b/src/main/java/org/maxgamer/quickshop/listener/PlayerListener.java
index 60d993980..a08228458 100644
--- a/src/main/java/org/maxgamer/quickshop/listener/PlayerListener.java
+++ b/src/main/java/org/maxgamer/quickshop/listener/PlayerListener.java
@@ -19,6 +19,8 @@
package org.maxgamer.quickshop.listener;
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
import io.papermc.lib.PaperLib;
import org.bukkit.GameMode;
import org.bukkit.Location;
@@ -27,7 +29,7 @@ import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
-import org.bukkit.event.Event.Result;
+import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
@@ -49,11 +51,79 @@ import org.maxgamer.quickshop.util.Util;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
+import java.util.concurrent.TimeUnit;
public class PlayerListener extends QSListener {
+ private final Cache dupeClickPrevent = Caffeine
+ .newBuilder()
+ .initialCapacity(10)
+ .expireAfterAccess(1, TimeUnit.SECONDS)
+ .weakKeys()
+ .build();
+ private boolean swapBehavior = false;
public PlayerListener(QuickShop plugin) {
super(plugin);
+ swapBehavior = plugin.getConfig().getBoolean("shop.interact.swap-click-behavior");
+ }
+
+ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
+ public void onClick(PlayerInteractEvent e) {
+ if (e.getHand() != EquipmentSlot.HAND) {
+ return;
+ }
+ final Block b = e.getClickedBlock();
+
+ // ----Adventure dupe click workaround start----
+ if (e.getPlayer().getGameMode() == GameMode.ADVENTURE) {
+ dupeClickPrevent.put(e.getPlayer(), System.currentTimeMillis());
+ }
+ // ----Adventure dupe click workaround end----
+ if (!e.getAction().equals(Action.LEFT_CLICK_BLOCK) && b != null) {
+ if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
+ if (!swapBehavior) {
+ postControlPanel(e);
+ } else {
+ postTrade(e);
+ }
+ return;
+ }
+ }
+ if (!swapBehavior) {
+ postTrade(e);
+ } else {
+ postControlPanel(e);
+ }
+
+ }
+
+ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
+ public void onAdventureClick(PlayerAnimationEvent event) {
+ if (event.getPlayer().getGameMode() != GameMode.ADVENTURE) {
+ return;
+ }
+ // ----Adventure dupe click workaround start----
+ Long dupeTime = dupeClickPrevent.getIfPresent(event.getPlayer());
+ if (dupeTime != null && dupeTime > System.currentTimeMillis() - 1000) {
+ return;
+ } else if (dupeTime != null) {
+ dupeClickPrevent.invalidate(event.getPlayer());
+ }
+ // ----Adventure dupe click workaround end----
+ Block focused = event.getPlayer().getTargetBlock(null, 5);
+ PlayerInteractEvent interactEvent
+ = new PlayerInteractEvent(event.getPlayer(),
+ focused.getType() == Material.AIR ? Action.LEFT_CLICK_AIR : Action.LEFT_CLICK_BLOCK,
+ event.getPlayer().getInventory().getItemInMainHand(),
+ focused,
+ event.getPlayer().getFacing().getOppositeFace());
+
+ if (!swapBehavior) {
+ postTrade(interactEvent);
+ } else {
+ postControlPanel(interactEvent);
+ }
+
}
private void playClickSound(@NotNull Player player) {
@@ -62,36 +132,36 @@ public class PlayerListener extends QSListener {
}
}
- @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
- public void onClick(PlayerInteractEvent e) {
- if (e.getHand() != EquipmentSlot.HAND) {
- return;
- }
- if (!e.getAction().equals(Action.LEFT_CLICK_BLOCK) && e.getClickedBlock() != null) {
- if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && Util.isWallSign(e.getClickedBlock().getType())) {
- final Block block;
- if (Util.isWallSign(e.getClickedBlock().getType())) {
- block = Util.getAttached(e.getClickedBlock());
- } else {
- block = e.getClickedBlock();
- }
- Shop controlPanelShop = plugin.getShopManager().getShop(Objects.requireNonNull(block).getLocation());
- if (controlPanelShop != null && (controlPanelShop.getOwner().equals(e.getPlayer().getUniqueId()) || QuickShop.getPermissionManager().hasPermission(e.getPlayer(), "quickshop.other.control"))) {
- MsgUtil.sendControlPanelInfo(e.getPlayer(), Objects.requireNonNull(plugin.getShopManager().getShop(block.getLocation())));
- this.playClickSound(e.getPlayer());
- Objects.requireNonNull(plugin.getShopManager().getShop(block.getLocation())).setSignText();
- }
- }
- return;
- }
+ private void postControlPanel(PlayerInteractEvent e) {
final Block b = e.getClickedBlock();
+ final Player p = e.getPlayer();
+ if (Util.isWallSign(b.getType())) {
+ final Block block;
+ if (Util.isWallSign(b.getType())) {
+ block = Util.getAttached(b);
+ } else {
+ block = e.getClickedBlock();
+ }
+ Shop controlPanelShop = plugin.getShopManager().getShop(Objects.requireNonNull(block).getLocation());
+ if (controlPanelShop != null && (controlPanelShop.getOwner().equals(p.getUniqueId()) || QuickShop.getPermissionManager().hasPermission(p, "quickshop.other.control"))) {
+ MsgUtil.sendControlPanelInfo(p, Objects.requireNonNull(plugin.getShopManager().getShop(block.getLocation())));
+ this.playClickSound(e.getPlayer());
+ Objects.requireNonNull(plugin.getShopManager().getShop(block.getLocation())).setSignText();
+ }
+ }
+ return;
+ }
+
+ private void postTrade(PlayerInteractEvent e) {
+ final Block b = e.getClickedBlock();
+ final Player p = e.getPlayer();
if (b == null) {
return;
}
if (!Util.canBeShop(b) && !Util.isWallSign(b.getType())) {
return;
}
- final Player p = e.getPlayer();
+
final Location loc = b.getLocation();
final ItemStack item = e.getItem();
// Get the shop
@@ -177,13 +247,13 @@ public class PlayerListener extends QSListener {
actions.put(p.getUniqueId(), info);
}
// Handles creating shops
- else if (e.useInteractedBlock() == Result.ALLOW
+ else if (e.useInteractedBlock() == Event.Result.ALLOW
&& shop == null
&& item != null
&& item.getType() != Material.AIR
&& QuickShop.getPermissionManager().hasPermission(p, "quickshop.create.sell")
&& p.getGameMode() != GameMode.CREATIVE) {
- if (e.useInteractedBlock() == Result.DENY
+ if (e.useInteractedBlock() == Event.Result.DENY
|| !InteractUtil.check(InteractUtil.Action.CREATE, p.isSneaking())
|| plugin.getConfig().getBoolean("shop.disable-quick-create")
|| !plugin.getShopManager().canBuildShop(p, b, e.getBlockFace())) {
@@ -237,6 +307,11 @@ public class PlayerListener extends QSListener {
}
}
+ enum InteractAction {
+ TRADE,
+ CONTROL_PANEL
+ }
+
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClose(InventoryCloseEvent e) {
diff --git a/src/main/java/org/maxgamer/quickshop/permission/BukkitPermsProvider.java b/src/main/java/org/maxgamer/quickshop/permission/BukkitPermsProvider.java
index 61226bdd2..224b89931 100644
--- a/src/main/java/org/maxgamer/quickshop/permission/BukkitPermsProvider.java
+++ b/src/main/java/org/maxgamer/quickshop/permission/BukkitPermsProvider.java
@@ -42,9 +42,9 @@ public class BukkitPermsProvider implements PermissionProvider {
* @return Debug Infos
*/
@Override
- public @NotNull PermissionInfomationContainer getDebugInfo(
+ public @NotNull PermissionInformationContainer getDebugInfo(
@NotNull CommandSender sender, @NotNull String permission) {
- return new PermissionInfomationContainer(sender, permission, null, null);
+ return new PermissionInformationContainer(sender, permission, null, null);
}
}
diff --git a/src/main/java/org/maxgamer/quickshop/permission/PermissionInfomationContainer.java b/src/main/java/org/maxgamer/quickshop/permission/PermissionInformationContainer.java
similarity index 94%
rename from src/main/java/org/maxgamer/quickshop/permission/PermissionInfomationContainer.java
rename to src/main/java/org/maxgamer/quickshop/permission/PermissionInformationContainer.java
index 794f4150b..1744baba9 100644
--- a/src/main/java/org/maxgamer/quickshop/permission/PermissionInfomationContainer.java
+++ b/src/main/java/org/maxgamer/quickshop/permission/PermissionInformationContainer.java
@@ -1,5 +1,5 @@
/*
- * This file is a part of project QuickShop, the name is PermissionInfomationContainer.java
+ * This file is a part of project QuickShop, the name is PermissionInformationContainer.java
* Copyright (C) PotatoCraft Studio and contributors
*
* This program is free software: you can redistribute it and/or modify it
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.Nullable;
@Data
@AllArgsConstructor
-public class PermissionInfomationContainer {
+public class PermissionInformationContainer {
@NotNull
private CommandSender sender;
diff --git a/src/main/java/org/maxgamer/quickshop/permission/PermissionManager.java b/src/main/java/org/maxgamer/quickshop/permission/PermissionManager.java
index 5ec9caaca..bc339bc42 100644
--- a/src/main/java/org/maxgamer/quickshop/permission/PermissionManager.java
+++ b/src/main/java/org/maxgamer/quickshop/permission/PermissionManager.java
@@ -57,7 +57,7 @@ public class PermissionManager {
boolean result = provider.hasPermission(sender, permission);
if (Util.isDevMode()) {
try {
- PermissionInfomationContainer container = provider.getDebugInfo(sender, permission);
+ PermissionInformationContainer container = provider.getDebugInfo(sender, permission);
Util.debugLog("Permission Node: " + container.getPermission() + "; Result: " + result + "; Sender: " + container.getSender().getName());
// Util.debugLog("Result: " + result);
// Util.debugLog("Sender: " + container.getSender().getName());
diff --git a/src/main/java/org/maxgamer/quickshop/permission/PermissionProvider.java b/src/main/java/org/maxgamer/quickshop/permission/PermissionProvider.java
index aa47389eb..100a36a7d 100644
--- a/src/main/java/org/maxgamer/quickshop/permission/PermissionProvider.java
+++ b/src/main/java/org/maxgamer/quickshop/permission/PermissionProvider.java
@@ -48,7 +48,7 @@ public interface PermissionProvider {
* @return Debug Infos
*/
@NotNull
- PermissionInfomationContainer getDebugInfo(
+ PermissionInformationContainer getDebugInfo(
@NotNull CommandSender sender, @NotNull String permission);
}
diff --git a/src/main/java/org/maxgamer/quickshop/permission/VaultPermissionProvider.java b/src/main/java/org/maxgamer/quickshop/permission/VaultPermissionProvider.java
index 633d8853b..4d037af3e 100644
--- a/src/main/java/org/maxgamer/quickshop/permission/VaultPermissionProvider.java
+++ b/src/main/java/org/maxgamer/quickshop/permission/VaultPermissionProvider.java
@@ -71,13 +71,13 @@ public class VaultPermissionProvider implements PermissionProvider {
* @return Debug Infos
*/
@Override
- public @NotNull PermissionInfomationContainer getDebugInfo(
+ public @NotNull PermissionInformationContainer getDebugInfo(
@NotNull CommandSender sender, @NotNull String permission) {
if (sender instanceof Server) {
- return new PermissionInfomationContainer(sender, permission, null, "User is Console");
+ return new PermissionInformationContainer(sender, permission, null, "User is Console");
}
OfflinePlayer offlinePlayer = (OfflinePlayer) sender;
- return new PermissionInfomationContainer(
+ return new PermissionInformationContainer(
sender, permission, api.getPrimaryGroup(null, offlinePlayer), null);
}
diff --git a/src/main/java/org/maxgamer/quickshop/shop/ArmorStandDisplayItem.java b/src/main/java/org/maxgamer/quickshop/shop/ArmorStandDisplayItem.java
deleted file mode 100644
index d53b703da..000000000
--- a/src/main/java/org/maxgamer/quickshop/shop/ArmorStandDisplayItem.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * This file is a part of project QuickShop, the name is ArmorStandDisplayItem.java
- * Copyright (C) PotatoCraft Studio 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 org.maxgamer.quickshop.shop;
-
-import lombok.ToString;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.NamespacedKey;
-import org.bukkit.block.BlockFace;
-import org.bukkit.block.data.Directional;
-import org.bukkit.entity.ArmorStand;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.EntityType;
-import org.bukkit.util.EulerAngle;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.maxgamer.quickshop.event.ShopDisplayItemDespawnEvent;
-import org.maxgamer.quickshop.event.ShopDisplayItemSpawnEvent;
-import org.maxgamer.quickshop.util.GameVersion;
-import org.maxgamer.quickshop.util.MsgUtil;
-import org.maxgamer.quickshop.util.ReflectFactory;
-import org.maxgamer.quickshop.util.Util;
-
-import java.util.Objects;
-
-@ToString
-@Deprecated
-
-public class ArmorStandDisplayItem extends DisplayItem {
-
- @Nullable
- private volatile ArmorStand armorStand;
-
- /**
- * @deprecated This display type pending for removal in future
- */
- ArmorStandDisplayItem(@NotNull Shop shop) {
- super(shop);
- }
-
- private static boolean isTool(Material material) {
- String nlc = material.name().toLowerCase();
- return nlc.contains("sword") || nlc.contains("shovel") || nlc.contains("axe"); //TODO: Needs a better impl. Maybe NamespacedKey
- }
-
- @Override
- public boolean checkDisplayIsMoved() {
- if (this.armorStand == null) {
- return false;
- }
- return !this.armorStand.getLocation().equals(getDisplayLocation());
- }
-
- public Location getCenter(Location loc) {
- // This is always '+' instead of '-' even in negative pos
- return new Location(
- loc.getWorld(), loc.getBlockX() + .5, loc.getBlockY() + .5, loc.getBlockZ() + .5);
- }
-
- @Override
- public boolean checkDisplayNeedRegen() {
- if (this.armorStand == null) {
- return false;
- }
- return !this.armorStand.isValid() || this.armorStand.isDead();
- }
-
- @Override
- public boolean checkIsShopEntity(@NotNull Entity entity) {
- if (!(entity instanceof ArmorStand)) {
- return false;
- }
- return DisplayItem.checkIsGuardItemStack(((ArmorStand) entity).getItemInHand()); //FIXME: Update this when drop 1.13 supports
- }
-
- @Override
- public void fixDisplayMoved() {
- Location location = this.getDisplayLocation();
- //if (this.armorStand != null) {
- if (location != null) {
- this.armorStand.teleport(location);
- } else {
- fixDisplayMovedOld();
- }
-// } else {
-// fixDisplayMovedOld();
-// }
- }
-
- public void fixDisplayMovedOld() {
- for (Entity entity : Objects.requireNonNull(this.shop.getLocation().getWorld()).getEntities()) {
- if (!(entity instanceof ArmorStand)) {
- continue;
- }
- ArmorStand eArmorStand = (ArmorStand) entity;
- if (eArmorStand.getUniqueId().equals(Objects.requireNonNull(this.armorStand).getUniqueId())) {
- Util.debugLog(
- "Fixing moved ArmorStand displayItem "
- + eArmorStand.getUniqueId()
- + " at "
- + eArmorStand.getLocation());
- eArmorStand.teleport(getDisplayLocation());
- return;
- }
- }
- }
-
- @Override
- public void fixDisplayNeedRegen() {
- respawn();
- }
-
- @Override
- public void remove() {
- if (this.armorStand == null) {
- Util.debugLog("Ignore the armorStand removing because the armorStand not spawned.");
- return;
- }
- this.armorStand.remove();
- this.armorStand = null;
- this.guardedIstack = null;
- ShopDisplayItemDespawnEvent shopDisplayItemDespawnEvent =
- new ShopDisplayItemDespawnEvent(this.shop, this.originalItemStack, DisplayType.ARMORSTAND);
- plugin.getServer().getPluginManager().callEvent(shopDisplayItemDespawnEvent);
- }
-
- @Override
- public boolean removeDupe() {
- if (this.armorStand == null) {
- Util.debugLog("Warning: Trying to removeDupe for a null display shop.");
- return false;
- }
- boolean removed = false;
- for (Entity entity : armorStand.getNearbyEntities(1.5, 1.5, 1.5)) {
- if (entity.getType() != EntityType.ARMOR_STAND) {
- continue;
- }
- ArmorStand eArmorStand = (ArmorStand) entity;
-
- if (!eArmorStand.getUniqueId().equals(this.armorStand.getUniqueId()) && DisplayItem.checkIsTargetShopDisplay(eArmorStand.getItemInHand(), this.shop)) {//FIXME: Update this when drop 1.13 supports
- Util.debugLog("Removing dupes ArmorEntity " + eArmorStand.getUniqueId() + " at " + eArmorStand.getLocation());
- entity.remove();
- removed = true;
- }
- }
- return removed;
- }
-
- @Override
- public void respawn() {
- remove();
- spawn();
- }
-
- @Override
- public void safeGuard(@NotNull Entity entity) {
- if (!(entity instanceof ArmorStand)) {
- Util.debugLog(
- "Failed to safeGuard " + entity.getLocation() + ", cause target not a ArmorStand");
- return;
- }
- ArmorStand armorStand = (ArmorStand) entity;
- // Set item protect in the armorstand's hand
- this.guardedIstack = DisplayItem.createGuardItemStack(this.originalItemStack, this.shop);
- Objects.requireNonNull(armorStand.getEquipment()).setHelmet(guardedIstack);
- if (GameVersion.get(ReflectFactory.getServerVersion()).isPersistentStorageApiSupports()) {
- armorStand
- .getPersistentDataContainer()
- .set(
- new NamespacedKey(plugin, "displayMark"),
- DisplayItemPersistentDataType.INSTANCE,
- DisplayItem.createShopProtectionFlag(this.originalItemStack, shop));
-
- }
- }
-
- @Override
- public void spawn() {
- if (shop.isDeleted() || !shop.isLoaded()) {
- return;
- }
- if (shop.getLocation().getWorld() == null) {
- Util.debugLog("Canceled the displayItem spawning because the location in the world is null.");
- return;
- }
-
- if (originalItemStack == null) {
- Util.debugLog("Canceled the displayItem spawning because the ItemStack is null.");
- return;
- }
-
- if (armorStand != null && armorStand.isValid() && !armorStand.isDead()) {
- Util.debugLog(
- "Warning: Spawning the armorStand for DisplayItem when there is already an existing armorStand may cause a duplicated armorStand!");
- MsgUtil.debugStackTrace(Thread.currentThread().getStackTrace());
-
- ShopDisplayItemSpawnEvent shopDisplayItemSpawnEvent =
- new ShopDisplayItemSpawnEvent(shop, originalItemStack, DisplayType.ARMORSTAND);
- plugin.getServer().getPluginManager().callEvent(shopDisplayItemSpawnEvent);
- if (shopDisplayItemSpawnEvent.isCancelled()) {
- Util.debugLog(
- "Canceled the displayItem from spawning because a plugin setCancelled the spawning event, usually it is a QuickShop Add on");
- return;
- }
-
- Location location = getDisplayLocation();
- this.armorStand =
- this.shop
- .getLocation()
- .getWorld()
- .spawn(
- location,
- ArmorStand.class,
- armorStand -> {
- // Set basic armorstand datas.
- armorStand.setGravity(false);
- armorStand.setVisible(false);
- armorStand.setMarker(true);
- armorStand.setCollidable(false);
- armorStand.setSmall(true);
- armorStand.setArms(false);
- armorStand.setBasePlate(false);
- armorStand.setSilent(true);
- armorStand.setAI(false);
- armorStand.setCanPickupItems(false);
- // Set pose (this is for hand while we use helmet)
- // setPoseForArmorStand();
- });
- // Set safeGuard
- Util.debugLog(
- "Spawned armor stand @ "
- + this.armorStand.getLocation()
- + " with UUID "
- + this.armorStand.getUniqueId());
- safeGuard(this.armorStand); // Helmet must be set after spawning
- }
- }
-
- @Override
- public @Nullable Entity getDisplay() {
- return this.armorStand;
- }
-
- @Override
- public Location getDisplayLocation() {
- BlockFace containerBlockFace = BlockFace.NORTH; // Set default vaule
- if (this.shop.getLocation().getBlock().getBlockData() instanceof Directional) {
- containerBlockFace =
- ((Directional) this.shop.getLocation().getBlock().getBlockData())
- .getFacing(); // Replace by container face.
- }
- // Fix specific block facing
- Material type = this.shop.getLocation().getBlock().getType();
- if (type.name().contains("ANVIL")
- || type.name().contains("FENCE")
- || type.name().contains("WALL")) {
- switch (containerBlockFace) {
- case SOUTH:
- containerBlockFace = BlockFace.WEST;
- break;
- case NORTH:
- containerBlockFace = BlockFace.EAST;
- case EAST:
- containerBlockFace = BlockFace.NORTH;
- case WEST:
- containerBlockFace = BlockFace.SOUTH;
- default:
- break;
- }
- }
-
- Location asloc = getCenter(this.shop.getLocation());
- Util.debugLog("containerBlockFace " + containerBlockFace);
- if (this.originalItemStack.getType().isBlock()) {
- asloc.add(0, 0.5, 0);
- }
- switch (containerBlockFace) {
- case SOUTH:
- asloc.add(0, -0.5, 0);
- asloc.setYaw(0);
- Util.debugLog("Block face as SOUTH");
- break;
- case WEST:
- asloc.add(0, -0.5, 0);
- asloc.setYaw(90);
- Util.debugLog("Block face as WEST");
- break;
- case EAST:
- asloc.add(0, -0.5, 0);
- asloc.setYaw(-90);
- Util.debugLog("Block face as EAST");
- break;
- case NORTH:
- asloc.add(0, -0.5, 0);
- asloc.setYaw(180);
- Util.debugLog("Block face as NORTH");
- break;
- default:
- break;
- }
- return asloc;
- }
-
- @Override
- public synchronized boolean isSpawned() {
- return this.armorStand != null && this.armorStand.isValid();
- }
-
- @Deprecated // no use, will be removed soon
- private void setPoseForArmorStand() {
- if (this.originalItemStack.getType().isBlock()) {
- Objects.requireNonNull(armorStand).setRightArmPose(new EulerAngle(-0.2, 0, 0));
- } else {
- Objects.requireNonNull(armorStand).setRightArmPose(new EulerAngle(-89.5, 0, 0));
- }
- }
-
-}
diff --git a/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java b/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java
index 9f577be11..0b7a505dd 100644
--- a/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java
+++ b/src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java
@@ -22,8 +22,6 @@ package org.maxgamer.quickshop.shop;
import com.lishid.openinv.OpenInv;
import io.papermc.lib.PaperLib;
import lombok.EqualsAndHashCode;
-import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
-import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
@@ -146,8 +144,7 @@ public class ContainerShop implements Shop {
Util.debugLog("Shop item display is: " + meta.getDisplayName());
//https://hub.spigotmc.org/jira/browse/SPIGOT-5964
if (meta.getDisplayName().matches("\\{.*\\}")) {
- meta.setDisplayName(LegacyComponentSerializer.legacySection().serialize(
- GsonComponentSerializer.gson().deserialize(meta.getDisplayName())));
+ meta.setDisplayName(meta.getDisplayName());
//Correct both items
item.setItemMeta(meta);
this.item.setItemMeta(meta);
@@ -169,21 +166,21 @@ public class ContainerShop implements Shop {
switch (DisplayItem.getNowUsing()) {
case UNKNOWN:
Util.debugLog(
- "Failed to create a ContainerShop displayItem, the type is unknown, fallback to RealDisplayItem");
+ "Failed to create a ContainerShop displayItem, the type is unknown, fallback to RealDisplayItem");
this.displayItem = new RealDisplayItem(this);
break;
case REALITEM:
this.displayItem = new RealDisplayItem(this);
break;
- case ARMORSTAND:
- this.displayItem = new ArmorStandDisplayItem(this);
- break;
+// case ARMORSTAND:
+// this.displayItem = new ArmorStandDisplayItem(this);
+// break;
case VIRTUALITEM:
try {
if (!GameVersion.get(ReflectFactory.getServerVersion())
- .isVirtualDisplaySupports()) {
+ .isVirtualDisplaySupports()) {
throw new IllegalStateException(
- "Version not supports Virtual DisplayItem.");
+ "Version not supports Virtual DisplayItem.");
}
this.displayItem = new VirtualDisplayItem(this);
@@ -804,7 +801,7 @@ public class ContainerShop implements Shop {
checkDisplay();
- if (!isLeftShop) {
+ if (!isLeftShop && plugin.isDisplay()) {
if (displayItem != null) {
displayItem.remove();
}
diff --git a/src/main/java/org/maxgamer/quickshop/shop/DisplayType.java b/src/main/java/org/maxgamer/quickshop/shop/DisplayType.java
index 92d7271db..e21e72f73 100644
--- a/src/main/java/org/maxgamer/quickshop/shop/DisplayType.java
+++ b/src/main/java/org/maxgamer/quickshop/shop/DisplayType.java
@@ -31,7 +31,7 @@ public enum DisplayType {
* */
UNKNOWN(-1),
REALITEM(0),
- ARMORSTAND(1),
+ // ARMORSTAND(1),
VIRTUALITEM(2);
private final int id;
@@ -57,9 +57,9 @@ public enum DisplayType {
if (displayItem instanceof RealDisplayItem) {
return REALITEM;
}
- if (displayItem instanceof ArmorStandDisplayItem) {
- return ARMORSTAND;
- }
+// if (displayItem instanceof ArmorStandDisplayItem) {
+// return ARMORSTAND;
+// }
if (displayItem instanceof VirtualDisplayItem) {
return VIRTUALITEM;
}
diff --git a/src/main/java/org/maxgamer/quickshop/shop/ShopControlPanelImpl.java b/src/main/java/org/maxgamer/quickshop/shop/ShopControlPanelImpl.java
index 3d7333058..578652ec5 100644
--- a/src/main/java/org/maxgamer/quickshop/shop/ShopControlPanelImpl.java
+++ b/src/main/java/org/maxgamer/quickshop/shop/ShopControlPanelImpl.java
@@ -27,4 +27,6 @@ public class ShopControlPanelImpl {
public ShopControlPanelImpl(QuickShop plugin) {
this.plugin = plugin;
}
+
+
}
diff --git a/src/main/java/org/maxgamer/quickshop/shop/VirtualDisplayItem.java b/src/main/java/org/maxgamer/quickshop/shop/VirtualDisplayItem.java
index e5e192804..bb7232bde 100644
--- a/src/main/java/org/maxgamer/quickshop/shop/VirtualDisplayItem.java
+++ b/src/main/java/org/maxgamer/quickshop/shop/VirtualDisplayItem.java
@@ -26,6 +26,7 @@ import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.injector.server.TemporaryPlayer;
+import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import org.bukkit.Chunk;
@@ -34,7 +35,6 @@ import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.maxgamer.quickshop.event.ShopDisplayItemSpawnEvent;
@@ -42,9 +42,7 @@ import org.maxgamer.quickshop.util.Util;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
-import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentSkipListSet;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
public class VirtualDisplayItem extends DisplayItem {
@@ -63,7 +61,7 @@ public class VirtualDisplayItem extends DisplayItem {
//The List which store packet sender
private final Set packetSenders = new ConcurrentSkipListSet<>();
- private final Queue asyncPacketSendQueue = new ConcurrentLinkedQueue<>();
+ // private final Queue asyncPacketSendQueue = new ConcurrentLinkedQueue<>();
private volatile boolean isDisplay;
@@ -82,8 +80,6 @@ public class VirtualDisplayItem extends DisplayItem {
//cache chunk x and z
private ShopChunk chunkLocation;
- @Nullable
- private BukkitTask asyncSendingTask;
public VirtualDisplayItem(@NotNull Shop shop) throws RuntimeException {
@@ -121,9 +117,10 @@ public class VirtualDisplayItem extends DisplayItem {
switch (version) {
case "v1_13_R1":
case "v1_13_R2":
- fakeItemPacket.getIntegers().write(6, 2);
- //int data to mark
- fakeItemPacket.getIntegers().write(7, 1);
+ fakeItemPacket.getIntegers()
+ .write(6, 2)
+ //int data to mark
+ .write(7, 1);
break;
//int data to mark
default:
@@ -246,15 +243,6 @@ public class VirtualDisplayItem extends DisplayItem {
}
}
- private void unload() {
- packetSenders.clear();
- if (packetAdapter != null) {
- protocolManager.getAsynchronousManager().unregisterAsyncHandler(packetAdapter);
- }
- if (asyncSendingTask != null && !asyncSendingTask.isCancelled()) {
- asyncSendingTask.cancel();
- }
- }
private void sendPacket(@NotNull Player player, @NotNull PacketContainer packet) {
try {
@@ -330,45 +318,38 @@ public class VirtualDisplayItem extends DisplayItem {
}
}
}
+
if (packetAdapter == null) {
packetAdapter = new PacketAdapter(plugin, ListenerPriority.HIGH, PacketType.Play.Server.MAP_CHUNK) {
@Override
public void onPacketSending(@NotNull PacketEvent event) {
//is really full chunk data
boolean isFull = event.getPacket().getBooleans().read(0);
- if (!shop.isLoaded() || !isDisplay || !isFull || !Util.isLoaded(shop.getLocation()) || shop.isLeftShop()) {
+ if (!shop.isLoaded() || !isDisplay || !isFull || shop.isLeftShop()) {
return;
}
+ StructureModifier integerStructureModifier = event.getPacket().getIntegers();
//chunk x
- int x = event.getPacket().getIntegers().read(0);
+ int x = integerStructureModifier.read(0);
//chunk z
- int z = event.getPacket().getIntegers().read(1);
- asyncPacketSendQueue.offer(() -> {
- //lazy initialize
- if (chunkLocation == null) {
- World world = shop.getLocation().getWorld();
- Chunk chunk = null;
- try {
- //sync getting chunk
- chunk = plugin.getServer().getScheduler().callSyncMethod(plugin, () -> shop.getLocation().getChunk()).get();
- } catch (InterruptedException | ExecutionException e) {
- throw new RuntimeException("An error occurred when getting chunk from the world", e);
- }
- chunkLocation = new ShopChunk(world.getName(), chunk.getX(), chunk.getZ());
- }
- Player player = event.getPlayer();
- if (player instanceof TemporaryPlayer) {
- return;
- }
- if (player == null || !player.isOnline()) {
- Util.debugLog("Cancelled packet sending cause player logged out when sending packets.");
- return;
- }
- if (chunkLocation.isSame(player.getWorld().getName(), x, z)) {
- packetSenders.add(player.getUniqueId());
- sendFakeItem(player);
- }
- });
+ int z = integerStructureModifier.read(1);
+
+ if (chunkLocation == null) {
+ World world = shop.getLocation().getWorld();
+ Chunk chunk = shop.getLocation().getChunk();
+ chunkLocation = new ShopChunk(world.getName(), chunk.getX(), chunk.getZ());
+ }
+ Player player = event.getPlayer();
+ if (player instanceof TemporaryPlayer) {
+ return;
+ }
+ if (player == null || !player.isOnline()) {
+ return;
+ }
+ if (chunkLocation.isSame(player.getWorld().getName(), x, z)) {
+ packetSenders.add(player.getUniqueId());
+ sendFakeItem(player);
+ }
// Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
// if (chunkLocation == null) {
// World world = shop.getLocation().getWorld();
@@ -383,16 +364,24 @@ public class VirtualDisplayItem extends DisplayItem {
}
};
}
- protocolManager.getAsynchronousManager().registerAsyncHandler(packetAdapter); //TODO: This may affects performance
- asyncSendingTask = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> {
- Runnable runnable = asyncPacketSendQueue.poll();
- while (runnable != null) {
- runnable.run();
- runnable = asyncPacketSendQueue.poll();
- }
- }, 0, 1);
+ protocolManager.addPacketListener(packetAdapter); //TODO: This may affects performance
+// asyncSendingTask = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> {
+// Runnable runnable = asyncPacketSendQueue.poll();
+// while (runnable != null) {
+// runnable.run();
+// runnable = asyncPacketSendQueue.poll();
+// }
+// }, 0, 1);
}
+ private void unload() {
+ packetSenders.clear();
+ if (packetAdapter != null) {
+ protocolManager.removePacketListener(packetAdapter);
+ }
+ }
+
+
public void sendFakeItem(@NotNull Player player) {
sendPacket(player, fakeItemPacket);
sendPacket(player, fakeItemMetaPacket);
diff --git a/src/main/java/org/maxgamer/quickshop/util/MsgUtil.java b/src/main/java/org/maxgamer/quickshop/util/MsgUtil.java
index a4b18451c..d83a0a31c 100644
--- a/src/main/java/org/maxgamer/quickshop/util/MsgUtil.java
+++ b/src/main/java/org/maxgamer/quickshop/util/MsgUtil.java
@@ -19,6 +19,7 @@
package org.maxgamer.quickshop.util;
+import com.dumptruckman.bukkit.configuration.json.JsonConfiguration;
import com.google.common.collect.Maps;
import lombok.Getter;
import lombok.SneakyThrows;
@@ -45,8 +46,7 @@ import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.ServiceInjector;
import org.maxgamer.quickshop.database.WarpedResultSet;
import org.maxgamer.quickshop.event.ShopControlPanelOpenEvent;
-import org.maxgamer.quickshop.fileportlek.old.IFile;
-import org.maxgamer.quickshop.fileportlek.old.JSONFile;
+import org.maxgamer.quickshop.fileportlek.old.HumanReadableJsonConfiguration;
import org.maxgamer.quickshop.shop.Shop;
import org.maxgamer.quickshop.util.language.game.GameLanguage;
import org.maxgamer.quickshop.util.language.game.MojangGameLanguageImpl;
@@ -75,10 +75,10 @@ public class MsgUtil {
private static boolean inited;
@Getter
private static YamlConfiguration itemi18n;
- private static IFile messagei18n;
+ private static JsonConfiguration messagei18n;
@Getter
private static YamlConfiguration potioni18n;
- private static IFile builtInLang;
+ private static JsonConfiguration builtInLang;
private static DecimalFormat processFormat() {
try {
@@ -172,11 +172,11 @@ public class MsgUtil {
public static String getMessageOfflinePlayer(
@NotNull String loc, @Nullable OfflinePlayer player, @NotNull String... args) {
try {
- Optional raw = messagei18n.getString(loc);
- if (!raw.isPresent()) {
+ String raw = messagei18n.getString(loc);
+ if (raw == null) {
return invaildMsg + ": " + loc;
}
- String filled = fillArgs(raw.get(), args);
+ String filled = fillArgs(raw, args);
if (player != null) {
if (plugin.getConfig().getBoolean("plugin.PlaceHolderAPI") && plugin.getPlaceHolderAPI() != null && plugin.getPlaceHolderAPI().isEnabled()) {
filled = PlaceholderAPI.setPlaceholders(player, filled);
@@ -228,16 +228,21 @@ public class MsgUtil {
String languageCode = plugin.getConfig().getString("language", "en-US").replace("_", "-");
// Init message file instance
- IFile messageFile;
+ JsonConfiguration messageFile;
File extractedMessageFile = new File(plugin.getDataFolder(), "messages.json");
String buildInMessageFilePath = "lang/" + languageCode + "/messages.json";
if (plugin.getResource(buildInMessageFilePath) == null) {
//Use default
buildInMessageFilePath = "lang-original/messages.json";
}
- messageFile = new JSONFile(plugin, extractedMessageFile, buildInMessageFilePath, true);
- messageFile.create();
-
+ if (!extractedMessageFile.exists()) {
+ try {
+ Files.copy(Objects.requireNonNull(plugin.getResource(buildInMessageFilePath)), extractedMessageFile.toPath());
+ } catch (IOException ioException) {
+ plugin.getLogger().log(Level.WARNING, "Cannot extract the messages.json file", ioException);
+ }
+ }
+ messageFile = HumanReadableJsonConfiguration.loadConfiguration(extractedMessageFile);
//Handle old message file and load it up
File oldMsgFile = new File(plugin.getDataFolder(), "messages.yml");
if (oldMsgFile.exists()) {
@@ -248,7 +253,11 @@ public class MsgUtil {
for (String key : oldMsgI18n.getKeys(true)) {
messageFile.set(key, oldMsgI18n.get(key));
}
- messageFile.save();
+ try {
+ messageFile.save(extractedMessageFile);
+ } catch (IOException ioException) {
+ ioException.printStackTrace();
+ }
try {
Files.move(
oldMsgFile.toPath(), new File(plugin.getDataFolder(), "messages.yml.bak").toPath());
@@ -269,16 +278,23 @@ public class MsgUtil {
}
//Init global instance
+ File buildInLangFile = new File(Util.getCacheFolder(), "bulitin-messages.json");
messagei18n = messageFile;
- builtInLang = new JSONFile(plugin, buildInMessageFilePath);
-
-
+ try {
+ if (buildInLangFile.exists()) {
+ buildInLangFile.delete();
+ }
+ Files.copy(Objects.requireNonNull(plugin.getResource(buildInMessageFilePath)), buildInLangFile.toPath());
+ } catch (IOException ioException) {
+ Util.debugLog("Cannot load default built-in language file: " + ioException.getMessage());
+ }
+ builtInLang = HumanReadableJsonConfiguration.loadConfiguration(buildInLangFile);
//Check the i18n language name and backup
- if (!messagei18n.getString("language-name").isPresent()) {
+ if (StringUtils.isEmpty(messagei18n.getString("language-name"))) {
setAndUpdate("language-name");
}
- String messageCodeInFile = messagei18n.getString("language-name").get();
- if (!messageCodeInFile.equals(languageCode)) {
+ String messageCodeInFile = messagei18n.getString("language-name");
+ if (!Objects.equals(messageCodeInFile, languageCode)) {
String backupFileName = "messages-bak-" + UUID.randomUUID().toString() + ".json";
Util.debugLog("Language name " + messageCodeInFile + " not matched with " + languageCode + ", replacing with build-in files and renaming current file to " + backupFileName);
plugin.getLogger().warning("Language name " + messageCodeInFile + " not matched with " + languageCode + ", replacing with build-in files and renaming current file to " + backupFileName);
@@ -296,10 +312,10 @@ public class MsgUtil {
/* Set default language vesion and update messages.yml */
int ver = 0;
- Optional strVer = messagei18n.getString("language-version");
- if (strVer.isPresent()) {
+ String strVer = messagei18n.getString("language-version");
+ if (StringUtils.isNumeric(strVer)) {
try {
- ver = Integer.parseInt(strVer.get());
+ ver = Integer.parseInt(strVer);
} catch (NumberFormatException ignore) {
}
}
@@ -323,7 +339,11 @@ public class MsgUtil {
}
/* Save the upgraded messages.yml */
- messagei18n.save();
+ try {
+ messagei18n.save(extractedMessageFile);
+ } catch (IOException ioException) {
+ ioException.printStackTrace();
+ }
plugin.getLogger().info("Completed to load plugin translations files.");
}
@@ -708,13 +728,13 @@ public class MsgUtil {
public static String getMessage(
@NotNull String loc, @Nullable CommandSender player, @NotNull String... args) {
try {
- final Optional raw = messagei18n.getString(loc);
- if (!raw.isPresent()) {
+ final String raw = messagei18n.getString(loc);
+ if (raw == null) {
Util.debugLog("ERR: MsgUtil cannot find the the phrase at " + loc + ", printing the all readed datas: " + messagei18n);
return invaildMsg + ": " + loc;
}
- String filled = fillArgs(raw.get(), args);
+ String filled = fillArgs(raw, args);
if (player instanceof OfflinePlayer) {
if (plugin.getPlaceHolderAPI() != null && plugin.getPlaceHolderAPI().isEnabled() && plugin.getConfig().getBoolean("plugin.PlaceHolderAPI")) {
try {
@@ -972,7 +992,7 @@ public class MsgUtil {
return Util.prettifyText(potionString);
}
- public static IFile getI18nFile() {
+ public static JsonConfiguration getI18nFile() {
return messagei18n;
}
@@ -1451,7 +1471,7 @@ public class MsgUtil {
}
for (String msg : messages) {
try {
- if (msg == null || msg.isEmpty()) {
+ if (StringUtils.isEmpty(msg)) {
continue;
}
plugin.getQuickChat().send(sender, chatColor + msg);
diff --git a/src/main/java/org/maxgamer/quickshop/util/envcheck/EnvironmentChecker.java b/src/main/java/org/maxgamer/quickshop/util/envcheck/EnvironmentChecker.java
index b198e0a2d..5031418d2 100644
--- a/src/main/java/org/maxgamer/quickshop/util/envcheck/EnvironmentChecker.java
+++ b/src/main/java/org/maxgamer/quickshop/util/envcheck/EnvironmentChecker.java
@@ -20,6 +20,7 @@
package org.maxgamer.quickshop.util.envcheck;
import lombok.SneakyThrows;
+import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.BlockPlaceEvent;
@@ -27,6 +28,8 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredListener;
import org.jetbrains.annotations.NotNull;
import org.maxgamer.quickshop.QuickShop;
+import org.maxgamer.quickshop.shop.DisplayItem;
+import org.maxgamer.quickshop.shop.DisplayType;
import org.maxgamer.quickshop.util.GameVersion;
import org.maxgamer.quickshop.util.JsonUtil;
import org.maxgamer.quickshop.util.ReflectFactory;
@@ -404,4 +407,12 @@ public class EnvironmentChecker {
}
return new ResultContainer(CheckResult.PASSED, "Passed checks");
}
+
+ @EnvCheckEntry(name = "PacketListenerAPI conflict Test", priority = 9)
+ public ResultContainer plapiConflictTest() {
+ if (plugin.isDisplay() && DisplayItem.getNowUsing() == DisplayType.VIRTUALITEM && Bukkit.getPluginManager().isPluginEnabled("ProtocolLib") && Bukkit.getPluginManager().isPluginEnabled("PacketListenerAPI")) {
+ return new ResultContainer(CheckResult.WARNING, "Virtual DisplayItem may stop working on your server. We already know plugin [PacketListenerAPI] conflict with plugin [ProtocolLib] (that we required to sending fake items). If you display not showing, please uninstall [PacketListenerAPI]. And it's fine to keep them if nothing wrong.");
+ }
+ return new ResultContainer(CheckResult.PASSED, "Passed checks");
+ }
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index fea8e75ce..4ef6a3db6 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -1,10 +1,28 @@
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
-
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+#This is example config, don't direct modify this file, all changes will revert when you reload the plugin.
+# READ ABOVE READ ABOVE READ ABOVE READ ABOVE READ ABOVE READ ABOVE READ ABOVE READ ABOVE READ ABOVE READ ABOVE
+# IF YOU WANT EDIT CONFIGURATION, THE FILE "config.yml" IS THE CORRECT FILE
#Do not touch if you not clear know about this
-config-version: 125
+config-version: 126
#Select the language you want to use, (e.g de), use only supported language codes from the list below.
#If you use a not exist/not support language, plugin will move to use en_US to keep everything working.
@@ -135,7 +153,7 @@ use-caching: true
#Control which one chat system QuickShop should to use.
#0=BungeeChat (Spigot Defaults)
-#1=Adventure
+#1=Adventure (Removed In Current Version)
chat-type: 0
#MySQL database settings.
@@ -221,6 +239,8 @@ shop:
sneak-to-create: false
sneak-to-trade: false
sneak-to-control: false
+ #Swap left and right click behavior
+ swap-click-behavior: false
#Should we automatically create the sign for the chest?
auto-sign: true
@@ -248,7 +268,6 @@ shop:
display-check-time: 40
#Allow display show stacks effect when stack creation turned on
- #!WIP, DON'T TURN ON IT BEFORE WE FINISH IT!
display-allow-stacks: false
#Use enhance display protect
@@ -417,8 +436,6 @@ shop:
remove-protection-trigger: true
#Allow quickshop selling/buying multi items in once transaction.
allow-stacks: false
- #Disallow player put items into shop container if that item not the shop item. WIP
- #deny-non-shop-items-to-shop-container: false
#List of items that can't be sold in shops. Anyone with quickshop.bypass. can bypass it
blacklist:
- Bedrock
@@ -663,6 +680,13 @@ integration:
warzone: false
#Player must have flags in the faction:
flags: [ ]
+ #Superior Skyblock Integration
+ superiorskyblock:
+ enable: false
+ #Does only island owner can create shops on island?
+ owner-create-only: false
+ #Delete shop when the shop owner kicked/quited from island
+ delete-shop-on-member-leave: true
#the protection that shop should check
protect:
explode: true
@@ -684,8 +708,6 @@ debug:
disable-debuglogger: false
#logging stacktrace when deleting shop
shop-deletion: false
- #Enable adventure debug flag
- adventure: false