mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-23 10:35:15 +01:00
Add SecureChests support and Fix Towny integration
This commit is contained in:
parent
47dc473163
commit
a467e405c2
@ -18,6 +18,7 @@ import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.Acrobot.ChestShop.Config.Property.TOWNY_INTEGRATION;
|
||||
import static com.Acrobot.ChestShop.Config.Property.WORLDGUARD_INTEGRATION;
|
||||
import static com.Acrobot.ChestShop.Config.Property.WORLDGUARD_USE_PROTECTION;
|
||||
|
||||
@ -79,12 +80,15 @@ public class Dependencies {
|
||||
case SimpleChestLock:
|
||||
listener = SimpleChestLock.getSimpleChestLock(plugin);
|
||||
break;
|
||||
case SecureChests:
|
||||
listener = new SecureChests();
|
||||
break;
|
||||
|
||||
//Terrain protection plugins
|
||||
case Towny:
|
||||
Towny towny = Towny.getTowny();
|
||||
|
||||
if (towny == null) {
|
||||
if (towny == null || !Config.getBoolean(TOWNY_INTEGRATION)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -148,6 +152,7 @@ public class Dependencies {
|
||||
Lockette,
|
||||
Deadbolt,
|
||||
SimpleChestLock,
|
||||
SecureChests,
|
||||
|
||||
OddItem,
|
||||
|
||||
|
60
com/Acrobot/ChestShop/Plugins/SecureChests.java
Normal file
60
com/Acrobot/ChestShop/Plugins/SecureChests.java
Normal file
@ -0,0 +1,60 @@
|
||||
package com.Acrobot.ChestShop.Plugins;
|
||||
|
||||
import com.Acrobot.ChestShop.Events.Protection.ProtectBlockEvent;
|
||||
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
|
||||
import me.HAklowner.SecureChests.Lock;
|
||||
import me.HAklowner.SecureChests.Managers.LockManager;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/**
|
||||
* @author Acrobot
|
||||
*/
|
||||
public class SecureChests implements Listener {
|
||||
private LockManager lockManager;
|
||||
|
||||
public SecureChests() {
|
||||
lockManager = me.HAklowner.SecureChests.SecureChests.getInstance().getLockManager();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProtectionCheck(ProtectionCheckEvent event) {
|
||||
if (event.getResult() == Event.Result.DENY) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
Lock lock = lockManager.getLock(block.getLocation());
|
||||
|
||||
if (!lock.isLocked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String owner = lock.getOwner();
|
||||
if (!event.getPlayer().getName().equals(owner)) {
|
||||
event.setResult(Event.Result.DENY);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockProtect(ProtectBlockEvent event) {
|
||||
if (event.isProtected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
String player = event.getName();
|
||||
|
||||
if (block == null || player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Lock lock = lockManager.getLock(block.getLocation());
|
||||
|
||||
if (!lock.isLocked()) {
|
||||
lock.lock(player);
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ description: >
|
||||
|
||||
|
||||
softdepend: [LWC, Lockette, Deadbolt, OddItem, Towny, WorldGuard, Vault, Heroes,
|
||||
iConomy, BOSEconomy, Essentials, SimpleChestLock]
|
||||
iConomy, BOSEconomy, Essentials, SimpleChestLock, SecureChests]
|
||||
commands:
|
||||
iteminfo:
|
||||
aliases: [iinfo]
|
||||
|
Loading…
Reference in New Issue
Block a user