Fix for hooks.

This commit is contained in:
Brianna 2019-05-16 01:09:58 -04:00
parent 856dc3e6c4
commit 52020dec8a
32 changed files with 14 additions and 1090 deletions

View File

@ -130,77 +130,11 @@
<version>2.3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>askyblock</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>factions</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>griefprevention</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>kingdoms</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>plotsquared</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>redprotect</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>towny</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>uskyblock</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>worldguard</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>worldguard6</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.milkbowl</groupId>
<artifactId>vault</artifactId>
<version>1.7.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>fabledskyblock</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -2,9 +2,14 @@ package com.songoda.epicfurnaces;
import com.songoda.epicfurnaces.command.CommandManager;
import com.songoda.epicfurnaces.handlers.BlacklistHandler;
import com.songoda.epicfurnaces.hooks.*;
import com.songoda.epicfurnaces.listeners.*;
import com.songoda.epicfurnaces.managers.*;
import com.songoda.epicfurnaces.listeners.BlockListeners;
import com.songoda.epicfurnaces.listeners.FurnaceListeners;
import com.songoda.epicfurnaces.listeners.InteractListeners;
import com.songoda.epicfurnaces.listeners.InventoryListeners;
import com.songoda.epicfurnaces.managers.BoostManager;
import com.songoda.epicfurnaces.managers.FurnaceManager;
import com.songoda.epicfurnaces.managers.HologramManager;
import com.songoda.epicfurnaces.managers.LevelManager;
import com.songoda.epicfurnaces.storage.Storage;
import com.songoda.epicfurnaces.storage.types.StorageMysql;
import com.songoda.epicfurnaces.storage.types.StorageYaml;
@ -31,14 +36,13 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import static com.songoda.epicfurnaces.utils.StringUtils.formatText;
import static java.util.Arrays.asList;
@ -50,7 +54,6 @@ public class EpicFurnaces extends JavaPlugin {
private BukkitEnums bukkitEnums;
private CommandManager commandManager;
private FurnaceManager furnaceManager;
private HookManager hookManager;
private LevelManager levelManager;
private Locale locale;
private Storage storage;
@ -105,7 +108,6 @@ public class EpicFurnaces extends JavaPlugin {
this.blacklistHandler = new BlacklistHandler(this);
this.bukkitEnums = new BukkitEnums(this);
this.levelManager = new LevelManager(this);
this.hookManager = new HookManager(this);
if (!setupEconomy()) {
getLogger().severe("Economy provider not found/not supported, disabling...");
@ -139,25 +141,6 @@ public class EpicFurnaces extends JavaPlugin {
new InteractListeners(this),
new InventoryListeners(this))).forEach(listener -> pluginManager.registerEvents(listener, this));
// Register default hooks
if (pluginManager.isPluginEnabled("ASkyBlock")) hookManager.register(ASkyBlockHook::new);
if (pluginManager.isPluginEnabled("FactionsFramework")) hookManager.register(FactionsHook::new);
if (pluginManager.isPluginEnabled("GriefPrevention")) hookManager.register(GriefPreventionHook::new);
if (pluginManager.isPluginEnabled("Kingdoms")) hookManager.register(KingdomsHook::new);
if (pluginManager.isPluginEnabled("PlotSquared")) hookManager.register(PlotSquaredHook::new);
if (pluginManager.isPluginEnabled("RedProtect")) hookManager.register(RedProtectHook::new);
if (pluginManager.isPluginEnabled("Towny")) hookManager.register(TownyHook::new);
if (pluginManager.isPluginEnabled("USkyBlock")) hookManager.register(USkyBlockHook::new);
if (pluginManager.isPluginEnabled("FabledSkyBlock")) hookManager.register(FabledSkyBlockHook::new);
if (pluginManager.isPluginEnabled("WorldGuard")) {
if (currentVersion >= 13) {
hookManager.register(WorldGuard7Hook::new);
} else {
hookManager.register(WorldGuard6Hook::new);
}
}
new Metrics(this);
Bukkit.getConsoleSender().sendMessage(formatText("&a============================="));
@ -296,10 +279,6 @@ public class EpicFurnaces extends JavaPlugin {
return Optional.ofNullable(hologramManager);
}
public HookManager getHookManager() {
return hookManager;
}
public Storage getStorage() {
return storage;
}

View File

@ -35,7 +35,6 @@ public class InteractListeners implements Listener {
Block block = event.getClickedBlock();
if (!player.hasPermission("EpicFurnaces.overview")
|| !instance.getHookManager().canBuild(player, event.getClickedBlock().getLocation())
|| event.getAction() != Action.LEFT_CLICK_BLOCK
|| player.isSneaking()
|| (block.getType() != Material.FURNACE && block.getType() != instance.getBukkitEnums().getMaterial("BURNING_FURNACE").getType())

View File

@ -1,62 +0,0 @@
package com.songoda.epicfurnaces.managers;
import com.google.common.base.Preconditions;
import com.songoda.epicfurnaces.EpicFurnaces;
import com.songoda.epicfurnaces.hooks.ProtectionPluginHook;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Supplier;
public class HookManager {
private final EpicFurnaces instance;
private Set<ProtectionPluginHook> protectionHooks;
public HookManager(EpicFurnaces instance) {
this.protectionHooks = new HashSet<>();
this.instance = instance;
protectionHooks.clear();
}
public void register(Supplier<ProtectionPluginHook> hookSupplier) {
this.registerProtectionHook(hookSupplier.get());
}
private void registerProtectionHook(ProtectionPluginHook hook) {
Preconditions.checkNotNull(hook, "Cannot register null hooks");
Preconditions.checkNotNull(hook.getPlugin(), "Protection plugin hooks returns null plugin instance (#getPlugin())");
JavaPlugin hookPlugin = hook.getPlugin();
for (ProtectionPluginHook existingHook : protectionHooks) {
if (existingHook.getPlugin().equals(hookPlugin)) {
throw new IllegalArgumentException("Hook already registered");
}
}
FileConfiguration configuration = instance.getConfiguration("hooks");
configuration.addDefault("hooks." + hookPlugin.getName(), true);
if (!configuration.getBoolean("hooks." + hookPlugin.getName(), true)) return;
configuration.options().copyDefaults(true);
instance.save("hooks");
protectionHooks.add(hook);
instance.getLogger().info("Registered protection hooks for plugin: " + hook.getPlugin().getName() + " v" + hook.getPlugin().getDescription().getVersion());
}
public boolean canBuild(Player player, Location location) {
if (player.hasPermission(instance.getDescription().getName() + ".bypass")) {
return true;
}
for (ProtectionPluginHook hook : protectionHooks) {
if (!hook.canBuild(player, location)) {
return false;
}
}
return true;
}
}

View File

@ -1,35 +0,0 @@
<?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>hooks</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>askyblock</artifactId>
<dependencies>
<dependency>
<groupId>com.wasteofplastic</groupId>
<artifactId>askyblock</artifactId>
<version>3.0.6.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>manager</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,59 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import com.wasteofplastic.askyblock.ASkyBlock;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import com.wasteofplastic.askyblock.Island;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
import java.util.Set;
import java.util.UUID;
public class ASkyBlockHook implements ClaimableProtectionPluginHook {
private final ASkyBlockAPI skyblock;
public ASkyBlockHook() {
this.skyblock = ASkyBlockAPI.getInstance();
}
@Override
public JavaPlugin getPlugin() {
return ASkyBlock.getPlugin();
}
@Override
public boolean canBuild(Player player, Location location) {
Island island = skyblock.getIslandAt(location);
if (island == null) return true;
UUID owner = island.getOwner();
UUID playerUUID = player.getUniqueId();
if (owner == null || owner.equals(playerUUID)) return true;
List<UUID> teamMembers = skyblock.getTeamMembers(owner);
if (teamMembers.contains(playerUUID)) return true;
Set<Location> coopIslands = skyblock.getCoopIslands(player);
for (Location islandLocation : coopIslands) {
if (skyblock.getIslandAt(islandLocation).getOwner().equals(playerUUID)) {
return true;
}
}
return false;
}
@Override
public boolean isInClaim(Location location, String id) {
return skyblock.getOwner(location).toString().equals(id);
}
@Override
public String getClaimID(String name) {
return null;
}
}

View File

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>hooks</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>fabledskyblock</artifactId>
<dependencies>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>skyblockearth</artifactId>
<version>59</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>manager</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,33 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import me.goodandevil.skyblock.SkyBlock;
import me.goodandevil.skyblock.api.SkyBlockAPI;
import me.goodandevil.skyblock.api.island.Island;
import me.goodandevil.skyblock.api.island.IslandRole;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashSet;
import java.util.Set;
public class FabledSkyBlockHook implements ProtectionPluginHook {
private final Set<IslandRole> allowedRoles = new HashSet<IslandRole>() {{
add(IslandRole.COOP);
add(IslandRole.MEMBER);
add(IslandRole.OPERATOR);
add(IslandRole.OWNER);
}};
public boolean canBuild(Player player, Location location) {
Island island = SkyBlockAPI.getIslandManager().getIslandAtLocation(location);
return allowedRoles.stream().anyMatch(role -> island.getPlayersWithRole(role).contains(player.getUniqueId())) ||
island.getCoopPlayers().contains(player.getUniqueId());
}
@Override
public JavaPlugin getPlugin() {
return SkyBlock.getInstance();
}
}

View File

@ -1,36 +0,0 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>hooks</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
</parent>
<artifactId>factions</artifactId>
<dependencies>
<dependency>
<groupId>me.markeh</groupId>
<artifactId>factionsframework</artifactId>
<version>1.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>manager</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,37 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import me.markeh.factionsframework.FactionsFramework;
import me.markeh.factionsframework.entities.*;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class FactionsHook implements ClaimableProtectionPluginHook {
private final FactionsFramework factions;
public FactionsHook() {
this.factions = FactionsFramework.get();
}
public JavaPlugin getPlugin() {
return factions;
}
public boolean canBuild(Player player, Location location) {
FPlayer fPlayer = FPlayers.getBySender(player);
Faction faction = Factions.getFactionAt(location);
return faction.isNone() || fPlayer.getFaction().equals(faction);
}
public boolean isInClaim(Location location, String id) {
return Factions.getFactionAt(location).getId().equals(id);
}
public String getClaimID(String name) {
Faction faction = Factions.getByName(name, "");
return (faction != null) ? faction.getId() : null;
}
}

View File

@ -1,36 +0,0 @@
<?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>hooks</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>griefprevention</artifactId>
<dependencies>
<dependency>
<groupId>me.ryanhamshire</groupId>
<artifactId>GriefPrevention</artifactId>
<version>16.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>manager</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,27 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class GriefPreventionHook implements ProtectionPluginHook {
private final GriefPrevention griefPrevention;
public GriefPreventionHook() {
this.griefPrevention = GriefPrevention.instance;
}
public JavaPlugin getPlugin() {
return griefPrevention;
}
public boolean canBuild(Player player, Location location) {
Claim claim = griefPrevention.dataStore.getClaimAt(location, false, null);
return claim != null && claim.allowBuild(player, Material.STONE) == null;
}
}

View File

@ -1,40 +0,0 @@
<?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>hooks</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>kingdoms</artifactId>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org</groupId>
<artifactId>kingdoms</artifactId>
<version>13.0.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>manager</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>manager</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,35 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.kingdoms.constants.land.Land;
import org.kingdoms.constants.land.SimpleChunkLocation;
import org.kingdoms.constants.player.KingdomPlayer;
import org.kingdoms.main.Kingdoms;
import org.kingdoms.manager.game.GameManagement;
public class KingdomsHook implements ProtectionPluginHook {
private final Kingdoms kingdoms;
public KingdomsHook() {
this.kingdoms = Kingdoms.getInstance();
}
public JavaPlugin getPlugin() {
return kingdoms;
}
public boolean canBuild(Player player, Location location) {
KingdomPlayer kPlayer = GameManagement.getPlayerManager().getOfflineKingdomPlayer(player).getKingdomPlayer();
if (kPlayer.getKingdom() == null) return true;
SimpleChunkLocation chunkLocation = new SimpleChunkLocation(location.getChunk());
Land land = GameManagement.getLandManager().getOrLoadLand(chunkLocation);
String owner = land.getOwner();
return owner == null || kPlayer.getKingdom().getKingdomName().equals(owner);
}
}

View File

@ -1,25 +0,0 @@
<?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>hooks</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>manager</artifactId>
<name>Hook-Manager</name>
<description>Provides intermediary support between the core and its hooks.</description>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,36 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import org.bukkit.Location;
/**
* A more specific implementation of {@link ProtectionPluginHook} used internally by
* EpicFurnaces to retain more information about default hooks. Often times this
* interface is not recommended over the ProtectionPluginHook interface as its methods
* will not often be used by implementation, though they are available if more information
* is desired. It is, however, recommended to use the former
*
* @author Parker Hawke - 2008Choco
*/
public interface ClaimableProtectionPluginHook extends ProtectionPluginHook {
/**
* Check whether the provided location is in the claim with the given String ID
*
* @param location the location to check
* @param id the ID of the claim to check
* @return true if the location is within the claim, false otherwise or if the
* claim ID does not exist
*/
boolean isInClaim(Location location, String id);
/**
* Get the ID of the claim with the given name. Often times this is unnecessary
* as unique IDs are not provided by a claim implementation, though for plugins
* such as factions, the passed parameter is the name of the faction and the
* returned String is its unique ID
*
* @param name the name of the claim to check
* @return the unique String ID. null if no claim exists
*/
String getClaimID(String name);
}

View File

@ -1,8 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import org.bukkit.Location;
public interface CraftBukkitHook {
void broadcastParticle(Location location, String name, int amount, String... optional);
}

View File

@ -1,45 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
/**
* Represents a hooks for a protection plugin. This is used by EpicSpawners to determine
* whether a block break should be successful or not according to the current state of
* another plugin. For plugins providing claims with unique String IDs, see the
* {@link ClaimableProtectionPluginHook} for a more detailed implementation.
*/
public interface ProtectionPluginHook {
/**
* The plugin to which this plugin hooks belongs. Must not be null
*
* @return the hooking plugin
*/
JavaPlugin getPlugin();
/**
* Check whether the provided player may build at the specified location
*
* @param player the player to check
* @param location the location to check
*
* @return true if player is permitted to build, false otherwise
*/
boolean canBuild(Player player, Location location);
/**
* Check whether the provided player may build at the specified block
*
* @param player the player to check
* @param block the block to check
*
* @return true if player is permitted to build, false otherwise
*/
default boolean canBuild(Player player, Block block) {
return block != null && canBuild(player, block.getLocation());
}
}

View File

@ -1,34 +0,0 @@
<?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>hooks</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>plotsquared</artifactId>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com</groupId>
<artifactId>plotsquared</artifactId>
<version>4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>manager</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,29 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import com.github.intellectualsites.plotsquared.api.PlotAPI;
import com.github.intellectualsites.plotsquared.bukkit.BukkitMain;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class PlotSquaredHook implements ProtectionPluginHook {
private final PlotAPI plotAPI;
public PlotSquaredHook() {
this.plotAPI = new PlotAPI();
}
public boolean canBuild(Player player, Location location) {
PlotPlayer plotPlayer = PlotPlayer.wrap(player);
Plot plot = plotPlayer.getCurrentPlot();
return plot != null && plot.hasOwner() && plot.isAdded(player.getUniqueId());
}
public JavaPlugin getPlugin() { // BukkitMain? Really?
return JavaPlugin.getPlugin(BukkitMain.class);
}
}

View File

@ -1,30 +0,0 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>EpicFurnaces-Parent</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hooks</artifactId>
<packaging>pom</packaging>
<modules>
<module>manager</module>
<module>uskyblock</module>
<module>towny</module>
<module>redprotect</module>
<module>plotsquared</module>
<module>kingdoms</module>
<module>factions</module>
<module>askyblock</module>
<module>griefprevention</module>
<module>worldguard6</module>
<module>worldguard7</module>
<module>fabledskyblock</module>
</modules>
</project>

View File

@ -1,36 +0,0 @@
<?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>hooks</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>redprotect</artifactId>
<dependencies>
<dependency>
<groupId>br.net.fabiozumbi12</groupId>
<artifactId>RedProtect</artifactId>
<version>7.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>manager</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,29 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI;
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
import br.net.fabiozumbi12.RedProtect.Bukkit.Region;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class RedProtectHook implements ProtectionPluginHook {
private final RedProtect redProtect;
public RedProtectHook() {
this.redProtect = RedProtect.get();
}
public JavaPlugin getPlugin() {
return redProtect;
}
public boolean canBuild(Player player, Location location) {
RedProtectAPI api = redProtect.getAPI();
Region region = api.getRegion(location);
return region != null && region.canBuild(player);
}
}

View File

@ -1,36 +0,0 @@
<?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>hooks</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>towny</artifactId>
<dependencies>
<dependency>
<groupId>com.palmergames.bukkit</groupId>
<artifactId>towny</artifactId>
<version>0.93.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>manager</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,54 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class TownyHook implements ClaimableProtectionPluginHook {
private final Towny towny;
public TownyHook() {
this.towny = Towny.getPlugin();
}
public JavaPlugin getPlugin() {
return towny;
}
public boolean canBuild(Player player, Location location) {
if (TownyUniverse.isWilderness(location.getBlock()) || !TownyUniverse.getTownBlock(location).hasTown())
return true;
try {
Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
return resident.hasTown() && TownyUniverse.getTownName(location).equals(resident.getTown().getName());
} catch (NotRegisteredException e) {
e.printStackTrace();
return false;
}
}
public boolean isInClaim(Location location, String id) {
try {
return TownyUniverse.isWilderness(location.getBlock()) && TownyUniverse.getTownBlock(location).getTown().getUID().toString().equals(id);
} catch (NotRegisteredException e) {
e.printStackTrace();
return false;
}
}
public String getClaimID(String name) {
try {
return TownyUniverse.getDataSource().getTown(name).getUID().toString();
} catch (NotRegisteredException e) {
e.printStackTrace();
return null;
}
}
}

View File

@ -1,33 +0,0 @@
<?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>hooks</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>uskyblock</artifactId>
<dependencies>
<dependency>
<groupId>us.talabrek</groupId>
<artifactId>ultimateskyblock</artifactId>
<version>2.7.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>manager</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,33 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import us.talabrek.ultimateskyblock.api.uSkyBlockAPI;
public class USkyBlockHook implements ClaimableProtectionPluginHook {
private final uSkyBlockAPI uSkyBlockAPI;
public USkyBlockHook() {
this.uSkyBlockAPI = (uSkyBlockAPI) Bukkit.getPluginManager().getPlugin("USkyBlock");
}
public JavaPlugin getPlugin() { // uSkyBlockAPI is also an instance of JavaPlugin
return (JavaPlugin) uSkyBlockAPI;
}
public boolean canBuild(Player player, Location location) {
return uSkyBlockAPI.getIslandInfo(location).getOnlineMembers().contains(player) || uSkyBlockAPI.getIslandInfo(location).isLeader(player);
}
public boolean isInClaim(Location location, String id) {
return uSkyBlockAPI.getIslandInfo(location).getLeader().equals(id);
}
public String getClaimID(String name) {
return null;
}
}

View File

@ -1,34 +0,0 @@
<?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>hooks</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>worldguard6</artifactId>
<dependencies>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>6.2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>manager</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,22 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class WorldGuard6Hook implements ProtectionPluginHook {
private final WorldGuardPlugin worldGuard;
public WorldGuard6Hook() {
this.worldGuard = WorldGuardPlugin.inst();
}
public JavaPlugin getPlugin() {
return WorldGuardPlugin.inst();
}
public boolean canBuild(Player player, Location location) {
return worldGuard.canBuild(player, location);
}
}

View File

@ -1,40 +0,0 @@
<?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>hooks</artifactId>
<groupId>com.songoda</groupId>
<version>maven-version-number</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>worldguard</artifactId>
<dependencies>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>7.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<version>7.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.13.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>manager</artifactId>
<version>maven-version-number</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,29 +0,0 @@
package com.songoda.epicfurnaces.hooks;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class WorldGuard7Hook implements ProtectionPluginHook {
private final WorldGuard worldGuard;
public WorldGuard7Hook() {
this.worldGuard = WorldGuard.getInstance();
}
public JavaPlugin getPlugin() {
return WorldGuardPlugin.inst();
}
public boolean canBuild(Player player, Location location) {
RegionQuery q = worldGuard.getPlatform().getRegionContainer().createQuery();
ApplicableRegionSet ars = q.getApplicableRegions(BukkitAdapter.adapt(player.getLocation()));
return ars.testState(WorldGuardPlugin.inst().wrapPlayer(player), Flags.BUILD);
}
}

View File

@ -9,7 +9,6 @@
<modules>
<module>core</module>
<module>hooks</module>
</modules>
<build>