9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-23 08:59:28 +00:00

res wg 兼容

This commit is contained in:
Xiao-MoMi
2022-05-22 13:04:02 +08:00
parent b1be47bd57
commit 577a8e54ec
5 changed files with 174 additions and 23 deletions

View File

@@ -0,0 +1,38 @@
package net.momirealms.customcrops.Integrations;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
import com.bekvon.bukkit.residence.protection.FlagPermissions;
import com.bekvon.bukkit.residence.protection.ResidencePermissions;
import dev.lone.itemsadder.api.Events.CustomBlockInteractEvent;
import org.bukkit.Location;
public class ResidenceIntegrations {
public static boolean checkResBuild(Location location, CustomBlockInteractEvent event){
FlagPermissions.addFlag("build");
ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location);
if(res!=null){
ResidencePermissions perms = res.getPermissions();
String playerName = event.getPlayer().getName();
boolean hasPermission = perms.playerHas(playerName, "build", true);
if(!hasPermission){
event.setCancelled(true);
return true;
}
}
return false;
}
public static boolean checkResHarvest(Location location, CustomBlockInteractEvent event){
FlagPermissions.addFlag("harvest");
ClaimedResidence res = com.bekvon.bukkit.residence.Residence.getInstance().getResidenceManager().getByLoc(location);
if(res!=null){
ResidencePermissions perms = res.getPermissions();
String playerName = event.getPlayer().getName();
boolean hasPermission = perms.playerHas(playerName, "harvest", true);
if(!hasPermission){
event.setCancelled(true);
return true;
}
}
return false;
}
}