mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/main/java/org/maxgamer/quickshop/QuickShop.java Former-commit-id: 56ac29442ad4af4bb817e11edea2623fb51c06db
This commit is contained in:
commit
d908eece39
7 files changed
+195
-52
No files matched your search
@@ -35,6 +35,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.api.QuickShopAPI;
|
||||
import org.maxgamer.quickshop.builtinlistener.InternalListener;
|
||||
import org.maxgamer.quickshop.command.CommandManager;
|
||||
import org.maxgamer.quickshop.database.*;
|
||||
@@ -471,6 +472,7 @@ public class QuickShop extends JavaPlugin {
|
||||
@Override
|
||||
public void onLoad() {
|
||||
instance = this;
|
||||
QuickShopAPI.setupApi(this);
|
||||
getDataFolder().mkdirs();
|
||||
replaceLogger();
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.maxgamer.quickshop.api;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
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.shop.Shop;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class DisplayItemAPI {
|
||||
private QuickShop plugin;
|
||||
|
||||
/**
|
||||
* Checks is a display item
|
||||
* @param itemStack The itemstack
|
||||
* @return yes or no
|
||||
*/
|
||||
public static boolean isDisplayItem(@NotNull ItemStack itemStack){
|
||||
return DisplayItem.checkIsGuardItemStack(itemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check is a shop's display item
|
||||
* @param itemStack The itemstack
|
||||
* @param shop The itemstack
|
||||
* @return yes or no
|
||||
*/
|
||||
public static boolean isShopDisplayItem(@NotNull ItemStack itemStack, @NotNull Shop shop){
|
||||
return DisplayItem.checkIsTargetShopDisplay(itemStack,shop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display type now using
|
||||
* @return The type of display now using
|
||||
*/
|
||||
public static DisplayType getNowUsing(){
|
||||
return DisplayItem.getNowUsing();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package org.maxgamer.quickshop.api;
|
||||
|
||||
public enum QAPIVersion {
|
||||
V1
|
||||
}
|
||||
@@ -1,44 +1,54 @@
|
||||
package org.maxgamer.quickshop.api;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.util.IntegrationHelper;
|
||||
import org.maxgamer.quickshop.util.compatibility.CompatibilityManager;
|
||||
|
||||
public class QuickShopAPI {
|
||||
protected static QuickShopAPI api;
|
||||
private static QuickShop plugin;
|
||||
|
||||
/**
|
||||
* Get api instance, you will get an object extends current class.
|
||||
* And you will need cast it to the version that you want to use.
|
||||
*
|
||||
* @param qapiVersion The version of api you want get.
|
||||
* @return
|
||||
* DO NOT CALL ME, IT JUST A INTERNAL METHOD, BUT BECAUSE CROSS-PACKAGE ACCESS, IT IS PUBLIC, SO DO NOT EXECUTE IT.
|
||||
* Go away =w=
|
||||
* @param qs The QuickShop plugin instance
|
||||
*/
|
||||
public static QuickShopAPI getApiInstance(QAPIVersion qapiVersion) {
|
||||
if (qapiVersion == null) {
|
||||
throw new IllegalArgumentException("QAPIVersion arg cannot be null");
|
||||
}
|
||||
if (api == null) {
|
||||
throw new IllegalStateException("QuickShop API not loaded yet, please try again later.");
|
||||
}
|
||||
switch (qapiVersion) {
|
||||
case V1:
|
||||
return api;
|
||||
default:
|
||||
throw new IllegalArgumentException("Cannot find the API (" + qapiVersion.name() + "), it not exist or removed.");
|
||||
}
|
||||
public static void setupApi(@NotNull QuickShop qs){
|
||||
plugin = qs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the api, you shouldn't use this method.
|
||||
*
|
||||
* @param clazz The clazz
|
||||
* Gets apis about shop
|
||||
* @return The Shop API
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setupApiInstance(@NotNull QuickShopAPI clazz) {
|
||||
api = clazz;
|
||||
public static @NotNull ShopAPI getShopAPI(){
|
||||
return new ShopAPI(plugin);
|
||||
}
|
||||
|
||||
public QAPIVersion getVersion() {
|
||||
return QAPIVersion.V1; //extend me
|
||||
/**
|
||||
* Gets apis about display item
|
||||
* @return The DisplayItem API
|
||||
*/
|
||||
public static @NotNull DisplayItemAPI getDisplayItemAPI(){
|
||||
return new DisplayItemAPI(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets anti-cheat compatibility manager to allow you access and process.
|
||||
* If you calling this before plugin loaded up, you might get nothing.
|
||||
* @return Compatibility Manager
|
||||
*/
|
||||
public static @Nullable CompatibilityManager getCompatibilityManager(){
|
||||
return plugin.getCompatibilityTool();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets protection plugins integration helper to allow hook your plugin to our checks system.
|
||||
* If you calling this before plugin loaded up, you might get nothing.
|
||||
* @return IntegrationHelper
|
||||
*/
|
||||
public static @Nullable IntegrationHelper getIntegrationManager(){
|
||||
return plugin.getIntegrationHelper();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package org.maxgamer.quickshop.api;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.shop.Shop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class ShopAPI {
|
||||
private QuickShop plugin;
|
||||
|
||||
/**
|
||||
* Gets shop from location
|
||||
* @param location The location
|
||||
* @return The shop in that location, may be null
|
||||
*/
|
||||
public @Nullable Shop getShop(@NotNull Location location){
|
||||
return plugin.getShopManager().getShop(location,false);
|
||||
}
|
||||
/**
|
||||
* Gets shop from location with caching
|
||||
* @param location The location
|
||||
* @return The shop in that location, may be null
|
||||
*/
|
||||
public @Nullable Shop getShopWithCaching(@NotNull Location location){
|
||||
if(plugin.getShopCache() == null){
|
||||
return getShop(location);
|
||||
}
|
||||
return plugin.getShopCache().getCaching(location,false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets shops in chunk
|
||||
* @param chunk The chunk
|
||||
* @return The shops in chunk, may be null
|
||||
*/
|
||||
public @Nullable Map<Location, Shop> getShop(@NotNull Chunk chunk){
|
||||
return plugin.getShopManager().getShops(chunk);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets shop from location
|
||||
* @param location The location
|
||||
* @return The shop in that location, may be null
|
||||
*/
|
||||
public @Nullable Shop getShopIncludeAttached(@NotNull Location location){
|
||||
return plugin.getShopManager().getShopIncludeAttached(location);
|
||||
}
|
||||
/**
|
||||
* Gets shop from location and use caching
|
||||
* @param location The location
|
||||
* @return The shop in that location, may be null
|
||||
*/
|
||||
public @Nullable Shop getShopIncludeAttachedWithCaching(@NotNull Location location){
|
||||
if(plugin.getShopCache() == null){
|
||||
return getShopIncludeAttached(location);
|
||||
}
|
||||
return plugin.getShopCache().getCaching(location,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of copy for loaded shops
|
||||
* This is a expensive action, please caching the result
|
||||
* @return The copy of loaded shops
|
||||
*/
|
||||
public @NotNull List<Shop> getLoadedShops(){
|
||||
return new ArrayList<>(plugin.getShopManager().getLoadedShops());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of a player's all shops
|
||||
* This is a expensive action, please caching the result
|
||||
* @param uuid Player UUID
|
||||
* @return The list of player's all shops
|
||||
*/
|
||||
public @NotNull List<Shop> getPlayerAllShops(@NotNull UUID uuid){
|
||||
return plugin.getShopManager().getPlayerAllShops(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all shops on this server
|
||||
* This is a expensive action, please caching the result
|
||||
* @return The list of all shops on server
|
||||
*/
|
||||
public @NotNull List<Shop> getAllShops(){
|
||||
return new ArrayList<>( plugin.getShopManager().getAllShops());
|
||||
}
|
||||
/**
|
||||
* Gets a list of all shops in world
|
||||
* This is a expensive action, please caching the result
|
||||
* @param world The world that you want get shops
|
||||
* @return The list of all shops in world
|
||||
*/
|
||||
public @NotNull List<Shop> getShopsInWorld(@NotNull World world){
|
||||
return plugin.getShopManager().getShopsInWorld(world);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package org.maxgamer.quickshop.api.v1;
|
||||
|
||||
import org.maxgamer.quickshop.api.QAPIVersion;
|
||||
import org.maxgamer.quickshop.api.QuickShopAPI;
|
||||
|
||||
public class QuickShopAPI_v1 extends QuickShopAPI {
|
||||
@Override
|
||||
public QAPIVersion getVersion() {
|
||||
return QAPIVersion.V1; //V1 impl
|
||||
}
|
||||
|
||||
}
|
||||
@@ -95,8 +95,7 @@ public class MsgUtil {
|
||||
.getLogger()
|
||||
.info("Cleaning purchase messages from the database that are over a week old...");
|
||||
// 604800,000 msec = 1 week.
|
||||
long weekAgo = System.currentTimeMillis() - 604800000;
|
||||
plugin.getDatabaseHelper().cleanMessage(weekAgo);
|
||||
plugin.getDatabaseHelper().cleanMessage(System.currentTimeMillis() - 604800000);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,7 +316,7 @@ public class MsgUtil {
|
||||
}
|
||||
|
||||
public static void loadEnchi18n() {
|
||||
plugin.getLogger().info("Starting loading Enchantment i18n...");
|
||||
plugin.getLogger().info("Starting loading enchantments translation...");
|
||||
File enchi18nFile = new File(plugin.getDataFolder(), "enchi18n.yml");
|
||||
if (!enchi18nFile.exists()) {
|
||||
plugin.getLogger().info("Creating enchi18n.yml");
|
||||
@@ -351,13 +350,14 @@ public class MsgUtil {
|
||||
Level.WARNING,
|
||||
"Could not load/save transaction enchname from enchi18n.yml. Skipping.");
|
||||
}
|
||||
plugin.getLogger().info("Complete to load enchname i18n.");
|
||||
plugin.getLogger().info("Complete to load enchantments translation.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Itemi18n fron file
|
||||
*/
|
||||
public static void loadItemi18n() {
|
||||
plugin.getLogger().info("Starting loading items translation...");
|
||||
File itemi18nFile = new File(plugin.getDataFolder(), "itemi18n.yml");
|
||||
if (!itemi18nFile.exists()) {
|
||||
plugin.getLogger().info("Creating itemi18n.yml");
|
||||
@@ -393,11 +393,11 @@ public class MsgUtil {
|
||||
Level.WARNING,
|
||||
"Could not load/save transaction itemname from itemi18n.yml. Skipping.");
|
||||
}
|
||||
plugin.getLogger().info("Complete to load Itemname i18n.");
|
||||
plugin.getLogger().info("Complete to load items translation.");
|
||||
}
|
||||
|
||||
public static void loadPotioni18n() {
|
||||
plugin.getLogger().info("Starting loading Potion i18n...");
|
||||
plugin.getLogger().info("Starting loading potions translation...");
|
||||
File potioni18nFile = new File(plugin.getDataFolder(), "potioni18n.yml");
|
||||
if (!potioni18nFile.exists()) {
|
||||
plugin.getLogger().info("Creating potioni18n.yml");
|
||||
@@ -430,7 +430,7 @@ public class MsgUtil {
|
||||
Level.WARNING,
|
||||
"Could not load/save transaction potionname from potioni18n.yml. Skipping.");
|
||||
}
|
||||
plugin.getLogger().info("Complete to load potionname i18n.");
|
||||
plugin.getLogger().info("Complete to load potions effect translation.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -684,7 +684,6 @@ public class MsgUtil {
|
||||
if (plugin.getPlaceHolderAPI() != null && plugin.getPlaceHolderAPI().isEnabled()) {
|
||||
try {
|
||||
filled = PlaceholderAPI.setPlaceholders((OfflinePlayer) player, filled);
|
||||
Util.debugLog("Processed message " + filled + " by PlaceHolderAPI.");
|
||||
} catch (Exception ignored) {
|
||||
if (((OfflinePlayer) player).getPlayer() != null) {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user