mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-20 23:49:26 +00:00
[Fix?]
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
package net.momirealms.customcrops.api;
|
||||
|
||||
import net.momirealms.customcrops.api.manager.*;
|
||||
import net.momirealms.customcrops.api.mechanic.world.season.Season;
|
||||
import net.momirealms.customcrops.api.scheduler.Scheduler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package net.momirealms.customcrops.api.manager;
|
||||
|
||||
import net.momirealms.customcrops.api.common.Reloadable;
|
||||
import net.momirealms.customcrops.api.mechanic.item.ItemCarrier;
|
||||
import org.bukkit.World;
|
||||
|
||||
public abstract class ConfigManager implements Reloadable {
|
||||
@@ -120,21 +121,33 @@ public abstract class ConfigManager implements Reloadable {
|
||||
return instance.isConvertWorldOnLoad();
|
||||
}
|
||||
|
||||
protected abstract boolean isConvertWorldOnLoad();
|
||||
public static boolean scarecrowProtectChunk() {
|
||||
return instance.doesScarecrowProtectChunk();
|
||||
}
|
||||
|
||||
protected abstract double[] getDefaultQualityRatio();
|
||||
public static ItemCarrier scarecrowItemCarrier() {
|
||||
return instance.getScarecrowItemCarrier();
|
||||
}
|
||||
|
||||
protected abstract String getLang();
|
||||
public static ItemCarrier glassItemCarrier() {
|
||||
return instance.getGlassItemCarrier();
|
||||
}
|
||||
|
||||
protected abstract boolean getDebugMode();
|
||||
public abstract boolean isConvertWorldOnLoad();
|
||||
|
||||
protected abstract boolean hasLegacyColorSupport();
|
||||
public abstract double[] getDefaultQualityRatio();
|
||||
|
||||
protected abstract int getMaximumPoolSize();
|
||||
public abstract String getLang();
|
||||
|
||||
protected abstract int getKeepAliveTime();
|
||||
public abstract boolean getDebugMode();
|
||||
|
||||
protected abstract int getCorePoolSize();
|
||||
public abstract boolean hasLegacyColorSupport();
|
||||
|
||||
public abstract int getMaximumPoolSize();
|
||||
|
||||
public abstract int getKeepAliveTime();
|
||||
|
||||
public abstract int getCorePoolSize();
|
||||
|
||||
public abstract boolean isProtectLore();
|
||||
|
||||
@@ -162,5 +175,11 @@ public abstract class ConfigManager implements Reloadable {
|
||||
|
||||
public abstract boolean isSyncSeasons();
|
||||
|
||||
public abstract boolean doesScarecrowProtectChunk();
|
||||
|
||||
public abstract ItemCarrier getScarecrowItemCarrier();
|
||||
|
||||
public abstract ItemCarrier getGlassItemCarrier();
|
||||
|
||||
public abstract World getReferenceWorld();
|
||||
}
|
||||
|
||||
@@ -25,8 +25,11 @@ import net.momirealms.customcrops.api.manager.VersionManager;
|
||||
import net.momirealms.customcrops.api.manager.WorldManager;
|
||||
import net.momirealms.customcrops.api.mechanic.item.*;
|
||||
import net.momirealms.customcrops.api.mechanic.requirement.State;
|
||||
import net.momirealms.customcrops.api.mechanic.world.CustomCropsBlock;
|
||||
import net.momirealms.customcrops.api.mechanic.world.SimpleLocation;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldCrop;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldGlass;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldPot;
|
||||
import net.momirealms.customcrops.api.util.EventUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -113,7 +116,7 @@ public abstract class AbstractCustomListener implements Listener {
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = false)
|
||||
@EventHandler
|
||||
public void onInteractAir(PlayerInteractEvent event) {
|
||||
if (event.getHand() != EquipmentSlot.HAND)
|
||||
return;
|
||||
@@ -146,10 +149,15 @@ public abstract class AbstractCustomListener implements Listener {
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onPlaceBlock(BlockPlaceEvent event) {
|
||||
final Block block = event.getBlock();
|
||||
// prevent players from placing blocks on entities (crops/sprinklers)
|
||||
if (CustomCropsPlugin.get().getWorldManager().getBlockAt(SimpleLocation.of(block.getLocation())).isPresent()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
final Location location = block.getLocation();
|
||||
Optional<CustomCropsBlock> customCropsBlock = CustomCropsPlugin.get().getWorldManager().getBlockAt(SimpleLocation.of(location));
|
||||
if (customCropsBlock.isPresent()) {
|
||||
if (customCropsBlock.get() instanceof WorldPot || customCropsBlock.get() instanceof WorldGlass) {
|
||||
CustomCropsPlugin.get().getWorldManager().removeAnythingAt(SimpleLocation.of(location));
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.onPlaceBlock(
|
||||
event.getPlayer(),
|
||||
|
||||
@@ -98,7 +98,6 @@ public class SimpleLocation {
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Location getBukkitLocation() {
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world == null) return null;
|
||||
|
||||
@@ -308,6 +308,13 @@ public interface CustomCropsChunk {
|
||||
*/
|
||||
void addScarecrowAt(WorldScarecrow scarecrow, SimpleLocation location);
|
||||
|
||||
/**
|
||||
* If this chunk has scarecrow
|
||||
*
|
||||
* @return has or not
|
||||
*/
|
||||
boolean hasScarecrow();
|
||||
|
||||
/**
|
||||
* Get CustomCrops sections
|
||||
*
|
||||
|
||||
@@ -344,6 +344,8 @@ public interface CustomCropsWorld {
|
||||
@Nullable
|
||||
CustomCropsBlock removeAnythingAt(SimpleLocation location);
|
||||
|
||||
boolean doesChunkHaveScarecrow(SimpleLocation location);
|
||||
|
||||
/**
|
||||
* If the amount of pot reaches the limitation
|
||||
*
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package net.momirealms.customcrops.api.mechanic.world.level;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import net.momirealms.customcrops.api.manager.ConfigManager;
|
||||
import net.momirealms.customcrops.api.mechanic.world.season.Season;
|
||||
|
||||
public class WorldInfoData {
|
||||
|
||||
Reference in New Issue
Block a user