diff --git a/pom.xml b/pom.xml
index bcc7439..f44bf22 100644
--- a/pom.xml
+++ b/pom.xml
@@ -106,6 +106,10 @@
bstats-repo
http://repo.bstats.org/content/repositories/releases/
+
+ xephi-repo
+ http://ci.xephi.fr/plugin/repository/everything/
+
@@ -138,6 +142,12 @@
bstats-bukkit
1.1
+
+ fr.xephi
+ authme
+ 5.2
+ provided
+
diff --git a/src/main/java/de/epiceric/shopchest/ShopChest.java b/src/main/java/de/epiceric/shopchest/ShopChest.java
index 0a594d0..40a59a6 100644
--- a/src/main/java/de/epiceric/shopchest/ShopChest.java
+++ b/src/main/java/de/epiceric/shopchest/ShopChest.java
@@ -17,6 +17,7 @@ import de.epiceric.shopchest.sql.SQLite;
import de.epiceric.shopchest.utils.*;
import de.epiceric.shopchest.utils.UpdateChecker.UpdateCheckerResult;
import de.epiceric.shopchest.worldguard.ShopFlag;
+import fr.xephi.authme.AuthMe;
import net.milkbowl.vault.economy.Economy;
import org.bstats.Metrics;
import org.bukkit.Bukkit;
@@ -46,6 +47,7 @@ public class ShopChest extends JavaPlugin {
private FileWriter fw;
private WorldGuardPlugin worldGuard;
private Towny towny;
+ private AuthMe authMe;
private ShopUpdater updater;
/**
@@ -154,6 +156,11 @@ public class ShopChest extends JavaPlugin {
towny = (Towny) townyPlugin;
}
+ Plugin authMePlugin = Bukkit.getServer().getPluginManager().getPlugin("AuthMe");
+ if (authMePlugin instanceof AuthMe) {
+ authMe = (AuthMe) authMePlugin;
+ }
+
debug("Loading utils and extras...");
LanguageUtils.load();
@@ -368,6 +375,20 @@ public class ShopChest extends JavaPlugin {
this.updater = updater;
}
+ /**
+ * @return Whether the plugin 'AuthMe' is enabled
+ */
+ public boolean hasAuthMe() {
+ return authMe != null;
+ }
+
+ /**
+ * @return An instance of {@link AuthMe} or {@code null} if AuthMe is not enabled
+ */
+ public AuthMe getAuthMe() {
+ return authMe;
+ }
+
/**
* @return Whether the plugin 'Towny' is enabled
*/
diff --git a/src/main/java/de/epiceric/shopchest/config/Config.java b/src/main/java/de/epiceric/shopchest/config/Config.java
index f12e261..d3a6852 100644
--- a/src/main/java/de/epiceric/shopchest/config/Config.java
+++ b/src/main/java/de/epiceric/shopchest/config/Config.java
@@ -101,6 +101,9 @@ public class Config {
/** Whether Towny integration should be enabled **/
public boolean enable_towny_integration;
+ /** Whether AuthMe integration should be enabled **/
+ public boolean enable_authme_integration;
+
/** Whether the vendor of the shop should get messages about buys and sells **/
public boolean enable_vendor_messages;
@@ -338,6 +341,7 @@ public class Config {
enable_debug_log = plugin.getConfig().getBoolean("enable-debug-log");
enable_worldguard_integration = plugin.getConfig().getBoolean("enable-worldguard-integration");
enable_towny_integration = plugin.getConfig().getBoolean("enable-towny-integration");
+ enable_authme_integration = plugin.getConfig().getBoolean("enable-authme-integration");
enable_vendor_messages = plugin.getConfig().getBoolean("enable-vendor-messages");
explosion_protection = plugin.getConfig().getBoolean("explosion-protection");
only_show_shops_in_sight = plugin.getConfig().getBoolean("only-show-shops-in-sight");
diff --git a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
index f93fed6..dfa2946 100644
--- a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
+++ b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
@@ -25,6 +25,7 @@ import de.epiceric.shopchest.utils.Permissions;
import de.epiceric.shopchest.utils.ShopUtils;
import de.epiceric.shopchest.utils.Utils;
import de.epiceric.shopchest.worldguard.ShopFlag;
+import fr.xephi.authme.AuthMe;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
@@ -76,6 +77,8 @@ public class ShopInteractListener implements Listener {
Player p = e.getPlayer();
Block b = e.getClickedBlock();
+ if (config.enable_authme_integration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(p)) return;
+
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (b.getType().equals(Material.CHEST) || b.getType().equals(Material.TRAPPED_CHEST)) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
@@ -361,6 +364,7 @@ public class ShopInteractListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
+ if (config.enable_authme_integration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(e.getPlayer())) return;
handleInteractEvent(e, true);
}
@@ -370,6 +374,7 @@ public class ShopInteractListener implements Listener {
Entity entity = e.getRightClicked();
Player p = e.getPlayer();
+ if (config.enable_authme_integration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(p)) return;
if (Utils.getMajorVersion() == 8 || e.getHand() == EquipmentSlot.HAND) {
if (entity instanceof ArmorStand) {
@@ -404,6 +409,7 @@ public class ShopInteractListener implements Listener {
if (!(damager instanceof Player)) return;
Player p = (Player) damager;
+ if (config.enable_authme_integration && plugin.hasAuthMe() && !AuthMe.getApi().isAuthenticated(p)) return;
if (entity instanceof ArmorStand) {
ArmorStand armorStand = (ArmorStand) entity;
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 4c19f82..17e5cb4 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -41,6 +41,10 @@ enable-worldguard-integration: true
# Of course, this only works if Towny is installed
enable-towny-integration: true
+# Set whether AuthMe integration should be enabled
+# Of course, this only works if AuthMe is installed
+enable-authme-integration: true
+
# Set whether the vendor of a shop should get messages when players
# buy or sell something from/to his shop or if his shop is out of stock
enable-vendor-messages: true