mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 16:39:36 +00:00
no change
This commit is contained in:
@@ -14,7 +14,6 @@ public class Placeholders extends PlaceholderExpansion{
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getIdentifier() {
|
public @NotNull String getIdentifier() {
|
||||||
return "customcrops";
|
return "customcrops";
|
||||||
|
|||||||
@@ -13,12 +13,10 @@ public class BreakFurniture implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void breakFurniture(EntitySpawnEvent event){
|
public void breakFurniture(EntitySpawnEvent event){
|
||||||
FileConfiguration config = CustomCrops.instance.getConfig();
|
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if(!(entity instanceof Item)){
|
if(!(entity instanceof Item)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(CustomStack.byItemStack(((Item) entity).getItemStack()) != null){
|
if(CustomStack.byItemStack(((Item) entity).getItemStack()) != null){
|
||||||
|
FileConfiguration config = CustomCrops.instance.getConfig();
|
||||||
if(CustomStack.byItemStack(((Item) entity).getItemStack()).getNamespacedID().equalsIgnoreCase(config.getString("config.sprinkler-1"))){
|
if(CustomStack.byItemStack(((Item) entity).getItemStack()).getNamespacedID().equalsIgnoreCase(config.getString("config.sprinkler-1"))){
|
||||||
entity.remove();
|
entity.remove();
|
||||||
entity.getWorld().dropItem(entity.getLocation() ,CustomStack.getInstance(config.getString("config.sprinkler-1-item")).getItemStack());
|
entity.getWorld().dropItem(entity.getLocation() ,CustomStack.getInstance(config.getString("config.sprinkler-1-item")).getItemStack());
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package net.momirealms.customcrops.listener;
|
package net.momirealms.customcrops.listener;
|
||||||
|
|
||||||
import com.bekvon.bukkit.residence.Residence;
|
|
||||||
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.CustomStack;
|
import dev.lone.itemsadder.api.CustomStack;
|
||||||
import net.momirealms.customcrops.CustomCrops;
|
import net.momirealms.customcrops.CustomCrops;
|
||||||
import net.momirealms.customcrops.DataManager.MaxSprinklersPerChunk;
|
import net.momirealms.customcrops.DataManager.MaxSprinklersPerChunk;
|
||||||
@@ -33,11 +29,11 @@ public class RightClickBlock implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void rightClickBlock(PlayerInteractEvent event){
|
public void rightClickBlock(PlayerInteractEvent event){
|
||||||
FileConfiguration config = CustomCrops.instance.getConfig();
|
|
||||||
if(!event.hasItem()){
|
if(!event.hasItem()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) return;
|
if(event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) return;
|
||||||
|
if(CustomStack.byItemStack(event.getItem()) == null) return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ItemStack itemStack = event.getItem();
|
ItemStack itemStack = event.getItem();
|
||||||
//水壶加水
|
//水壶加水
|
||||||
@@ -54,10 +50,12 @@ public class RightClickBlock implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||||
if(event.getBlockFace() != BlockFace.UP) return;
|
if(event.getBlockFace() != BlockFace.UP) return;
|
||||||
if(CustomStack.byItemStack(event.getItem()) == null) return;
|
|
||||||
|
|
||||||
|
|
||||||
|
FileConfiguration config = CustomCrops.instance.getConfig();
|
||||||
Location location = event.getClickedBlock().getLocation();
|
Location location = event.getClickedBlock().getLocation();
|
||||||
//res兼容
|
//res兼容
|
||||||
if(config.getBoolean("config.integration.residence")){
|
if(config.getBoolean("config.integration.residence")){
|
||||||
@@ -82,7 +80,6 @@ public class RightClickBlock implements Listener {
|
|||||||
MessageManager.playerMessage(config.getString("messages.prefix") + config.getString("messages.not-a-good-place"),player);
|
MessageManager.playerMessage(config.getString("messages.prefix") + config.getString("messages.not-a-good-place"),player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CustomStack.byItemStack(event.getItem()).getNamespacedID().equalsIgnoreCase(config.getString("config.sprinkler-1-item"))){
|
if(CustomStack.byItemStack(event.getItem()).getNamespacedID().equalsIgnoreCase(config.getString("config.sprinkler-1-item"))){
|
||||||
if(MaxSprinklersPerChunk.maxSprinklersPerChunk(location)){
|
if(MaxSprinklersPerChunk.maxSprinklersPerChunk(location)){
|
||||||
MessageManager.playerMessage(config.getString("messages.prefix")+config.getString("messages.reach-limit-sprinkler").replace("{Max}", config.getString("config.max-sprinklers")),player);
|
MessageManager.playerMessage(config.getString("messages.prefix")+config.getString("messages.reach-limit-sprinkler").replace("{Max}", config.getString("config.max-sprinklers")),player);
|
||||||
@@ -107,18 +104,16 @@ public class RightClickBlock implements Listener {
|
|||||||
}
|
}
|
||||||
private void addWater(ItemStack itemStack, Player player){
|
private void addWater(ItemStack itemStack, Player player){
|
||||||
FileConfiguration config = CustomCrops.instance.getConfig();
|
FileConfiguration config = CustomCrops.instance.getConfig();
|
||||||
if(CustomStack.byItemStack(itemStack)!= null){
|
CustomStack customStack = CustomStack.byItemStack(itemStack);
|
||||||
CustomStack customStack = CustomStack.byItemStack(itemStack);
|
if(customStack.getNamespacedID().equalsIgnoreCase(config.getString("config.watering-can-1")) ||
|
||||||
if(customStack.getNamespacedID().equalsIgnoreCase(config.getString("config.watering-can-1")) ||
|
customStack.getNamespacedID().equalsIgnoreCase(config.getString("config.watering-can-2")) ||
|
||||||
customStack.getNamespacedID().equalsIgnoreCase(config.getString("config.watering-can-2")) ||
|
customStack.getNamespacedID().equalsIgnoreCase(config.getString("config.watering-can-3")))
|
||||||
customStack.getNamespacedID().equalsIgnoreCase(config.getString("config.watering-can-3")))
|
{
|
||||||
{
|
if(customStack.getMaxDurability() == customStack.getDurability()){
|
||||||
if(customStack.getMaxDurability() == customStack.getDurability()){
|
MessageManager.playerMessage(config.getString("messages.prefix") + config.getString("messages.can-full"),player);
|
||||||
MessageManager.playerMessage(config.getString("messages.prefix") + config.getString("messages.can-full"),player);
|
}else {
|
||||||
}else {
|
customStack.setDurability(customStack.getDurability() + 1);
|
||||||
customStack.setDurability(customStack.getDurability() + 1);
|
player.playSound(player, Sound.ITEM_BUCKET_FILL,1,1);
|
||||||
player.playSound(player, Sound.ITEM_BUCKET_FILL,1,1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public class RightClickCustomBlock implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//空手收获农作物
|
||||||
if (event.getItem() == null) {
|
if (event.getItem() == null) {
|
||||||
if(config.getBoolean("config.integration.residence")){
|
if(config.getBoolean("config.integration.residence")){
|
||||||
if(ResidenceIntegrations.checkResHarvest(clickedBlockLocation,player)){
|
if(ResidenceIntegrations.checkResHarvest(clickedBlockLocation,player)){
|
||||||
@@ -61,11 +62,13 @@ public class RightClickCustomBlock implements Listener {
|
|||||||
clickedBlockLocation.getWorld().dropItem(clickedBlockLocation.clone().add(0.5,0.2,0.5),itemStack);
|
clickedBlockLocation.getWorld().dropItem(clickedBlockLocation.clone().add(0.5,0.2,0.5),itemStack);
|
||||||
});
|
});
|
||||||
CustomBlock.remove(clickedBlockLocation);
|
CustomBlock.remove(clickedBlockLocation);
|
||||||
|
//如果配置文件有配置则返回第几阶段
|
||||||
if(config.getConfigurationSection("crops." + cropNameList[0]).getKeys(false).contains("return")){
|
if(config.getConfigurationSection("crops." + cropNameList[0]).getKeys(false).contains("return")){
|
||||||
CustomBlock.place(config.getString("crops." + cropNameList[0] + ".return"), clickedBlockLocation);
|
CustomBlock.place(config.getString("crops." + cropNameList[0] + ".return"), clickedBlockLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
//res兼容
|
//res兼容
|
||||||
if(config.getBoolean("config.integration.residence")){
|
if(config.getBoolean("config.integration.residence")){
|
||||||
@@ -73,17 +76,14 @@ public class RightClickCustomBlock implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//wg兼容
|
//wg兼容
|
||||||
if(config.getBoolean("config.integration.worldguard")){
|
if(config.getBoolean("config.integration.worldguard")){
|
||||||
if(WorldGuardIntegrations.checkWGBuild(clickedBlockLocation,player)){
|
if(WorldGuardIntegrations.checkWGBuild(clickedBlockLocation,player)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
ItemStack mainHandItem = player.getInventory().getItemInMainHand();
|
ItemStack mainHandItem = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
//右键的作物下方是否为自定义方块
|
//右键的作物下方是否为自定义方块
|
||||||
if (CustomBlock.byAlreadyPlaced(world.getBlockAt(clickedBlockLocation.clone().subtract(0,1,0))) != null && clickedBlock.getType() == Material.TRIPWIRE) {
|
if (CustomBlock.byAlreadyPlaced(world.getBlockAt(clickedBlockLocation.clone().subtract(0,1,0))) != null && clickedBlock.getType() == Material.TRIPWIRE) {
|
||||||
//检测右键的方块下方是否为干燥的种植盆方块
|
//检测右键的方块下方是否为干燥的种植盆方块
|
||||||
@@ -152,14 +152,12 @@ public class RightClickCustomBlock implements Listener {
|
|||||||
}
|
}
|
||||||
//检测右键的方块是否为湿润的种植盆方块
|
//检测右键的方块是否为湿润的种植盆方块
|
||||||
}else if(CustomBlock.byAlreadyPlaced(world.getBlockAt(clickedBlockLocation)).getNamespacedID().equalsIgnoreCase(config.getString("config.watered-pot"))){
|
}else if(CustomBlock.byAlreadyPlaced(world.getBlockAt(clickedBlockLocation)).getNamespacedID().equalsIgnoreCase(config.getString("config.watered-pot"))){
|
||||||
|
|
||||||
tryPlantSeed(clickedBlockLocation, mainHandItem, player, config);
|
tryPlantSeed(clickedBlockLocation, mainHandItem, player, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//尝试种植植物
|
//尝试种植植物
|
||||||
private void tryPlantSeed(Location clickedBlockLocation, ItemStack mainHandItem, Player player, FileConfiguration config) {
|
private void tryPlantSeed(Location clickedBlockLocation, ItemStack mainHandItem, Player player, FileConfiguration config) {
|
||||||
|
|
||||||
if(CustomStack.byItemStack(mainHandItem) == null) return;
|
if(CustomStack.byItemStack(mainHandItem) == null) return;
|
||||||
if (CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase().endsWith("_seeds")){
|
if (CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase().endsWith("_seeds")){
|
||||||
String namespaced_id = CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase();
|
String namespaced_id = CustomStack.byItemStack(mainHandItem).getNamespacedID().toLowerCase();
|
||||||
@@ -221,9 +219,7 @@ public class RightClickCustomBlock implements Listener {
|
|||||||
private void waterPot(ItemStack itemStack, Player player, Location location, FileConfiguration config){
|
private void waterPot(ItemStack itemStack, Player player, Location location, FileConfiguration config){
|
||||||
|
|
||||||
if(CustomStack.byItemStack(itemStack) == null) return;
|
if(CustomStack.byItemStack(itemStack) == null) return;
|
||||||
|
|
||||||
CustomStack customStack = CustomStack.byItemStack(itemStack);
|
CustomStack customStack = CustomStack.byItemStack(itemStack);
|
||||||
|
|
||||||
if(customStack.getDurability() > 0){
|
if(customStack.getDurability() > 0){
|
||||||
CustomStack.byItemStack(itemStack).setDurability(CustomStack.byItemStack(itemStack).getDurability() - 1);
|
CustomStack.byItemStack(itemStack).setDurability(CustomStack.byItemStack(itemStack).getDurability() - 1);
|
||||||
}else return;
|
}else return;
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ config:
|
|||||||
# should we only alow crops in loaded chunks to grow?
|
# should we only alow crops in loaded chunks to grow?
|
||||||
# This is good for server performance
|
# This is good for server performance
|
||||||
only-grow-in-loaded-chunks: true
|
only-grow-in-loaded-chunks: true
|
||||||
|
integration:
|
||||||
|
residence: false
|
||||||
|
worldguard: false
|
||||||
|
kingdomsX: false
|
||||||
|
|
||||||
messages:
|
messages:
|
||||||
prefix: '<gradient:#ccfbff:#ef96c5>[CustomCrops] </gradient>'
|
prefix: '<gradient:#ccfbff:#ef96c5>[CustomCrops] </gradient>'
|
||||||
|
|||||||
Reference in New Issue
Block a user