Move every external plugins references in a dedicated module

This commit is contained in:
Flowsqy 2022-04-17 22:07:54 +02:00
parent 07426afe62
commit b0522b7fe7
20 changed files with 150 additions and 124 deletions

62
external/pom.xml vendored Normal file
View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ShopChest-parent</artifactId>
<groupId>de.epiceric</groupId>
<version>1.14.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>shopchest-external</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</dependency>
<dependency>
<groupId>fr.xephi</groupId>
<artifactId>authme</artifactId>
</dependency>
<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Core</artifactId>
</dependency>
<dependency>
<groupId>com.github.rlf.uSkyBlock</groupId>
<artifactId>uSkyBlock-API</artifactId>
</dependency>
<dependency>
<groupId>com.wasteofplastic</groupId>
<artifactId>askyblock</artifactId>
</dependency>
<dependency>
<groupId>com.github.TechFortress</groupId>
<artifactId>GriefPrevention</artifactId>
</dependency>
<dependency>
<groupId>me.wiefferink</groupId>
<artifactId>areashop</artifactId>
</dependency>
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
</dependency>
<dependency>
<groupId>com.github.IntellectualSites.PlotSquared</groupId>
<artifactId>Core</artifactId>
</dependency>
<dependency>
<groupId>com.github.TownyAdvanced</groupId>
<artifactId>Towny</artifactId>
</dependency>
<dependency>
<groupId>pl.gnacik.islandworld</groupId>
<artifactId>IslandWorld</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
package de.epiceric.shopchest.external;
package de.epiceric.shopchest.external.flags;
import org.bukkit.Material;

View File

@ -1,4 +1,4 @@
package de.epiceric.shopchest.external;
package de.epiceric.shopchest.external.flags;
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;

View File

@ -1,4 +1,4 @@
package de.epiceric.shopchest.external;
package de.epiceric.shopchest.external.flags;
import java.util.Arrays;
import java.util.Collection;

View File

@ -1,4 +1,4 @@
package de.epiceric.shopchest.external;
package de.epiceric.shopchest.external.flags;
import java.util.Optional;

View File

@ -13,7 +13,7 @@ import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.event.ShopCreateEvent;
import de.epiceric.shopchest.event.ShopExtendEvent;
import de.epiceric.shopchest.external.BentoBoxShopFlag;
import de.epiceric.shopchest.external.flags.BentoBoxShopFlag;
import de.epiceric.shopchest.utils.Utils;
import world.bentobox.bentobox.api.flags.FlagListener;

View File

@ -11,8 +11,8 @@ import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.event.ShopCreateEvent;
import de.epiceric.shopchest.event.ShopExtendEvent;
import de.epiceric.shopchest.external.PlotSquaredOldShopFlag;
import de.epiceric.shopchest.external.PlotSquaredShopFlag;
import de.epiceric.shopchest.external.flags.PlotSquaredOldShopFlag;
import de.epiceric.shopchest.external.flags.PlotSquaredShopFlag;
import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.Utils;
import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package de.epiceric.shopchest.listeners;
package de.epiceric.shopchest.external.listeners2;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

View File

@ -1,4 +1,4 @@
package de.epiceric.shopchest.listeners;
package de.epiceric.shopchest.external.listeners2;
import java.util.Collection;
import java.util.UUID;

View File

@ -20,54 +20,10 @@
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
</dependency>
<dependency>
<groupId>fr.xephi</groupId>
<artifactId>authme</artifactId>
</dependency>
<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Core</artifactId>
</dependency>
<dependency>
<groupId>com.github.rlf.uSkyBlock</groupId>
<artifactId>uSkyBlock-API</artifactId>
</dependency>
<dependency>
<groupId>com.wasteofplastic</groupId>
<artifactId>askyblock</artifactId>
</dependency>
<dependency>
<groupId>com.github.TechFortress</groupId>
<artifactId>GriefPrevention</artifactId>
</dependency>
<dependency>
<groupId>me.wiefferink</groupId>
<artifactId>areashop</artifactId>
</dependency>
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
</dependency>
<dependency>
<groupId>com.github.IntellectualSites.PlotSquared</groupId>
<artifactId>Core</artifactId>
</dependency>
<dependency>
<groupId>com.github.TownyAdvanced</groupId>
<artifactId>Towny</artifactId>
</dependency>
<dependency>
<groupId>pl.gnacik.islandworld</groupId>
<artifactId>IslandWorld</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.codemc.worldguardwrapper</groupId>
<artifactId>worldguardwrapper</artifactId>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>

View File

@ -1,20 +1,20 @@
package de.epiceric.shopchest;
import com.palmergames.bukkit.towny.Towny;
import com.plotsquared.core.PlotSquared;
import com.wasteofplastic.askyblock.ASkyBlock;
//import com.palmergames.bukkit.towny.Towny;
//import com.plotsquared.core.PlotSquared;
//import com.wasteofplastic.askyblock.ASkyBlock;
import de.epiceric.shopchest.command.ShopCommand;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.config.hologram.HologramFormat;
import de.epiceric.shopchest.event.ShopInitializedEvent;
import de.epiceric.shopchest.external.BentoBoxShopFlag;
import de.epiceric.shopchest.external.PlotSquaredOldShopFlag;
import de.epiceric.shopchest.external.PlotSquaredShopFlag;
import de.epiceric.shopchest.external.WorldGuardShopFlag;
import de.epiceric.shopchest.external.listeners.*;
//import de.epiceric.shopchest.external.BentoBoxShopFlag;
//import de.epiceric.shopchest.external.PlotSquaredOldShopFlag;
//import de.epiceric.shopchest.external.PlotSquaredShopFlag;
//import de.epiceric.shopchest.external.WorldGuardShopFlag;
//import de.epiceric.shopchest.external.listeners.*;
import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.listeners.BentoBoxListener;
import de.epiceric.shopchest.listeners.WorldGuardListener;
//import de.epiceric.shopchest.external.listeners2.BentoBoxListener;
//import de.epiceric.shopchest.listeners.WorldGuardListener;
import de.epiceric.shopchest.listeners.*;
import de.epiceric.shopchest.nms.Platform;
import de.epiceric.shopchest.nms.reflection.PlatformImpl;
@ -24,22 +24,22 @@ import de.epiceric.shopchest.sql.MySQL;
import de.epiceric.shopchest.sql.SQLite;
import de.epiceric.shopchest.utils.*;
import de.epiceric.shopchest.utils.UpdateChecker.UpdateCheckerResult;
import fr.xephi.authme.AuthMe;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import me.wiefferink.areashop.AreaShop;
//import fr.xephi.authme.AuthMe;
//import me.ryanhamshire.GriefPrevention.GriefPrevention;
//import me.wiefferink.areashop.AreaShop;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
//import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.codemc.worldguardwrapper.WorldGuardWrapper;
import pl.islandworld.IslandWorld;
import us.talabrek.ultimateskyblock.api.uSkyBlockAPI;
import world.bentobox.bentobox.BentoBox;
//import org.codemc.worldguardwrapper.WorldGuardWrapper;
//import pl.islandworld.IslandWorld;
//import us.talabrek.ultimateskyblock.api.uSkyBlockAPI;
//import world.bentobox.bentobox.BentoBox;
import java.io.File;
import java.io.FileWriter;
@ -70,6 +70,7 @@ public class ShopChest extends JavaPlugin {
private String downloadLink = "";
private ShopUtils shopUtils;
private FileWriter fw;
/*
private Plugin worldGuard;
private Towny towny;
private AuthMe authMe;
@ -79,6 +80,7 @@ public class ShopChest extends JavaPlugin {
private GriefPrevention griefPrevention;
private AreaShop areaShop;
private BentoBox bentoBox;
*/
private ShopUpdater updater;
private ExecutorService shopCreationThreadPool;
@ -127,10 +129,13 @@ public class ShopChest extends JavaPlugin {
debug("Loading ShopChest version " + getDescription().getVersion());
// TODO EXTERNAL : Register WorldGuard Flags
/*
worldGuard = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
if (worldGuard != null) {
WorldGuardShopFlag.register(this);
}
}*/
}
@Override
@ -208,12 +213,14 @@ public class ShopChest extends JavaPlugin {
shopCommand = new ShopCommand(this);
shopCreationThreadPool = new ThreadPoolExecutor(0, 8,
5L, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
// TODO EXTERNAL : Load it the right way
loadExternalPlugins();
initDatabase();
checkForUpdates();
registerListeners();
registerExternalListeners();
//registerExternalListeners();
initializeShops();
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
@ -277,6 +284,9 @@ public class ShopChest extends JavaPlugin {
}
private void loadExternalPlugins() {
// TODO EXTERNAL : Load Integrations
/*
Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
if (townyPlugin instanceof Towny) {
towny = (Towny) townyPlugin;
@ -316,7 +326,11 @@ public class ShopChest extends JavaPlugin {
if (bentoBoxPlugin instanceof BentoBox) {
bentoBox = (BentoBox) bentoBoxPlugin;
}
*/
// TODO EXTERNAL : Register flags and
/*
if (hasWorldGuard()) {
WorldGuardWrapper.getInstance().registerEvents(this);
}
@ -332,7 +346,7 @@ public class ShopChest extends JavaPlugin {
if (hasBentoBox()) {
BentoBoxShopFlag.register(this);
}
}*/
}
private void initDatabase() {
@ -411,6 +425,9 @@ public class ShopChest extends JavaPlugin {
getServer().getPluginManager().registerEvents(new BlockExplodeListener(this), this);
}
// TODO EXTERNAL : Register Listeners 1
/*
if (hasWorldGuard()) {
getServer().getPluginManager().registerEvents(new WorldGuardListener(this), this);
@ -421,9 +438,11 @@ public class ShopChest extends JavaPlugin {
if (hasBentoBox()) {
getServer().getPluginManager().registerEvents(new BentoBoxListener(this), this);
}
}*/
}
// TODO : EXTERNAL : Register Listeners 2
/*
private void registerExternalListeners() {
if (hasASkyBlock())
getServer().getPluginManager().registerEvents(new ASkyBlockListener(this), this);
@ -444,7 +463,7 @@ public class ShopChest extends JavaPlugin {
getServer().getPluginManager().registerEvents(new de.epiceric.shopchest.external.listeners.WorldGuardListener(this), this);
if (hasBentoBox())
getServer().getPluginManager().registerEvents(new de.epiceric.shopchest.external.listeners.BentoBoxListener(this), this);
}
} */
/**
* Initializes the shops
@ -552,57 +571,40 @@ public class ShopChest extends JavaPlugin {
return updater;
}
/**
* @return Whether the plugin 'AreaShop' is enabled
*/
// TODO EXTERNAL Plugins supports
/*
public boolean hasAreaShop() {
return Config.enableAreaShopIntegration && areaShop != null && areaShop.isEnabled();
}
/**
* @return Whether the plugin 'GriefPrevention' is enabled
*/
public boolean hasGriefPrevention() {
return Config.enableGriefPreventionIntegration && griefPrevention != null && griefPrevention.isEnabled();
}
/**
* @return An instance of {@link GriefPrevention} or {@code null} if GriefPrevention is not enabled
*/
public GriefPrevention getGriefPrevention() {
return griefPrevention;
}
/**
* @return Whether the plugin 'IslandWorld' is enabled
*/
public boolean hasIslandWorld() {
return Config.enableIslandWorldIntegration && islandWorld != null && islandWorld.isEnabled();
}
/**
* @return Whether the plugin 'ASkyBlock' is enabled
*/
public boolean hasASkyBlock() {
return Config.enableASkyblockIntegration && aSkyBlock != null && aSkyBlock.isEnabled();
}
/**
* @return Whether the plugin 'uSkyBlock' is enabled
*/
public boolean hasUSkyBlock() {
return Config.enableUSkyblockIntegration && uSkyBlock != null && uSkyBlock.isEnabled();
}
/**
* @return An instance of {@link uSkyBlockAPI} or {@code null} if uSkyBlock is not enabled
*/
public uSkyBlockAPI getUSkyBlock() {
return uSkyBlock;
}
/**
* @return Whether the plugin 'PlotSquared' is enabled
*/
public boolean hasPlotSquared() {
if (!Config.enablePlotsquaredIntegration) {
return false;
@ -616,32 +618,23 @@ public class ShopChest extends JavaPlugin {
return p != null && p.isEnabled();
}
/**
* @return Whether the plugin 'AuthMe' is enabled
*/
public boolean hasAuthMe() {
return Config.enableAuthMeIntegration && authMe != null && authMe.isEnabled();
}
/**
* @return Whether the plugin 'Towny' is enabled
*/
public boolean hasTowny() {
return Config.enableTownyIntegration && towny != null && towny.isEnabled();
}
/**
* @return Whether the plugin 'WorldGuard' is enabled
*/
public boolean hasWorldGuard() {
return Config.enableWorldGuardIntegration && worldGuard != null && worldGuard.isEnabled();
}
/**
* @return Whether the plugin 'WorldGuard' is enabled
*/
public boolean hasBentoBox() {
return Config.enableBentoBoxIntegration && bentoBox != null && bentoBox.isEnabled();
}
*/
/**
* @return ShopChest's {@link ShopUtils} containing some important methods

View File

@ -8,8 +8,8 @@ import de.epiceric.shopchest.event.ShopCreateEvent;
import de.epiceric.shopchest.event.ShopInfoEvent;
import de.epiceric.shopchest.event.ShopOpenEvent;
import de.epiceric.shopchest.event.ShopRemoveEvent;
import de.epiceric.shopchest.external.PlotSquaredOldShopFlag;
import de.epiceric.shopchest.external.PlotSquaredShopFlag;
//import de.epiceric.shopchest.external.PlotSquaredOldShopFlag;
//import de.epiceric.shopchest.external.PlotSquaredShopFlag;
import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.Message;
import de.epiceric.shopchest.language.Replacement;
@ -23,7 +23,7 @@ import de.epiceric.shopchest.utils.ItemUtils;
import de.epiceric.shopchest.utils.Permissions;
import de.epiceric.shopchest.utils.ShopUtils;
import de.epiceric.shopchest.utils.Utils;
import fr.xephi.authme.api.v3.AuthMeApi;
//import fr.xephi.authme.api.v3.AuthMeApi;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
@ -51,9 +51,9 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scheduler.BukkitRunnable;
import org.codemc.worldguardwrapper.WorldGuardWrapper;
import org.codemc.worldguardwrapper.flag.IWrappedFlag;
import org.codemc.worldguardwrapper.flag.WrappedState;
//import org.codemc.worldguardwrapper.WorldGuardWrapper;
//import org.codemc.worldguardwrapper.flag.IWrappedFlag;
//import org.codemc.worldguardwrapper.flag.WrappedState;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
@ -126,8 +126,10 @@ public class ShopInteractListener implements Listener {
if (ClickType.getPlayerClickType(p).getClickType() != ClickType.EnumClickType.CREATE)
return;
// TODO EXTERNAL : Check AUTH
/*
if (Config.enableAuthMeIntegration && plugin.hasAuthMe() && !AuthMeApi.getInstance().isAuthenticated(p))
return;
return;*/
if (e.useInteractedBlock() == Event.Result.DENY && !p.hasPermission(Permissions.CREATE_PROTECTED)) {
p.sendMessage(LanguageUtils.getMessage(Message.NO_PERMISSION_CREATE_PROTECTED));
@ -255,6 +257,8 @@ public class ShopInteractListener implements Listener {
// TODO: Outsource shop use external permission
boolean externalPluginsAllowed = true;
// TODO EXTERNAL : Check USE
/*
if (plugin.hasPlotSquared() && Config.enablePlotsquaredIntegration) {
try {
Class.forName("com.plotsquared.core.PlotSquared");
@ -277,7 +281,7 @@ public class ShopInteractListener implements Listener {
if (!flag.isPresent()) plugin.debug("WorldGuard flag '" + flagName + "' is not present!");
WrappedState state = flag.map(f -> wgWrapper.queryFlag(p, b.getLocation(), f).orElse(WrappedState.DENY)).orElse(WrappedState.DENY);
externalPluginsAllowed = state == WrappedState.ALLOW;
}
}*/
if (shop.getShopType() == ShopType.ADMIN) {
if (externalPluginsAllowed || p.hasPermission(Permissions.BYPASS_EXTERNAL_PLUGIN)) {
@ -380,6 +384,8 @@ public class ShopInteractListener implements Listener {
// TODO: Outsource shop use external permission
boolean externalPluginsAllowed = true;
// TODO EXTERNAL : Check USE
/*
if (plugin.hasPlotSquared() && Config.enablePlotsquaredIntegration) {
try {
Class.forName("com.plotsquared.core.PlotSquared");
@ -402,7 +408,7 @@ public class ShopInteractListener implements Listener {
if (!flag.isPresent()) plugin.debug("WorldGuard flag '" + flagName + "' is not present!");
WrappedState state = flag.map(f -> wgWrapper.queryFlag(p, b.getLocation(), f).orElse(WrappedState.DENY)).orElse(WrappedState.DENY);
externalPluginsAllowed = state == WrappedState.ALLOW;
}
}*/
ItemStack itemStack = shop.getProduct().getItemStack();
@ -467,7 +473,8 @@ public class ShopInteractListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if (Config.enableAuthMeIntegration && plugin.hasAuthMe() && !AuthMeApi.getInstance().isAuthenticated(e.getPlayer())) return;
// TODO EXTERNAL : Check AUTH
//if (Config.enableAuthMeIntegration && plugin.hasAuthMe() && !AuthMeApi.getInstance().isAuthenticated(e.getPlayer())) return;
handleInteractEvent(e);
}

10
pom.xml
View File

@ -17,6 +17,7 @@
<module>nms/v1_17_1_R1</module>
<module>nms/v1_18_R1</module>
<module>nms/v1_18_R2</module>
<module>external</module>
</modules>
<name>ShopChest</name>
@ -294,7 +295,8 @@
<version>1.18.7-SNAPSHOT</version>
</dependency>
<!-- Internal nms shaded dependencies -->
<!-- Internal shaded dependencies -->
<!-- NMS -->
<dependency>
<groupId>de.epiceric</groupId>
<artifactId>shopchest-nms-interface</artifactId>
@ -325,6 +327,12 @@
<artifactId>shopchest-nms-v1_18_R2</artifactId>
<version>1.0.0</version>
</dependency>
<!-- External plugins -->
<dependency>
<groupId>de.epiceric</groupId>
<artifactId>shopchest-external</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>