Merge fdc3581049
into 9537d93688
This commit is contained in:
commit
eefcf32245
Binary file not shown.
7
pom.xml
7
pom.xml
|
@ -175,6 +175,13 @@
|
|||
<version>1.18.20</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.OmerBenGera</groupId>
|
||||
<artifactId>SuperiorSkyblockAPI</artifactId>
|
||||
<version>api-version</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/SuperiorSkyblockAPI.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- Shaded dependencies -->
|
||||
<dependency>
|
||||
|
|
|
@ -38,6 +38,7 @@ 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.SuperiorSkyblockShopIslandPermission;
|
||||
import de.epiceric.shopchest.external.WorldGuardShopFlag;
|
||||
import de.epiceric.shopchest.external.listeners.ASkyBlockListener;
|
||||
import de.epiceric.shopchest.external.listeners.GriefPreventionListener;
|
||||
|
@ -55,6 +56,7 @@ import de.epiceric.shopchest.listeners.NotifyPlayerOnJoinListener;
|
|||
import de.epiceric.shopchest.listeners.ShopInteractListener;
|
||||
import de.epiceric.shopchest.listeners.ShopItemListener;
|
||||
import de.epiceric.shopchest.listeners.ShopUpdateListener;
|
||||
import de.epiceric.shopchest.listeners.SuperiorSkyblockListener;
|
||||
import de.epiceric.shopchest.listeners.WorldGuardListener;
|
||||
import de.epiceric.shopchest.shop.Shop;
|
||||
import de.epiceric.shopchest.shop.Shop.ShopType;
|
||||
|
@ -100,6 +102,7 @@ public class ShopChest extends JavaPlugin {
|
|||
private GriefPrevention griefPrevention;
|
||||
private AreaShop areaShop;
|
||||
private BentoBox bentoBox;
|
||||
private boolean superiorskyblock;
|
||||
private ShopUpdater updater;
|
||||
private ExecutorService shopCreationThreadPool;
|
||||
|
||||
|
@ -319,6 +322,13 @@ public class ShopChest extends JavaPlugin {
|
|||
bentoBox = (BentoBox) bentoBoxPlugin;
|
||||
}
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("SuperiorSkyblock2").isEnabled()) {
|
||||
superiorskyblock = true;
|
||||
}
|
||||
else {
|
||||
superiorskyblock = false;
|
||||
}
|
||||
|
||||
if (hasWorldGuard()) {
|
||||
WorldGuardWrapper.getInstance().registerEvents(this);
|
||||
}
|
||||
|
@ -335,6 +345,10 @@ public class ShopChest extends JavaPlugin {
|
|||
if (hasBentoBox()) {
|
||||
BentoBoxShopFlag.register(this);
|
||||
}
|
||||
|
||||
if (hasSuperiorSkyblock()) {
|
||||
SuperiorSkyblockShopIslandPermission.register(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadMetrics() {
|
||||
|
@ -451,6 +465,10 @@ public class ShopChest extends JavaPlugin {
|
|||
if (hasBentoBox()) {
|
||||
getServer().getPluginManager().registerEvents(new BentoBoxListener(this), this);
|
||||
}
|
||||
|
||||
if (hasSuperiorSkyblock())
|
||||
getServer().getPluginManager().registerEvents(new SuperiorSkyblockListener(this), this);
|
||||
|
||||
}
|
||||
|
||||
private void registerExternalListeners() {
|
||||
|
@ -470,6 +488,8 @@ 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);
|
||||
if (hasSuperiorSkyblock())
|
||||
getServer().getPluginManager().registerEvents(new de.epiceric.shopchest.external.listeners.SuperiorSkyblockListener(this), this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -665,6 +685,13 @@ public class ShopChest extends JavaPlugin {
|
|||
return Config.enableBentoBoxIntegration && bentoBox != null && bentoBox.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the plugin 'SuperiorSkyblock' is enabled
|
||||
*/
|
||||
public boolean hasSuperiorSkyblock() {
|
||||
return superiorskyblock;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ShopChest's {@link ShopUtils} containing some important methods
|
||||
*/
|
||||
|
|
|
@ -198,6 +198,11 @@ public class Config {
|
|||
* Whether BentoBox integration should be enabled
|
||||
**/
|
||||
public static boolean enableBentoBoxIntegration;
|
||||
|
||||
/**
|
||||
* Whether SuperiorSkyblock integration should be enabled
|
||||
**/
|
||||
public static boolean enableSuperiorSkyblockIntegration;
|
||||
|
||||
/**
|
||||
* Whether IslandWorld integration should be enabled
|
||||
|
@ -312,6 +317,16 @@ public class Config {
|
|||
* The language configuration of the currently selected language file
|
||||
*/
|
||||
public static LanguageConfiguration langConfig;
|
||||
|
||||
/**
|
||||
* Name of the IslandPrivilage... SuperiorSkyblock
|
||||
**/
|
||||
public static String SuperiorSkyblockIslandPrivilegeName;
|
||||
|
||||
/**
|
||||
* Whether IslandPrivilage option should be enabled... SuperiorSkyblock
|
||||
**/
|
||||
public static boolean SuperiorSkyblockEnableIslandPrivilege;
|
||||
|
||||
private ShopChest plugin;
|
||||
|
||||
|
@ -487,6 +502,9 @@ public class Config {
|
|||
enableUSkyblockIntegration = plugin.getConfig().getBoolean("enable-uskyblock-integration");
|
||||
enableASkyblockIntegration = plugin.getConfig().getBoolean("enable-askyblock-integration");
|
||||
enableBentoBoxIntegration = plugin.getConfig().getBoolean("enable-bentobox-integration");
|
||||
enableSuperiorSkyblockIntegration = plugin.getConfig().getBoolean("enable-superiorskyblock-integration");
|
||||
SuperiorSkyblockIslandPrivilegeName = plugin.getConfig().getString("superiorskyblock.islandprivilege-name");
|
||||
SuperiorSkyblockEnableIslandPrivilege = plugin.getConfig().getBoolean("superiorskyblock.enable-islandprivilege");
|
||||
enableIslandWorldIntegration = plugin.getConfig().getBoolean("enable-islandworld-integration");
|
||||
enableGriefPreventionIntegration = plugin.getConfig().getBoolean("enable-griefprevention-integration");
|
||||
enableAreaShopIntegration = plugin.getConfig().getBoolean("enable-areashop-integration");
|
||||
|
|
25
src/main/java/de/epiceric/shopchest/external/SuperiorSkyblockShopIslandPermission.java
vendored
Normal file
25
src/main/java/de/epiceric/shopchest/external/SuperiorSkyblockShopIslandPermission.java
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
package de.epiceric.shopchest.external;
|
||||
|
||||
import de.epiceric.shopchest.*;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
|
||||
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI;
|
||||
import com.bgsoftware.superiorskyblock.api.island.IslandPrivilege;
|
||||
|
||||
public class SuperiorSkyblockShopIslandPermission {
|
||||
private static String name = Config.SuperiorSkyblockIslandPrivilegeName;
|
||||
|
||||
public static void register(ShopChest plugin) {
|
||||
if(!Config.SuperiorSkyblockEnableIslandPrivilege) return;
|
||||
try {
|
||||
IslandPrivilege.register(name);
|
||||
SuperiorSkyblockAPI.getSuperiorSkyblock().getMenus().updatePermission(IslandPrivilege.getByName(name));
|
||||
|
||||
plugin.debug("Registered SuperiorSkyblock shop Island Privilege");
|
||||
}catch(Exception e) {
|
||||
plugin.getLogger().warning("Failed to register SuperiorSkyblock shop Island Privilege");
|
||||
plugin.debug("Failed to register SuperiorSkyblock shop Island Privilege");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
90
src/main/java/de/epiceric/shopchest/external/listeners/SuperiorSkyblockListener.java
vendored
Normal file
90
src/main/java/de/epiceric/shopchest/external/listeners/SuperiorSkyblockListener.java
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
package de.epiceric.shopchest.external.listeners;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
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.utils.Utils;
|
||||
|
||||
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI;
|
||||
import com.bgsoftware.superiorskyblock.api.island.*;
|
||||
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
|
||||
|
||||
public class SuperiorSkyblockListener implements Listener {
|
||||
private final ShopChest plugin;
|
||||
|
||||
public SuperiorSkyblockListener(ShopChest plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onCreateShop(ShopCreateEvent e) {
|
||||
if (!Config.enableSuperiorSkyblockIntegration)
|
||||
return;
|
||||
|
||||
Set<Location> chestLocations = Utils.getChestLocations(e.getShop());
|
||||
for (Location loc : chestLocations) {
|
||||
if (handleForLocation(e.getPlayer(), loc, e))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onExtendShop(ShopExtendEvent e) {
|
||||
if (!Config.enableSuperiorSkyblockIntegration)
|
||||
return;
|
||||
|
||||
handleForLocation(e.getPlayer(), e.getNewChestLocation(), e);
|
||||
}
|
||||
|
||||
private boolean handleForLocation(Player player, Location loc, Cancellable e) {
|
||||
Island island = SuperiorSkyblockAPI.getIslandAt(loc);
|
||||
if (island == null)
|
||||
return false;
|
||||
|
||||
SuperiorPlayer sp = SuperiorSkyblockAPI.getPlayer(player);
|
||||
if(sp == null)
|
||||
return false;
|
||||
|
||||
if (Config.SuperiorSkyblockEnableIslandPrivilege) {
|
||||
|
||||
IslandPrivilege ip;
|
||||
|
||||
try {
|
||||
ip = IslandPrivilege.getByName(Config.SuperiorSkyblockIslandPrivilegeName);
|
||||
}catch(Exception ex) {
|
||||
e.setCancelled(true);
|
||||
plugin.debug("Cancel Reason: SuperiorSkyblock Couldn't find an IslandPrivilege with the name "+Config.SuperiorSkyblockIslandPrivilegeName);
|
||||
ex.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage("Perm: "+ip+" status: "+sp.hasPermission(ip));
|
||||
|
||||
if(!sp.hasPermission(ip)) {
|
||||
e.setCancelled(true);
|
||||
plugin.debug("Cancel Reason: SuperiorSkyblock no permission "+Config.SuperiorSkyblockIslandPrivilegeName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!island.isMember(sp) && !island.getOwner().getName().equalsIgnoreCase(sp.getName().toLowerCase())) {
|
||||
e.setCancelled(true);
|
||||
plugin.debug("Cancel Reason: SuperiorSkyblock");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package de.epiceric.shopchest.listeners;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.shop.Shop;
|
||||
import com.bgsoftware.superiorskyblock.api.events.*;
|
||||
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
|
||||
|
||||
public class SuperiorSkyblockListener implements Listener {
|
||||
private ShopChest plugin;
|
||||
|
||||
public SuperiorSkyblockListener(ShopChest plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onIslandDeleted(IslandDisbandEvent e) {
|
||||
deleteShops(e.getIsland().getIslandMembers(true));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onIslandQuit(IslandQuitEvent e) {
|
||||
deleteShops(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onTeamKick(IslandKickEvent e) {
|
||||
deleteShops(e.getTarget());
|
||||
}
|
||||
|
||||
private void deleteShops(List<SuperiorPlayer> members) {
|
||||
deleteShops(members, null);
|
||||
}
|
||||
|
||||
private void deleteShops(SuperiorPlayer vendorUuid) {
|
||||
deleteShops(null, vendorUuid);
|
||||
}
|
||||
|
||||
|
||||
private void deleteShops(List<SuperiorPlayer> members, SuperiorPlayer vendorUuid) {
|
||||
if (!Config.enableSuperiorSkyblockIntegration)
|
||||
return;
|
||||
|
||||
Collection<Shop> shops = plugin.getShopUtils().getShops();
|
||||
for (Shop shop : shops) {
|
||||
|
||||
if(members != null) {
|
||||
for(SuperiorPlayer sp : members) {
|
||||
if(shop.getVendor().getName().equalsIgnoreCase(sp.getName().toLowerCase())) {
|
||||
plugin.getShopUtils().removeShop(shop, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(vendorUuid != null) {
|
||||
if(shop.getVendor().getName().equalsIgnoreCase(vendorUuid.getName().toLowerCase())) {
|
||||
plugin.getShopUtils().removeShop(shop, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -58,6 +58,7 @@ enable-plotsquared-integration: true
|
|||
enable-uskyblock-integration: true
|
||||
enable-askyblock-integration: true
|
||||
enable-bentobox-integration: true
|
||||
enable-superiorskyblock-integration: true
|
||||
enable-islandworld-integration: true
|
||||
enable-griefprevention-integration: true
|
||||
enable-areashop-integration: true
|
||||
|
@ -221,4 +222,9 @@ database:
|
|||
username: ""
|
||||
|
||||
# ...password you are going to login with
|
||||
password: ""
|
||||
password: ""
|
||||
|
||||
superiorskyblock:
|
||||
# Remember that if you want to enable this option, you have to add this element (https://hastebin.com/igogekiger.bash) item inside 'SuperiorSkyblock2/menus/permissions.yml' at the end!
|
||||
enable-islandprivilege: false
|
||||
islandprivilege-name: "SHOPCHEST"
|
Loading…
Reference in New Issue