mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-05 01:59:41 +01:00
Added Residence Chest protection
This commit is contained in:
parent
7a8158508a
commit
002430a147
34
com/Acrobot/ChestShop/Plugins/ResidenceChestProtection.java
Normal file
34
com/Acrobot/ChestShop/Plugins/ResidenceChestProtection.java
Normal file
@ -0,0 +1,34 @@
|
||||
package com.Acrobot.ChestShop.Plugins;
|
||||
|
||||
import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent;
|
||||
import com.bekvon.bukkit.residence.Residence;
|
||||
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author TOOTHPlCK1
|
||||
*/
|
||||
public class ResidenceChestProtection implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public static void onProtectionCheck(ProtectionCheckEvent event) {
|
||||
if (event.getResult() == Event.Result.DENY) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
ClaimedResidence res = Residence.getResidenceManager().getByLoc(block.getLocation());
|
||||
|
||||
if (res != null) {
|
||||
if (!res.getPermissions().playerHas(player.getName(), "container", false) && !Residence.isResAdminOn(player)) {
|
||||
//Doesn't have permissions to that chest.
|
||||
event.setResult(Event.Result.DENY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user