9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-22 08:29:35 +00:00

lands + code clean

This commit is contained in:
Xiao-MoMi
2022-07-06 16:43:15 +08:00
parent d0d75ba809
commit a12120d053
10 changed files with 47 additions and 17 deletions

View File

@@ -196,6 +196,14 @@ public class ConfigReader {
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#FFEBCD>已启用 <gold>Towny <color:#FFEBCD>保护!");
}
}
if(config.getBoolean("config.integration.Lands",false)){
if(Bukkit.getPluginManager().getPlugin("Lands") == null){
CustomCrops.instance.getLogger().warning("未检测到插件 Lands!");
}else {
integration.add(new Lands());
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><color:#FFEBCD>已启用 <gold>Lands <color:#FFEBCD>保护!");
}
}
}
}

View File

@@ -1,6 +1,5 @@
package net.momirealms.customcrops;
import de.tr7zw.changeme.nbtapi.NBTItem;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.momirealms.customcrops.commands.Executor;
import net.momirealms.customcrops.commands.Completer;
@@ -16,8 +15,6 @@ import net.momirealms.customcrops.utils.BackUp;
import net.momirealms.customcrops.utils.HoloUtil;
import net.momirealms.customcrops.utils.Placeholders;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Objects;

View File

@@ -3,7 +3,7 @@ package net.momirealms.customcrops.integrations;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public record GriefDefender() implements Integration {
public class GriefDefender implements Integration {
@Override
public boolean canBreak(Location location, Player player) {

View File

@@ -6,7 +6,7 @@ import org.kingdoms.constants.group.Kingdom;
import org.kingdoms.constants.land.Land;
import org.kingdoms.constants.player.KingdomPlayer;
public record KingdomsX() implements Integration {
public class KingdomsX implements Integration {
@Override
public boolean canBreak(Location location, Player player) {

View File

@@ -0,0 +1,31 @@
package net.momirealms.customcrops.integrations;
import me.angeschossen.lands.api.flags.Flags;
import me.angeschossen.lands.api.integration.LandsIntegration;
import me.angeschossen.lands.api.land.Area;
import net.momirealms.customcrops.CustomCrops;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class Lands implements Integration{
@Override
public boolean canBreak(Location location, Player player) {
Area area = new LandsIntegration(CustomCrops.instance).getAreaByLoc(location);
if (area != null){
return area.hasFlag(player, Flags.BLOCK_BREAK, false);
}else {
return true;
}
}
@Override
public boolean canPlace(Location location, Player player) {
Area area = new LandsIntegration(CustomCrops.instance).getAreaByLoc(location);
if (area != null){
return area.hasFlag(player, Flags.BLOCK_PLACE, false);
}else {
return true;
}
}
}

View File

@@ -3,7 +3,7 @@ package net.momirealms.customcrops.integrations;
import com.plotsquared.core.location.Location;
import org.bukkit.entity.Player;
public record PlotSquared() implements Integration {
public class PlotSquared implements Integration {
@Override
public boolean canBreak(org.bukkit.Location location, Player player) {
@@ -16,8 +16,6 @@ public record PlotSquared() implements Integration {
}
private boolean isAllowed(org.bukkit.Location location, Player player) {
// PlotAPI api = new PlotAPI();
// PlotPlayer<?> plotPlayer = com.plotsquared.core.PlotSquared.platform().playerManager().getPlayerIfExists(player.getUniqueId());
Location plotLoc = Location.at(location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
if (plotLoc.isPlotRoad()) return false;
if (plotLoc.getPlotArea() != null){

View File

@@ -6,7 +6,7 @@ import com.bekvon.bukkit.residence.protection.ResidencePermissions;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public record Residence() implements Integration {
public class Residence implements Integration {
@Override
public boolean canBreak(Location location, Player player) {

View File

@@ -13,7 +13,7 @@ import com.sk89q.worldguard.protection.regions.RegionQuery;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public record WorldGuard() implements Integration {
public class WorldGuard implements Integration {
@Override
public boolean canPlace(Location location, Player player) {

View File

@@ -1,18 +1,13 @@
config:
#插件兼容
integration:
#收获flag为destroy 浇水种植flag为build
Residence: false
#收获flag为BLOCK-BREAK 浇水种植flag为BUILD
WorldGuard: false
#只有王国成员可以收获、浇水和种植
Kingdoms: false
#信任的玩家可以收获、浇水和种植
GriefDefender: false
#拥有plot add的玩家可以收获、浇水和种植
PlotSquared: false
#拥有Town权限的玩家可以收获、浇水和种植
Towny: false
Lands: false
#生长时间点(tick)
#洒水器将会在农作物全部完成生长后开始工作

View File

@@ -1,5 +1,5 @@
name: CustomCrops
version: '1.5.4'
version: '1.5.5'
main: net.momirealms.customcrops.CustomCrops
api-version: 1.16
depend:
@@ -13,6 +13,7 @@ softdepend:
- GriefDefender
- PlotSquared
- Towny
- Lands
authors: [ XiaoMoMi ]
commands:
customcrops: