mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-21 07:59:16 +00:00
[Fix?]
This commit is contained in:
@@ -18,7 +18,6 @@
|
|||||||
package net.momirealms.customcrops.api;
|
package net.momirealms.customcrops.api;
|
||||||
|
|
||||||
import net.momirealms.customcrops.api.manager.*;
|
import net.momirealms.customcrops.api.manager.*;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.season.Season;
|
|
||||||
import net.momirealms.customcrops.api.scheduler.Scheduler;
|
import net.momirealms.customcrops.api.scheduler.Scheduler;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package net.momirealms.customcrops.api.manager;
|
package net.momirealms.customcrops.api.manager;
|
||||||
|
|
||||||
import net.momirealms.customcrops.api.common.Reloadable;
|
import net.momirealms.customcrops.api.common.Reloadable;
|
||||||
|
import net.momirealms.customcrops.api.mechanic.item.ItemCarrier;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
public abstract class ConfigManager implements Reloadable {
|
public abstract class ConfigManager implements Reloadable {
|
||||||
@@ -120,21 +121,33 @@ public abstract class ConfigManager implements Reloadable {
|
|||||||
return instance.isConvertWorldOnLoad();
|
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();
|
public abstract boolean isProtectLore();
|
||||||
|
|
||||||
@@ -162,5 +175,11 @@ public abstract class ConfigManager implements Reloadable {
|
|||||||
|
|
||||||
public abstract boolean isSyncSeasons();
|
public abstract boolean isSyncSeasons();
|
||||||
|
|
||||||
|
public abstract boolean doesScarecrowProtectChunk();
|
||||||
|
|
||||||
|
public abstract ItemCarrier getScarecrowItemCarrier();
|
||||||
|
|
||||||
|
public abstract ItemCarrier getGlassItemCarrier();
|
||||||
|
|
||||||
public abstract World getReferenceWorld();
|
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.manager.WorldManager;
|
||||||
import net.momirealms.customcrops.api.mechanic.item.*;
|
import net.momirealms.customcrops.api.mechanic.item.*;
|
||||||
import net.momirealms.customcrops.api.mechanic.requirement.State;
|
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.SimpleLocation;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldCrop;
|
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 net.momirealms.customcrops.api.util.EventUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -113,7 +116,7 @@ public abstract class AbstractCustomListener implements Listener {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler (ignoreCancelled = false)
|
@EventHandler
|
||||||
public void onInteractAir(PlayerInteractEvent event) {
|
public void onInteractAir(PlayerInteractEvent event) {
|
||||||
if (event.getHand() != EquipmentSlot.HAND)
|
if (event.getHand() != EquipmentSlot.HAND)
|
||||||
return;
|
return;
|
||||||
@@ -146,11 +149,16 @@ public abstract class AbstractCustomListener implements Listener {
|
|||||||
@EventHandler (ignoreCancelled = true)
|
@EventHandler (ignoreCancelled = true)
|
||||||
public void onPlaceBlock(BlockPlaceEvent event) {
|
public void onPlaceBlock(BlockPlaceEvent event) {
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
// prevent players from placing blocks on entities (crops/sprinklers)
|
final Location location = block.getLocation();
|
||||||
if (CustomCropsPlugin.get().getWorldManager().getBlockAt(SimpleLocation.of(block.getLocation())).isPresent()) {
|
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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.onPlaceBlock(
|
this.onPlaceBlock(
|
||||||
event.getPlayer(),
|
event.getPlayer(),
|
||||||
block,
|
block,
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ public class SimpleLocation {
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public Location getBukkitLocation() {
|
public Location getBukkitLocation() {
|
||||||
World world = Bukkit.getWorld(worldName);
|
World world = Bukkit.getWorld(worldName);
|
||||||
if (world == null) return null;
|
if (world == null) return null;
|
||||||
|
|||||||
@@ -308,6 +308,13 @@ public interface CustomCropsChunk {
|
|||||||
*/
|
*/
|
||||||
void addScarecrowAt(WorldScarecrow scarecrow, SimpleLocation location);
|
void addScarecrowAt(WorldScarecrow scarecrow, SimpleLocation location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this chunk has scarecrow
|
||||||
|
*
|
||||||
|
* @return has or not
|
||||||
|
*/
|
||||||
|
boolean hasScarecrow();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get CustomCrops sections
|
* Get CustomCrops sections
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -344,6 +344,8 @@ public interface CustomCropsWorld {
|
|||||||
@Nullable
|
@Nullable
|
||||||
CustomCropsBlock removeAnythingAt(SimpleLocation location);
|
CustomCropsBlock removeAnythingAt(SimpleLocation location);
|
||||||
|
|
||||||
|
boolean doesChunkHaveScarecrow(SimpleLocation location);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the amount of pot reaches the limitation
|
* If the amount of pot reaches the limitation
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
package net.momirealms.customcrops.api.mechanic.world.level;
|
package net.momirealms.customcrops.api.mechanic.world.level;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import net.momirealms.customcrops.api.manager.ConfigManager;
|
|
||||||
import net.momirealms.customcrops.api.mechanic.world.season.Season;
|
import net.momirealms.customcrops.api.mechanic.world.season.Season;
|
||||||
|
|
||||||
public class WorldInfoData {
|
public class WorldInfoData {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ plugins {
|
|||||||
allprojects {
|
allprojects {
|
||||||
|
|
||||||
project.group = "net.momirealms"
|
project.group = "net.momirealms"
|
||||||
project.version = "3.4.7-BETA"
|
project.version = "3.4.7"
|
||||||
|
|
||||||
apply<JavaPlugin>()
|
apply<JavaPlugin>()
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import net.momirealms.customcrops.api.CustomCropsPlugin;
|
|||||||
import net.momirealms.customcrops.api.event.CustomCropsReloadEvent;
|
import net.momirealms.customcrops.api.event.CustomCropsReloadEvent;
|
||||||
import net.momirealms.customcrops.api.manager.ConfigManager;
|
import net.momirealms.customcrops.api.manager.ConfigManager;
|
||||||
import net.momirealms.customcrops.api.manager.CoolDownManager;
|
import net.momirealms.customcrops.api.manager.CoolDownManager;
|
||||||
|
import net.momirealms.customcrops.api.util.EventUtils;
|
||||||
import net.momirealms.customcrops.api.util.LogUtils;
|
import net.momirealms.customcrops.api.util.LogUtils;
|
||||||
import net.momirealms.customcrops.compatibility.IntegrationManagerImpl;
|
import net.momirealms.customcrops.compatibility.IntegrationManagerImpl;
|
||||||
import net.momirealms.customcrops.libraries.classpath.ReflectionClassPathAppender;
|
import net.momirealms.customcrops.libraries.classpath.ReflectionClassPathAppender;
|
||||||
@@ -38,7 +39,6 @@ import net.momirealms.customcrops.mechanic.misc.migrator.Migration;
|
|||||||
import net.momirealms.customcrops.mechanic.requirement.RequirementManagerImpl;
|
import net.momirealms.customcrops.mechanic.requirement.RequirementManagerImpl;
|
||||||
import net.momirealms.customcrops.mechanic.world.WorldManagerImpl;
|
import net.momirealms.customcrops.mechanic.world.WorldManagerImpl;
|
||||||
import net.momirealms.customcrops.scheduler.SchedulerImpl;
|
import net.momirealms.customcrops.scheduler.SchedulerImpl;
|
||||||
import net.momirealms.customcrops.api.util.EventUtils;
|
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
|
|||||||
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
|
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
|
||||||
import net.momirealms.customcrops.api.CustomCropsPlugin;
|
import net.momirealms.customcrops.api.CustomCropsPlugin;
|
||||||
import net.momirealms.customcrops.api.manager.ConfigManager;
|
import net.momirealms.customcrops.api.manager.ConfigManager;
|
||||||
|
import net.momirealms.customcrops.api.mechanic.item.ItemCarrier;
|
||||||
import net.momirealms.customcrops.api.util.LogUtils;
|
import net.momirealms.customcrops.api.util.LogUtils;
|
||||||
import net.momirealms.customcrops.util.ConfigUtils;
|
import net.momirealms.customcrops.util.ConfigUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -35,12 +36,13 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ConfigManagerImpl extends ConfigManager {
|
public class ConfigManagerImpl extends ConfigManager {
|
||||||
|
|
||||||
public static final String configVersion = "36";
|
public static final String configVersion = "37";
|
||||||
private CustomCropsPlugin plugin;
|
private final CustomCropsPlugin plugin;
|
||||||
private String lang;
|
private String lang;
|
||||||
private int maximumPoolSize;
|
private int maximumPoolSize;
|
||||||
private int corePoolSize;
|
private int corePoolSize;
|
||||||
@@ -63,6 +65,9 @@ public class ConfigManagerImpl extends ConfigManager {
|
|||||||
private boolean syncSeasons;
|
private boolean syncSeasons;
|
||||||
private WeakReference<World> referenceWorld;
|
private WeakReference<World> referenceWorld;
|
||||||
private boolean convertWorldOnLoad;
|
private boolean convertWorldOnLoad;
|
||||||
|
private boolean scarecrowProtectChunk;
|
||||||
|
private ItemCarrier scarecrowItemType;
|
||||||
|
private ItemCarrier glassItemType;
|
||||||
|
|
||||||
public ConfigManagerImpl(CustomCropsPlugin plugin) {
|
public ConfigManagerImpl(CustomCropsPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@@ -126,10 +131,13 @@ public class ConfigManagerImpl extends ConfigManager {
|
|||||||
greenhouse = mechanics.getBoolean("greenhouse.enable", true);
|
greenhouse = mechanics.getBoolean("greenhouse.enable", true);
|
||||||
greenhouseID = mechanics.getString("greenhouse.id");
|
greenhouseID = mechanics.getString("greenhouse.id");
|
||||||
greenhouseRange = mechanics.getInt("greenhouse.range", 5);
|
greenhouseRange = mechanics.getInt("greenhouse.range", 5);
|
||||||
|
glassItemType = ItemCarrier.valueOf(mechanics.getString("greenhouse.type", "CHORUS").toUpperCase(Locale.ENGLISH));
|
||||||
|
|
||||||
scarecrow = mechanics.getBoolean("scarecrow.enable", true);
|
scarecrow = mechanics.getBoolean("scarecrow.enable", true);
|
||||||
scarecrowID = mechanics.getString("scarecrow.id");
|
scarecrowID = mechanics.getString("scarecrow.id");
|
||||||
scarecrowRange = mechanics.getInt("scarecrow.range", 7);
|
scarecrowRange = mechanics.getInt("scarecrow.range", 7);
|
||||||
|
scarecrowProtectChunk = mechanics.getBoolean("scarecrow.protect-chunk", false);
|
||||||
|
scarecrowItemType = ItemCarrier.valueOf(mechanics.getString("scarecrow.type", "ITEM_FRAME").toUpperCase(Locale.ENGLISH));
|
||||||
|
|
||||||
syncSeasons = mechanics.getBoolean("sync-season.enable", true);
|
syncSeasons = mechanics.getBoolean("sync-season.enable", true);
|
||||||
if (syncSeasons) {
|
if (syncSeasons) {
|
||||||
@@ -163,17 +171,17 @@ public class ConfigManagerImpl extends ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isConvertWorldOnLoad() {
|
public boolean isConvertWorldOnLoad() {
|
||||||
return convertWorldOnLoad;
|
return convertWorldOnLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected double[] getDefaultQualityRatio() {
|
public double[] getDefaultQualityRatio() {
|
||||||
return defaultQualityRatio;
|
return defaultQualityRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getLang() {
|
public String getLang() {
|
||||||
return lang;
|
return lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,6 +255,21 @@ public class ConfigManagerImpl extends ConfigManager {
|
|||||||
return syncSeasons;
|
return syncSeasons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesScarecrowProtectChunk() {
|
||||||
|
return scarecrowProtectChunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemCarrier getScarecrowItemCarrier() {
|
||||||
|
return scarecrowItemType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemCarrier getGlassItemCarrier() {
|
||||||
|
return glassItemType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getReferenceWorld() {
|
public World getReferenceWorld() {
|
||||||
return referenceWorld.get();
|
return referenceWorld.get();
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import net.momirealms.customcrops.api.mechanic.world.level.WorldCrop;
|
|||||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldPot;
|
import net.momirealms.customcrops.api.mechanic.world.level.WorldPot;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldSprinkler;
|
import net.momirealms.customcrops.api.mechanic.world.level.WorldSprinkler;
|
||||||
import net.momirealms.customcrops.api.scheduler.CancellableTask;
|
import net.momirealms.customcrops.api.scheduler.CancellableTask;
|
||||||
|
import net.momirealms.customcrops.api.util.EventUtils;
|
||||||
import net.momirealms.customcrops.api.util.LogUtils;
|
import net.momirealms.customcrops.api.util.LogUtils;
|
||||||
import net.momirealms.customcrops.compatibility.VaultHook;
|
import net.momirealms.customcrops.compatibility.VaultHook;
|
||||||
import net.momirealms.customcrops.manager.AdventureManagerImpl;
|
import net.momirealms.customcrops.manager.AdventureManagerImpl;
|
||||||
@@ -58,7 +59,6 @@ import net.momirealms.customcrops.mechanic.misc.TempFakeItem;
|
|||||||
import net.momirealms.customcrops.mechanic.world.block.MemoryCrop;
|
import net.momirealms.customcrops.mechanic.world.block.MemoryCrop;
|
||||||
import net.momirealms.customcrops.util.ClassUtils;
|
import net.momirealms.customcrops.util.ClassUtils;
|
||||||
import net.momirealms.customcrops.util.ConfigUtils;
|
import net.momirealms.customcrops.util.ConfigUtils;
|
||||||
import net.momirealms.customcrops.api.util.EventUtils;
|
|
||||||
import net.momirealms.customcrops.util.ItemUtils;
|
import net.momirealms.customcrops.util.ItemUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
|||||||
@@ -168,10 +168,11 @@ public class ConditionManagerImpl implements ConditionManager {
|
|||||||
if (Math.random() > chance) return false;
|
if (Math.random() > chance) return false;
|
||||||
SimpleLocation location = block.getLocation();
|
SimpleLocation location = block.getLocation();
|
||||||
if (ConfigManager.enableScarecrow()) {
|
if (ConfigManager.enableScarecrow()) {
|
||||||
int range = ConfigManager.scarecrowRange();
|
|
||||||
Optional<CustomCropsWorld> world = plugin.getWorldManager().getCustomCropsWorld(location.getWorldName());
|
Optional<CustomCropsWorld> world = plugin.getWorldManager().getCustomCropsWorld(location.getWorldName());
|
||||||
if (world.isEmpty()) return false;
|
if (world.isEmpty()) return false;
|
||||||
CustomCropsWorld customCropsWorld = world.get();
|
CustomCropsWorld customCropsWorld = world.get();
|
||||||
|
if (!ConfigManager.scarecrowProtectChunk()) {
|
||||||
|
int range = ConfigManager.scarecrowRange();
|
||||||
for (int i = -range; i <= range; i++) {
|
for (int i = -range; i <= range; i++) {
|
||||||
for (int j = -range; j <= range; j++) {
|
for (int j = -range; j <= range; j++) {
|
||||||
for (int k : new int[]{0,-1,1}) {
|
for (int k : new int[]{0,-1,1}) {
|
||||||
@@ -181,6 +182,11 @@ public class ConditionManagerImpl implements ConditionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (customCropsWorld.doesChunkHaveScarecrow(location)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!offline)
|
if (!offline)
|
||||||
new CrowAttackAnimation(location, flyModel, standModel).start();
|
new CrowAttackAnimation(location, flyModel, standModel).start();
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import net.momirealms.customcrops.api.mechanic.action.ActionTrigger;
|
|||||||
import net.momirealms.customcrops.api.mechanic.condition.Conditions;
|
import net.momirealms.customcrops.api.mechanic.condition.Conditions;
|
||||||
import net.momirealms.customcrops.api.mechanic.condition.DeathConditions;
|
import net.momirealms.customcrops.api.mechanic.condition.DeathConditions;
|
||||||
import net.momirealms.customcrops.api.mechanic.item.*;
|
import net.momirealms.customcrops.api.mechanic.item.*;
|
||||||
|
import net.momirealms.customcrops.api.mechanic.item.custom.AbstractCustomListener;
|
||||||
import net.momirealms.customcrops.api.mechanic.item.custom.CustomProvider;
|
import net.momirealms.customcrops.api.mechanic.item.custom.CustomProvider;
|
||||||
import net.momirealms.customcrops.api.mechanic.item.water.PassiveFillMethod;
|
import net.momirealms.customcrops.api.mechanic.item.water.PassiveFillMethod;
|
||||||
import net.momirealms.customcrops.api.mechanic.item.water.PositiveFillMethod;
|
import net.momirealms.customcrops.api.mechanic.item.water.PositiveFillMethod;
|
||||||
@@ -39,11 +40,9 @@ import net.momirealms.customcrops.api.mechanic.requirement.State;
|
|||||||
import net.momirealms.customcrops.api.mechanic.world.CustomCropsBlock;
|
import net.momirealms.customcrops.api.mechanic.world.CustomCropsBlock;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.SimpleLocation;
|
import net.momirealms.customcrops.api.mechanic.world.SimpleLocation;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.level.*;
|
import net.momirealms.customcrops.api.mechanic.world.level.*;
|
||||||
|
import net.momirealms.customcrops.api.util.EventUtils;
|
||||||
import net.momirealms.customcrops.api.util.LocationUtils;
|
import net.momirealms.customcrops.api.util.LocationUtils;
|
||||||
import net.momirealms.customcrops.api.util.LogUtils;
|
import net.momirealms.customcrops.api.util.LogUtils;
|
||||||
import net.momirealms.customcrops.api.mechanic.item.custom.AbstractCustomListener;
|
|
||||||
import net.momirealms.customcrops.mechanic.item.custom.crucible.CrucibleListener;
|
|
||||||
import net.momirealms.customcrops.mechanic.item.custom.crucible.CrucibleProvider;
|
|
||||||
import net.momirealms.customcrops.mechanic.item.custom.itemsadder.ItemsAdderListener;
|
import net.momirealms.customcrops.mechanic.item.custom.itemsadder.ItemsAdderListener;
|
||||||
import net.momirealms.customcrops.mechanic.item.custom.itemsadder.ItemsAdderProvider;
|
import net.momirealms.customcrops.mechanic.item.custom.itemsadder.ItemsAdderProvider;
|
||||||
import net.momirealms.customcrops.mechanic.item.custom.oraxen.OraxenListener;
|
import net.momirealms.customcrops.mechanic.item.custom.oraxen.OraxenListener;
|
||||||
@@ -61,7 +60,6 @@ import net.momirealms.customcrops.mechanic.item.impl.WateringCanConfig;
|
|||||||
import net.momirealms.customcrops.mechanic.item.impl.fertilizer.*;
|
import net.momirealms.customcrops.mechanic.item.impl.fertilizer.*;
|
||||||
import net.momirealms.customcrops.mechanic.world.block.*;
|
import net.momirealms.customcrops.mechanic.world.block.*;
|
||||||
import net.momirealms.customcrops.util.ConfigUtils;
|
import net.momirealms.customcrops.util.ConfigUtils;
|
||||||
import net.momirealms.customcrops.api.util.EventUtils;
|
|
||||||
import net.momirealms.customcrops.util.ItemUtils;
|
import net.momirealms.customcrops.util.ItemUtils;
|
||||||
import net.momirealms.customcrops.util.RotationUtils;
|
import net.momirealms.customcrops.util.RotationUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
@@ -140,8 +138,8 @@ public class ItemManagerImpl implements ItemManager {
|
|||||||
listener = new ItemsAdderListener(this);
|
listener = new ItemsAdderListener(this);
|
||||||
customProvider = new ItemsAdderProvider();
|
customProvider = new ItemsAdderProvider();
|
||||||
} else if (Bukkit.getPluginManager().getPlugin("MythicCrucible") != null) {
|
} else if (Bukkit.getPluginManager().getPlugin("MythicCrucible") != null) {
|
||||||
listener = new CrucibleListener(this);
|
// listener = new CrucibleListener(this);
|
||||||
customProvider = new CrucibleProvider();
|
// customProvider = new CrucibleProvider();
|
||||||
} else {
|
} else {
|
||||||
LogUtils.severe("======================================================");
|
LogUtils.severe("======================================================");
|
||||||
LogUtils.severe(" Please install ItemsAdder or Oraxen as dependency.");
|
LogUtils.severe(" Please install ItemsAdder or Oraxen as dependency.");
|
||||||
|
|||||||
@@ -1,56 +1,49 @@
|
|||||||
/*
|
///*
|
||||||
* Copyright (C) <2022> <XiaoMoMi>
|
// * Copyright (C) <2022> <XiaoMoMi>
|
||||||
*
|
// *
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
// * it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// * the Free Software Foundation, either version 3 of the License, or
|
||||||
* any later version.
|
// * any later version.
|
||||||
*
|
// *
|
||||||
* This program is distributed in the hope that it will be useful,
|
// * This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// * GNU General Public License for more details.
|
||||||
*
|
// *
|
||||||
* You should have received a copy of the GNU General Public License
|
// * You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// * along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
package net.momirealms.customcrops.mechanic.item.custom.crucible;
|
//package net.momirealms.customcrops.mechanic.item.custom.crucible;
|
||||||
|
//
|
||||||
import io.lumine.mythiccrucible.events.MythicFurniturePlaceEvent;
|
//import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
|
||||||
import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
|
//import net.momirealms.customcrops.api.mechanic.item.custom.AbstractCustomListener;
|
||||||
import net.momirealms.customcrops.api.mechanic.item.custom.AbstractCustomListener;
|
//import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventHandler;
|
//
|
||||||
|
//public class CrucibleListener extends AbstractCustomListener {
|
||||||
public class CrucibleListener extends AbstractCustomListener {
|
//
|
||||||
|
// public CrucibleListener(ItemManagerImpl itemManager) {
|
||||||
public CrucibleListener(ItemManagerImpl itemManager) {
|
// super(itemManager);
|
||||||
super(itemManager);
|
// }
|
||||||
}
|
//
|
||||||
|
// @EventHandler (ignoreCancelled = true)
|
||||||
@EventHandler (ignoreCancelled = true)
|
// public void onBreakCustomBlock() {
|
||||||
public void onBreakCustomBlock() {
|
// }
|
||||||
}
|
//
|
||||||
|
// @EventHandler (ignoreCancelled = true)
|
||||||
@EventHandler (ignoreCancelled = true)
|
// public void onPlaceCustomBlock() {
|
||||||
public void onPlaceCustomBlock() {
|
// }
|
||||||
}
|
//
|
||||||
|
// @EventHandler (ignoreCancelled = true)
|
||||||
@EventHandler (ignoreCancelled = true)
|
// public void onPlaceFurniture() {
|
||||||
public void onPlaceFurniture(MythicFurniturePlaceEvent event) {
|
// }
|
||||||
super.onPlaceFurniture(
|
//
|
||||||
event.getPlayer(),
|
// @EventHandler (ignoreCancelled = true)
|
||||||
event.getBlock().getLocation(),
|
// public void onBreakFurniture() {
|
||||||
event.getFurnitureItemContext().getItem().getInternalName(),
|
// }
|
||||||
event
|
//
|
||||||
);
|
// @EventHandler (ignoreCancelled = true)
|
||||||
}
|
// public void onInteractFurniture() {
|
||||||
|
// }
|
||||||
@EventHandler (ignoreCancelled = true)
|
//}
|
||||||
public void onBreakFurniture() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler (ignoreCancelled = true)
|
|
||||||
public void onInteractFurniture() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,124 +1,124 @@
|
|||||||
/*
|
///*
|
||||||
* Copyright (C) <2022> <XiaoMoMi>
|
// * Copyright (C) <2022> <XiaoMoMi>
|
||||||
*
|
// *
|
||||||
* This program is free software: you can redistribute it and/or modify
|
// * This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
// * it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
// * the Free Software Foundation, either version 3 of the License, or
|
||||||
* any later version.
|
// * any later version.
|
||||||
*
|
// *
|
||||||
* This program is distributed in the hope that it will be useful,
|
// * This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
// * GNU General Public License for more details.
|
||||||
*
|
// *
|
||||||
* You should have received a copy of the GNU General Public License
|
// * You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// * along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
package net.momirealms.customcrops.mechanic.item.custom.crucible;
|
//package net.momirealms.customcrops.mechanic.item.custom.crucible;
|
||||||
|
//
|
||||||
import io.lumine.mythic.bukkit.BukkitAdapter;
|
//import io.lumine.mythic.bukkit.BukkitAdapter;
|
||||||
import io.lumine.mythic.bukkit.adapters.BukkitEntity;
|
//import io.lumine.mythic.bukkit.adapters.BukkitEntity;
|
||||||
import io.lumine.mythiccrucible.MythicCrucible;
|
//import io.lumine.mythiccrucible.MythicCrucible;
|
||||||
import io.lumine.mythiccrucible.items.CrucibleItem;
|
//import io.lumine.mythiccrucible.items.CrucibleItem;
|
||||||
import io.lumine.mythiccrucible.items.ItemManager;
|
//import io.lumine.mythiccrucible.items.ItemManager;
|
||||||
import io.lumine.mythiccrucible.items.blocks.CustomBlockItemContext;
|
//import io.lumine.mythiccrucible.items.blocks.CustomBlockItemContext;
|
||||||
import io.lumine.mythiccrucible.items.blocks.CustomBlockManager;
|
//import io.lumine.mythiccrucible.items.blocks.CustomBlockManager;
|
||||||
import io.lumine.mythiccrucible.items.furniture.Furniture;
|
//import io.lumine.mythiccrucible.items.furniture.Furniture;
|
||||||
import io.lumine.mythiccrucible.items.furniture.FurnitureManager;
|
//import io.lumine.mythiccrucible.items.furniture.FurnitureManager;
|
||||||
import net.momirealms.customcrops.api.util.LogUtils;
|
//import net.momirealms.customcrops.api.util.LogUtils;
|
||||||
import net.momirealms.customcrops.api.mechanic.item.custom.CustomProvider;
|
//import net.momirealms.customcrops.api.mechanic.item.custom.CustomProvider;
|
||||||
import org.bukkit.Location;
|
//import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
//import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
//import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
//import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Entity;
|
//import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
//import org.bukkit.inventory.ItemStack;
|
||||||
|
//
|
||||||
import java.util.Optional;
|
//import java.util.Optional;
|
||||||
|
//
|
||||||
public class CrucibleProvider implements CustomProvider {
|
//public class CrucibleProvider implements CustomProvider {
|
||||||
|
//
|
||||||
private final ItemManager itemManager;
|
// private final ItemManager itemManager;
|
||||||
private final CustomBlockManager blockManager;
|
// private final CustomBlockManager blockManager;
|
||||||
private final FurnitureManager furnitureManager;
|
// private final FurnitureManager furnitureManager;
|
||||||
|
//
|
||||||
public CrucibleProvider() {
|
// public CrucibleProvider() {
|
||||||
this.itemManager = MythicCrucible.inst().getItemManager();
|
// this.itemManager = MythicCrucible.inst().getItemManager();
|
||||||
this.blockManager = itemManager.getCustomBlockManager();
|
// this.blockManager = itemManager.getCustomBlockManager();
|
||||||
this.furnitureManager = itemManager.getFurnitureManager();
|
// this.furnitureManager = itemManager.getFurnitureManager();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean removeBlock(Location location) {
|
// public boolean removeBlock(Location location) {
|
||||||
Block block = location.getBlock();
|
// Block block = location.getBlock();
|
||||||
if (block.getType() == Material.AIR) {
|
// if (block.getType() == Material.AIR) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
Optional<CustomBlockItemContext> optional = blockManager.getBlockFromBlock(block);
|
// Optional<CustomBlockItemContext> optional = blockManager.getBlockFromBlock(block);
|
||||||
if (optional.isPresent()) {
|
// if (optional.isPresent()) {
|
||||||
optional.get().remove(block, null, false);
|
// optional.get().remove(block, null, false);
|
||||||
} else {
|
// } else {
|
||||||
block.setType(Material.AIR);
|
// block.setType(Material.AIR);
|
||||||
}
|
// }
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void placeCustomBlock(Location location, String id) {
|
// public void placeCustomBlock(Location location, String id) {
|
||||||
Optional<CrucibleItem> optionalCI = itemManager.getItem(id);
|
// Optional<CrucibleItem> optionalCI = itemManager.getItem(id);
|
||||||
if (optionalCI.isPresent()) {
|
// if (optionalCI.isPresent()) {
|
||||||
location.getBlock().setBlockData(optionalCI.get().getBlockData().getBlockData());
|
// location.getBlock().setBlockData(optionalCI.get().getBlockData().getBlockData());
|
||||||
} else {
|
// } else {
|
||||||
LogUtils.warn("Custom block(" + id +") doesn't exist in Crucible configs. Please double check if that block exists.");
|
// LogUtils.warn("Custom block(" + id +") doesn't exist in Crucible configs. Please double check if that block exists.");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public Entity placeFurniture(Location location, String id) {
|
// public Entity placeFurniture(Location location, String id) {
|
||||||
Optional<CrucibleItem> optionalCI = itemManager.getItem(id);
|
// Optional<CrucibleItem> optionalCI = itemManager.getItem(id);
|
||||||
if (optionalCI.isPresent()) {
|
// if (optionalCI.isPresent()) {
|
||||||
return optionalCI.get().getFurnitureData().placeFrame(location.getBlock(), BlockFace.UP, 0f, null);
|
// return optionalCI.get().getFurnitureData().placeFrame(location.getBlock(), BlockFace.UP, 0f, null);
|
||||||
} else {
|
// } else {
|
||||||
LogUtils.warn("Furniture(" + id +") doesn't exist in Crucible configs. Please double check if that furniture exists.");
|
// LogUtils.warn("Furniture(" + id +") doesn't exist in Crucible configs. Please double check if that furniture exists.");
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void removeFurniture(Entity entity) {
|
// public void removeFurniture(Entity entity) {
|
||||||
Optional<Furniture> optional = furnitureManager.getFurniture(entity.getUniqueId());
|
// Optional<Furniture> optional = furnitureManager.getFurniture(entity.getUniqueId());
|
||||||
optional.ifPresent(furniture -> furniture.getFurnitureData().remove(furniture, null, false, false));
|
// optional.ifPresent(furniture -> furniture.getFurnitureData().remove(furniture, null, false, false));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getBlockID(Block block) {
|
// public String getBlockID(Block block) {
|
||||||
Optional<CustomBlockItemContext> optionalCB = blockManager.getBlockFromBlock(block);
|
// Optional<CustomBlockItemContext> optionalCB = blockManager.getBlockFromBlock(block);
|
||||||
return optionalCB.map(customBlockItemContext -> customBlockItemContext.getCrucibleItem().getInternalName()).orElse(block.getType().name());
|
// return optionalCB.map(customBlockItemContext -> customBlockItemContext.getCrucibleItem().getInternalName()).orElse(block.getType().name());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getItemID(ItemStack itemStack) {
|
// public String getItemID(ItemStack itemStack) {
|
||||||
return itemManager.getItem(itemStack).map(CrucibleItem::getInternalName).orElse(null);
|
// return itemManager.getItem(itemStack).map(CrucibleItem::getInternalName).orElse(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public ItemStack getItemStack(String id) {
|
// public ItemStack getItemStack(String id) {
|
||||||
Optional<CrucibleItem> optionalCI = itemManager.getItem(id);
|
// Optional<CrucibleItem> optionalCI = itemManager.getItem(id);
|
||||||
return optionalCI.map(crucibleItem -> BukkitAdapter.adapt(crucibleItem.getMythicItem().generateItemStack(1))).orElse(null);
|
// return optionalCI.map(crucibleItem -> BukkitAdapter.adapt(crucibleItem.getMythicItem().generateItemStack(1))).orElse(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public String getEntityID(Entity entity) {
|
// public String getEntityID(Entity entity) {
|
||||||
Optional<CrucibleItem> optionalCI = furnitureManager.getItemFromEntity(entity);
|
// Optional<CrucibleItem> optionalCI = furnitureManager.getItemFromEntity(entity);
|
||||||
if (optionalCI.isPresent()) {
|
// if (optionalCI.isPresent()) {
|
||||||
return optionalCI.get().getInternalName();
|
// return optionalCI.get().getInternalName();
|
||||||
}
|
// }
|
||||||
return entity.getType().name();
|
// return entity.getType().name();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public boolean isFurniture(Entity entity) {
|
// public boolean isFurniture(Entity entity) {
|
||||||
return furnitureManager.isFurniture(new BukkitEntity(entity));
|
// return furnitureManager.isFurniture(new BukkitEntity(entity));
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ package net.momirealms.customcrops.mechanic.item.custom.itemsadder;
|
|||||||
|
|
||||||
import dev.lone.itemsadder.api.CustomFurniture;
|
import dev.lone.itemsadder.api.CustomFurniture;
|
||||||
import dev.lone.itemsadder.api.Events.*;
|
import dev.lone.itemsadder.api.Events.*;
|
||||||
import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
|
|
||||||
import net.momirealms.customcrops.api.mechanic.item.custom.AbstractCustomListener;
|
import net.momirealms.customcrops.api.mechanic.item.custom.AbstractCustomListener;
|
||||||
|
import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ package net.momirealms.customcrops.mechanic.item.custom.itemsadder;
|
|||||||
import dev.lone.itemsadder.api.CustomBlock;
|
import dev.lone.itemsadder.api.CustomBlock;
|
||||||
import dev.lone.itemsadder.api.CustomFurniture;
|
import dev.lone.itemsadder.api.CustomFurniture;
|
||||||
import dev.lone.itemsadder.api.CustomStack;
|
import dev.lone.itemsadder.api.CustomStack;
|
||||||
import net.momirealms.customcrops.api.util.LogUtils;
|
|
||||||
import net.momirealms.customcrops.api.mechanic.item.custom.CustomProvider;
|
import net.momirealms.customcrops.api.mechanic.item.custom.CustomProvider;
|
||||||
|
import net.momirealms.customcrops.api.util.LogUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ import io.th0rgal.oraxen.api.events.custom_block.stringblock.OraxenStringBlockPl
|
|||||||
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureBreakEvent;
|
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureBreakEvent;
|
||||||
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureInteractEvent;
|
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureInteractEvent;
|
||||||
import io.th0rgal.oraxen.api.events.furniture.OraxenFurniturePlaceEvent;
|
import io.th0rgal.oraxen.api.events.furniture.OraxenFurniturePlaceEvent;
|
||||||
|
import net.momirealms.customcrops.api.mechanic.item.custom.AbstractCustomListener;
|
||||||
import net.momirealms.customcrops.api.util.LocationUtils;
|
import net.momirealms.customcrops.api.util.LocationUtils;
|
||||||
import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
|
import net.momirealms.customcrops.mechanic.item.ItemManagerImpl;
|
||||||
import net.momirealms.customcrops.api.mechanic.item.custom.AbstractCustomListener;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
public class OraxenListener extends AbstractCustomListener {
|
public class OraxenListener extends AbstractCustomListener {
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import io.th0rgal.oraxen.api.OraxenItems;
|
|||||||
import io.th0rgal.oraxen.items.ItemBuilder;
|
import io.th0rgal.oraxen.items.ItemBuilder;
|
||||||
import io.th0rgal.oraxen.mechanics.Mechanic;
|
import io.th0rgal.oraxen.mechanics.Mechanic;
|
||||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
|
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
|
||||||
import net.momirealms.customcrops.api.util.LogUtils;
|
|
||||||
import net.momirealms.customcrops.api.mechanic.item.custom.CustomProvider;
|
import net.momirealms.customcrops.api.mechanic.item.custom.CustomProvider;
|
||||||
|
import net.momirealms.customcrops.api.util.LogUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Rotation;
|
import org.bukkit.Rotation;
|
||||||
|
|||||||
@@ -553,6 +553,18 @@ public class CChunk implements CustomCropsChunk {
|
|||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasScarecrow() {
|
||||||
|
for (CustomCropsSection section : getSections()) {
|
||||||
|
for (CustomCropsBlock block : section.getBlocks()) {
|
||||||
|
if (block instanceof WorldScarecrow) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public CSection[] getSectionsForSerialization() {
|
public CSection[] getSectionsForSerialization() {
|
||||||
ArrayList<CSection> sections = new ArrayList<>();
|
ArrayList<CSection> sections = new ArrayList<>();
|
||||||
for (Map.Entry<Integer, CSection> entry : loadedSections.entrySet()) {
|
for (Map.Entry<Integer, CSection> entry : loadedSections.entrySet()) {
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ import net.momirealms.customcrops.api.mechanic.world.level.*;
|
|||||||
import net.momirealms.customcrops.api.mechanic.world.season.Season;
|
import net.momirealms.customcrops.api.mechanic.world.season.Season;
|
||||||
import net.momirealms.customcrops.api.scheduler.CancellableTask;
|
import net.momirealms.customcrops.api.scheduler.CancellableTask;
|
||||||
import net.momirealms.customcrops.api.scheduler.Scheduler;
|
import net.momirealms.customcrops.api.scheduler.Scheduler;
|
||||||
import net.momirealms.customcrops.api.util.LogUtils;
|
|
||||||
import net.momirealms.customcrops.api.util.EventUtils;
|
import net.momirealms.customcrops.api.util.EventUtils;
|
||||||
|
import net.momirealms.customcrops.api.util.LogUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -525,7 +525,7 @@ public class CWorld implements CustomCropsWorld {
|
|||||||
if (chunk != null) {
|
if (chunk != null) {
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
// is a loaded chunk, but it doesn't have customcrops data
|
// is a loaded chunk, but it doesn't have CustomCrops data
|
||||||
if (bukkitWorld.isChunkLoaded(chunkPos.x(), chunkPos.z())) {
|
if (bukkitWorld.isChunkLoaded(chunkPos.x(), chunkPos.z())) {
|
||||||
chunk = new CChunk(this, chunkPos);
|
chunk = new CChunk(this, chunkPos);
|
||||||
loadChunk(chunk);
|
loadChunk(chunk);
|
||||||
@@ -535,6 +535,12 @@ public class CWorld implements CustomCropsWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean doesChunkHaveScarecrow(SimpleLocation location) {
|
||||||
|
Optional<CustomCropsChunk> chunk = getLoadedChunkAt(location.getChunkPos());
|
||||||
|
return chunk.map(CustomCropsChunk::hasScarecrow).orElse(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPotReachLimit(SimpleLocation location) {
|
public boolean isPotReachLimit(SimpleLocation location) {
|
||||||
Optional<CustomCropsChunk> chunk = getLoadedChunkAt(location.getChunkPos());
|
Optional<CustomCropsChunk> chunk = getLoadedChunkAt(location.getChunkPos());
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import net.momirealms.customcrops.api.mechanic.item.ItemType;
|
|||||||
import net.momirealms.customcrops.api.mechanic.item.Pot;
|
import net.momirealms.customcrops.api.mechanic.item.Pot;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.SimpleLocation;
|
import net.momirealms.customcrops.api.mechanic.world.SimpleLocation;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.level.AbstractCustomCropsBlock;
|
import net.momirealms.customcrops.api.mechanic.world.level.AbstractCustomCropsBlock;
|
||||||
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsChunk;
|
|
||||||
import net.momirealms.customcrops.api.mechanic.world.level.WorldPot;
|
import net.momirealms.customcrops.api.mechanic.world.level.WorldPot;
|
||||||
import net.momirealms.customcrops.api.util.LogUtils;
|
import net.momirealms.customcrops.api.util.LogUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Don't change
|
# Don't change
|
||||||
config-version: '36'
|
config-version: '37'
|
||||||
|
|
||||||
# Debug
|
# Debug
|
||||||
debug: false
|
debug: false
|
||||||
@@ -102,12 +102,17 @@ mechanics:
|
|||||||
scarecrow:
|
scarecrow:
|
||||||
enable: true
|
enable: true
|
||||||
id: '{0}scarecrow'
|
id: '{0}scarecrow'
|
||||||
|
type: ITEM_FRAME
|
||||||
range: 7
|
range: 7
|
||||||
|
# If this option is enabled, the range above would not longer take effect
|
||||||
|
# This option would make the scarecrow protect all the crops in a chunk instead of crops in certain range
|
||||||
|
protect-chunk: false
|
||||||
|
|
||||||
# Greenhouse glass prevents crops from withering from season changing
|
# Greenhouse glass prevents crops from withering from season changing
|
||||||
greenhouse:
|
greenhouse:
|
||||||
enable: true
|
enable: true
|
||||||
id: '{0}greenhouse_glass'
|
id: '{0}greenhouse_glass'
|
||||||
|
type: CHORUS
|
||||||
range: 5
|
range: 5
|
||||||
|
|
||||||
# Sync seasons
|
# Sync seasons
|
||||||
|
|||||||
Reference in New Issue
Block a user