From 22442f0429292b22ae2cbd2a0127c799dcd5a839 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 4 Sep 2015 12:31:19 +0200 Subject: [PATCH] Added LWC and Lockette Support --- plugin.yml | 9 +++++-- src/de/epiceric/shopchest/ShopChest.java | 22 +++++++++++++++- .../shopchest/event/InteractShop.java | 25 +++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/plugin.yml b/plugin.yml index d6c427a..9e262ea 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,11 +2,11 @@ name: ShopChest main: de.epiceric.shopchest.ShopChest -version: 1.4.10 +version: 1.4.11 author: EpicEric website: https://www.spigotmc.org/resources/shopchest.11431/ depend: [Vault] -softdepend: [ClearLag] +softdepend: [ClearLag, LWC, Lockette] permissions: shopchest.*: @@ -28,6 +28,11 @@ permissions: children: shopchest.create: true default: op + shopchest.create.protected: + description: Allows you to create a shop on a protected chest. + children: + shopchest.create: true + default: op shopchest.removeOther: description: Allows you to remove other players' shop. default: op diff --git a/src/de/epiceric/shopchest/ShopChest.java b/src/de/epiceric/shopchest/ShopChest.java index a7fd413..df3dc54 100644 --- a/src/de/epiceric/shopchest/ShopChest.java +++ b/src/de/epiceric/shopchest/ShopChest.java @@ -16,8 +16,13 @@ import org.bukkit.World; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; +import org.yi.acru.bukkit.Lockette.Lockette; + +import com.griefcraft.lwc.LWC; +import com.griefcraft.lwc.LWCPlugin; import de.epiceric.shopchest.config.Config; import de.epiceric.shopchest.event.InteractShop; @@ -53,6 +58,8 @@ public class ShopChest extends JavaPlugin{ public static Logger logger = Logger.getLogger("Minecraft"); public static Economy econ = null; public static Permission perm = null; + public static LWC lwc = null; + public static boolean lockette = false; public static boolean isUpdateNeeded = false; public static String latestVersion = ""; @@ -103,7 +110,7 @@ public class ShopChest extends JavaPlugin{ } catch (IOException e) { logger.severe("[ShopChest] [PluginMetrics] Could not submit stats."); } - + switch (Utils.getVersion(getServer())) { case "v1_8_R1": utils = new Utils_R1(); break; @@ -115,6 +122,19 @@ public class ShopChest extends JavaPlugin{ return; } + if (getServer().getPluginManager().getPlugin("LWC") != null) { + Plugin lwcp = getServer().getPluginManager().getPlugin("LWC"); + lwc = ((LWCPlugin) lwcp).getLWC(); + } else { + lwc = null; + } + + if (getServer().getPluginManager().getPlugin("Lockette") != null) { + lockette = true; + } else { + lockette = false; + } + setupPermissions(); instance = this; diff --git a/src/de/epiceric/shopchest/event/InteractShop.java b/src/de/epiceric/shopchest/event/InteractShop.java index a6d2646..32c6749 100644 --- a/src/de/epiceric/shopchest/event/InteractShop.java +++ b/src/de/epiceric/shopchest/event/InteractShop.java @@ -19,6 +19,10 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.yi.acru.bukkit.Lockette.Lockette; + +import com.griefcraft.lwc.LWC; +import com.griefcraft.model.Protection; import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.config.Config; @@ -63,6 +67,27 @@ public class InteractShop implements Listener{ case CREATE: e.setCancelled(true); + + if (!p.isOp() || !perm.has(p, "shopchest.create.protected")) { + if (ShopChest.lockette) { + if (Lockette.isProtected(b)) { + if (!Lockette.isOwner(b, p) || !Lockette.isUser(b, p, true)) { + ClickType.removePlayerClickType(p); + break; + } + } + } + + if (ShopChest.lwc != null) { + if (ShopChest.lwc.getPhysicalDatabase().loadProtection(b.getLocation().getWorld().getName(), b.getX(), b.getY(), b.getZ()) != null) { + Protection protection = ShopChest.lwc.getPhysicalDatabase().loadProtection(b.getLocation().getWorld().getName(), b.getX(), b.getY(), b.getZ()); + if (!protection.isOwner(p) || !protection.isRealOwner(p)) { + ClickType.removePlayerClickType(p); + break; + } + } + } + } if (!ShopUtils.isShop(b.getLocation())) { ClickType clickType = ClickType.getPlayerClickType(p);