mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-01-07 07:37:35 +01:00
Implement LockettePro support and improve soft dependency handling (#354)
This commit is contained in:
parent
741a10cb95
commit
282c39c975
11
pom.xml
11
pom.xml
@ -53,6 +53,10 @@
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>NyaaCat</id>
|
||||
<url>https://ci.nyaacat.com/maven/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -318,6 +322,13 @@
|
||||
<version>0.1.0.10</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.crafter.mc</groupId>
|
||||
<artifactId>lockettepro</artifactId>
|
||||
<version>2.10-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -299,6 +299,8 @@ public class ChestShop extends JavaPlugin {
|
||||
private void registerEvents() {
|
||||
registerEvent(new com.Acrobot.ChestShop.Plugins.ChestShop()); //Chest protection
|
||||
|
||||
registerEvent(new Dependencies());
|
||||
|
||||
registerEvent(new NameManager());
|
||||
|
||||
registerPreShopCreationEvents();
|
||||
|
@ -6,7 +6,10 @@ import com.Acrobot.ChestShop.Listeners.Economy.Plugins.ReserveListener;
|
||||
import com.Acrobot.ChestShop.Listeners.Economy.Plugins.VaultListener;
|
||||
import com.Acrobot.ChestShop.Plugins.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
@ -14,7 +17,7 @@ import org.bukkit.plugin.PluginManager;
|
||||
/**
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class Dependencies {
|
||||
public class Dependencies implements Listener {
|
||||
|
||||
public static void initializePlugins() {
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
@ -106,6 +109,9 @@ public class Dependencies {
|
||||
case Lockette:
|
||||
listener = new Lockette();
|
||||
break;
|
||||
case LockettePro:
|
||||
listener = new LockettePro();
|
||||
break;
|
||||
case Deadbolt:
|
||||
listener = new Deadbolt();
|
||||
break;
|
||||
@ -184,6 +190,7 @@ public class Dependencies {
|
||||
private static enum Dependency {
|
||||
LWC,
|
||||
Lockette,
|
||||
LockettePro,
|
||||
Deadbolt,
|
||||
SimpleChestLock,
|
||||
Residence,
|
||||
@ -198,4 +205,12 @@ public class Dependencies {
|
||||
|
||||
ShowItem
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEnable(PluginEnableEvent event) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
if (ChestShop.getDependencies().contains(plugin.getName())) {
|
||||
loadPlugin(plugin.getName(), plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -277,6 +278,10 @@ public class PlayerInteract implements Listener {
|
||||
if (!Security.canAccess(player, signBlock)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Security.canAccess(player, container.getBlock())) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockUtil.openBlockGUI(container, player);
|
||||
}
|
||||
|
30
src/main/java/com/Acrobot/ChestShop/Plugins/LockettePro.java
Normal file
30
src/main/java/com/Acrobot/ChestShop/Plugins/LockettePro.java
Normal file
@ -0,0 +1,30 @@
|
||||
package com.Acrobot.ChestShop.Plugins;
|
||||
|
||||
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
|
||||
import me.crafter.mc.lockettepro.LocketteProAPI;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class LockettePro implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public static void onProtectionCheck(ProtectionCheckEvent event) {
|
||||
if (event.getResult() == Event.Result.DENY) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (!LocketteProAPI.isProtected(block)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (LocketteProAPI.isLocked(block) && !LocketteProAPI.isOwner(block, player)) {
|
||||
event.setResult(Event.Result.DENY);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ version: '${bukkit.plugin.version}'
|
||||
author: Acrobot
|
||||
authors: ['https://github.com/ChestShop-authors/ChestShop-3/contributors']
|
||||
description: A chest shop for economy plugins.
|
||||
softdepend: [Vault, Reserve, LWC, Lockette, Deadbolt, OddItem, WorldGuard, GriefPrevention, RedProtect, Heroes, SimpleChestLock, Residence, ShowItem]
|
||||
softdepend: [Vault, Reserve, LWC, Lockette, LockettePro, Deadbolt, OddItem, WorldGuard, GriefPrevention, RedProtect, Heroes, SimpleChestLock, Residence, ShowItem]
|
||||
api-version: '1.13'
|
||||
|
||||
commands:
|
||||
|
Loading…
Reference in New Issue
Block a user