Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added lib/SuperiorSkyblockAPI.jar
Binary file not shown.
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -169,6 +169,13 @@
<scope>system</scope>
<systemPath>${project.basedir}/lib/PlotSquared-Bukkit-4.4.495.jar</systemPath>
</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>
Expand Down
1 change: 1 addition & 0 deletions script/entries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,7 @@ item.minecraft.phantom_membrane
item.minecraft.phantom_spawn_egg
item.minecraft.pig_spawn_egg
item.minecraft.piglin_banner_pattern.desc
item.minecraft.piglin_brute_spawn_egg
item.minecraft.piglin_spawn_egg
item.minecraft.pillager_spawn_egg
item.minecraft.pink_dye
Expand Down
36 changes: 31 additions & 5 deletions src/main/java/de/epiceric/shopchest/ShopChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.stream.Stream;

import com.palmergames.bukkit.towny.Towny;
import com.plotsquared.core.PlotSquared;
import com.wasteofplastic.askyblock.ASkyBlock;

import org.bstats.bukkit.Metrics;
Expand All @@ -37,6 +36,7 @@
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;
Expand All @@ -54,6 +54,7 @@
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;
Expand Down Expand Up @@ -99,6 +100,7 @@ public class ShopChest extends JavaPlugin {
private GriefPrevention griefPrevention;
private AreaShop areaShop;
private BentoBox bentoBox;
private boolean superiorskyblock;
private ShopUpdater updater;
private ExecutorService shopCreationThreadPool;

Expand Down Expand Up @@ -185,6 +187,8 @@ public void onEnable() {
case "v1_14_R1":
case "v1_15_R1":
case "v1_16_R1":
case "v1_16_R2":
case "v1_16_R3":
break;
default:
debug("Server version not officially supported: " + Utils.getServerVersion() + "!");
Expand Down Expand Up @@ -254,10 +258,8 @@ public void onDisable() {
shopCreationThreadPool.shutdown();
}

for (Shop shop : shopUtils.getShops()) {
shopUtils.removeShop(shop, false);
debug("Removed shop (#" + shop.getID() + ")");
}
shopUtils.removeShops();
debug("Removed shops");

if (database != null && database.isInitialized()) {
if (database instanceof SQLite) {
Expand Down Expand Up @@ -318,6 +320,13 @@ private void loadExternalPlugins() {
bentoBox = (BentoBox) bentoBoxPlugin;
}

if (getServer().getPluginManager().getPlugin("SuperiorSkyblock2").isEnabled()) {
superiorskyblock = true;
}
else {
superiorskyblock = false;
}

if (hasWorldGuard()) {
WorldGuardWrapper.getInstance().registerEvents(this);
}
Expand All @@ -334,6 +343,10 @@ private void loadExternalPlugins() {
if (hasBentoBox()) {
BentoBoxShopFlag.register(this);
}

if (hasSuperiorSkyblock()) {
SuperiorSkyblockShopIslandPermission.register(this);
}
}

private void loadMetrics() {
Expand Down Expand Up @@ -450,6 +463,10 @@ private void registerListeners() {
if (hasBentoBox()) {
getServer().getPluginManager().registerEvents(new BentoBoxListener(this), this);
}

if (hasSuperiorSkyblock())
getServer().getPluginManager().registerEvents(new SuperiorSkyblockListener(this), this);

}

private void registerExternalListeners() {
Expand All @@ -469,6 +486,8 @@ private void registerExternalListeners() {
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);
}

/**
Expand Down Expand Up @@ -660,6 +679,13 @@ public boolean hasBentoBox() {
return 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
*/
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/de/epiceric/shopchest/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -487,6 +502,9 @@ public void reload(boolean firstLoad, boolean langReload, boolean showMessages)
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");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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.IslandFlag;
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);
IslandFlag.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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,44 @@
public class WorldGuardShopFlag {

public static void register(final ShopChest plugin) {
WorldGuardWrapper wrapper = WorldGuardWrapper.getInstance();

Optional<IWrappedFlag<WrappedState>> createFlag = wrapper.registerFlag("create-shop",
WrappedState.class, Config.wgAllowCreateShopDefault ? WrappedState.ALLOW : WrappedState.DENY);

Optional<IWrappedFlag<WrappedState>> useFlag = wrapper.registerFlag("use-shop",
WrappedState.class, Config.wgAllowUseShopDefault ? WrappedState.ALLOW : WrappedState.DENY);

Optional<IWrappedFlag<WrappedState>> useAdminFlag = wrapper.registerFlag("use-admin-shop",
WrappedState.class, Config.wgAllowUseAdminShopDefault ? WrappedState.ALLOW : WrappedState.DENY);

plugin.debug("Flag create-shop: " + String.valueOf(createFlag.isPresent()));
plugin.debug("Flag use-shop: " + String.valueOf(useFlag.isPresent()));
plugin.debug("Flag use-admin-shop: " + String.valueOf(useAdminFlag.isPresent()));
try {
WorldGuardWrapper wrapper = WorldGuardWrapper.getInstance();
Optional<IWrappedFlag<WrappedState>> createFlag = null;
Optional<IWrappedFlag<WrappedState>> useFlag = null;
Optional<IWrappedFlag<WrappedState>> useAdminFlag = null;

if(! wrapper.getFlag("create-shop", WrappedState.class).isPresent() ) {
createFlag = wrapper.registerFlag("create-shop",
WrappedState.class, Config.wgAllowCreateShopDefault ? WrappedState.ALLOW : WrappedState.DENY);
}
else {
createFlag = wrapper.getFlag("create-shop", WrappedState.class);
}

if(! wrapper.getFlag("use-shop", WrappedState.class).isPresent() ) {
useFlag = wrapper.registerFlag("use-shop",
WrappedState.class, Config.wgAllowUseShopDefault ? WrappedState.ALLOW : WrappedState.DENY);
}
else {
useFlag = wrapper.getFlag("use-shop", WrappedState.class);
}

if(! wrapper.getFlag("use-admin-shop", WrappedState.class).isPresent() ) {
useAdminFlag = wrapper.registerFlag("use-admin-shop",
WrappedState.class, Config.wgAllowUseAdminShopDefault ? WrappedState.ALLOW : WrappedState.DENY);
}
else {
useAdminFlag = wrapper.getFlag("use-admin-shop", WrappedState.class);
}



plugin.debug("Flag create-shop: " + String.valueOf(createFlag.isPresent()));
plugin.debug("Flag use-shop: " + String.valueOf(useFlag.isPresent()));
plugin.debug("Flag use-admin-shop: " + String.valueOf(useAdminFlag.isPresent()));
}catch(Exception e) {
e.printStackTrace();
}
}

}
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,12 @@ public static void load() {
itemNames.add(new ItemName(Material.WEEPING_VINES_PLANT, langConfig.getString("block.minecraft.weeping_vines_plant", "Weeping Vines Plant")));
itemNames.add(new ItemName(Material.ZOGLIN_SPAWN_EGG, langConfig.getString("item.minecraft.zoglin_spawn_egg", "Zoglin Spawn Egg")));
itemNames.add(new ItemName(Material.ZOMBIFIED_PIGLIN_SPAWN_EGG, langConfig.getString("item.minecraft.zombified_piglin_spawn_egg", "Zombified Piglin Spawn Egg")));

if (Utils.getMajorVersion() > 16 || Utils.getRevision() >= 2) {
// Add 1.16.2 item names
itemNames.add(new ItemName(Material.PIGLIN_BRUTE_SPAWN_EGG, langConfig.getString("item.minecraft.piglin_brute_spawn_egg", "Piglin Brute Spawn Egg")));
}

} else {
// Add pre-1.16 item names that don't exist anymore
itemNames.add(new ItemName(Material.valueOf("ZOMBIE_PIGMAN_SPAWN_EGG"), langConfig.getString("item.minecraft.zombie_pigman_spawn_egg", "Zombie Pigman Spawn Egg")));
Expand Down
Loading