mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-24 17:39:26 +00:00
3.0.5
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'net.momirealms'
|
||||
version = '3.0.4'
|
||||
version = '3.0.5'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -33,6 +33,7 @@ import net.momirealms.customcrops.api.object.fertilizer.FertilizerManager;
|
||||
import net.momirealms.customcrops.api.object.hologram.HologramManager;
|
||||
import net.momirealms.customcrops.api.object.pot.PotManager;
|
||||
import net.momirealms.customcrops.api.object.scheduler.Scheduler;
|
||||
import net.momirealms.customcrops.api.object.season.CCSeason;
|
||||
import net.momirealms.customcrops.api.object.season.SeasonManager;
|
||||
import net.momirealms.customcrops.api.object.sprinkler.SprinklerManager;
|
||||
import net.momirealms.customcrops.api.object.wateringcan.WateringCanManager;
|
||||
|
||||
@@ -20,6 +20,8 @@ package net.momirealms.customcrops.api;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.crop.GrowingCrop;
|
||||
import net.momirealms.customcrops.api.object.pot.Pot;
|
||||
import net.momirealms.customcrops.api.object.season.CCSeason;
|
||||
import net.momirealms.customcrops.api.object.season.SeasonData;
|
||||
import net.momirealms.customcrops.api.object.sprinkler.Sprinkler;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
import org.bukkit.Location;
|
||||
@@ -60,4 +62,34 @@ public class CustomCropsAPI {
|
||||
public Sprinkler getSprinklerAt(Location location) {
|
||||
return plugin.getWorldDataManager().getSprinklerData(SimpleLocation.getByBukkitLocation(location));
|
||||
}
|
||||
|
||||
public void setSeason(String world, CCSeason season) {
|
||||
SeasonData seasonData = plugin.getSeasonManager().getSeasonData(world);
|
||||
if (seasonData != null) {
|
||||
seasonData.changeSeason(season);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDate(String world, int date) {
|
||||
SeasonData seasonData = plugin.getSeasonManager().getSeasonData(world);
|
||||
if (seasonData != null) {
|
||||
seasonData.setDate(date);
|
||||
}
|
||||
}
|
||||
|
||||
public void addDate(String world) {
|
||||
SeasonData seasonData = plugin.getSeasonManager().getSeasonData(world);
|
||||
if (seasonData != null) {
|
||||
seasonData.addDate();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CCSeason getSeason(String world) {
|
||||
SeasonData seasonData = plugin.getSeasonManager().getSeasonData(world);
|
||||
if (seasonData != null) {
|
||||
return seasonData.getSeason();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import net.momirealms.customcrops.api.customplugin.oraxen.OraxenHandler;
|
||||
import net.momirealms.customcrops.api.event.*;
|
||||
import net.momirealms.customcrops.api.object.BoneMeal;
|
||||
import net.momirealms.customcrops.api.object.Function;
|
||||
import net.momirealms.customcrops.api.object.InteractWithItem;
|
||||
import net.momirealms.customcrops.api.object.InteractCrop;
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.object.basic.MessageManager;
|
||||
@@ -468,9 +468,18 @@ public class PlatformManager extends Function {
|
||||
}
|
||||
|
||||
if (item_in_hand_id.equals("AIR")) {
|
||||
Action[] actions = stageConfig.getInteractByHandActions();
|
||||
if (actions != null) {
|
||||
for (Action action : actions) {
|
||||
InteractCrop interactCrop = stageConfig.getInteractByHand();
|
||||
if (interactCrop != null) {
|
||||
Requirement[] requirements = interactCrop.getRequirements();
|
||||
if (requirements != null) {
|
||||
CurrentState currentState = new CurrentState(location, player);
|
||||
for (Requirement requirement : requirements) {
|
||||
if (!requirement.isConditionMet(currentState)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Action action : interactCrop.getActions()) {
|
||||
action.doOn(player, SimpleLocation.getByBukkitLocation(location), cropConfig.getCropMode());
|
||||
}
|
||||
}
|
||||
@@ -549,19 +558,29 @@ public class PlatformManager extends Function {
|
||||
}
|
||||
}
|
||||
|
||||
InteractWithItem[] interactActions = stageConfig.getInteractActions();
|
||||
InteractCrop[] interactActions = stageConfig.getInteractCropWithItem();
|
||||
if (interactActions != null) {
|
||||
for (InteractWithItem interactWithItem : interactActions) {
|
||||
if (interactWithItem.isRightItem(item_in_hand_id)) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
if (interactWithItem.isConsumed()) {
|
||||
item_in_hand.setAmount(item_in_hand.getAmount() - 1);
|
||||
}
|
||||
if (interactWithItem.getReturned() != null) {
|
||||
player.getInventory().addItem(interactWithItem.getReturned());
|
||||
outer:
|
||||
for (InteractCrop interactCrop : interactActions) {
|
||||
if (interactCrop.isRightItem(item_in_hand_id)) {
|
||||
Requirement[] requirements = interactCrop.getRequirements();
|
||||
if (requirements != null) {
|
||||
CurrentState currentState = new CurrentState(location, player);
|
||||
for (Requirement requirement : requirements) {
|
||||
if (!requirement.isConditionMet(currentState)) {
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
Action[] inAc = interactWithItem.getActions();
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
if (interactCrop.isConsumed()) {
|
||||
item_in_hand.setAmount(item_in_hand.getAmount() - 1);
|
||||
}
|
||||
if (interactCrop.getReturned() != null) {
|
||||
player.getInventory().addItem(interactCrop.getReturned());
|
||||
}
|
||||
}
|
||||
Action[] inAc = interactCrop.getActions();
|
||||
if (inAc != null) {
|
||||
for (Action action : inAc) {
|
||||
action.doOn(player, SimpleLocation.getByBukkitLocation(location), cropConfig.getCropMode());
|
||||
@@ -618,7 +637,7 @@ public class PlatformManager extends Function {
|
||||
}
|
||||
|
||||
if (plugin.getPlatformInterface().detectAnyThing(crop_loc)) return true;
|
||||
if (ConfigManager.enableLimitation && plugin.getWorldDataManager().getChunkCropAmount(SimpleLocation.getByBukkitLocation(crop_loc)) >= ConfigManager.maxCropPerChunk) {
|
||||
if (ConfigManager.enableLimitation && plugin.getWorldDataManager().getChunkCropAmount(SimpleLocation.getByBukkitLocation(crop_loc)) >= plugin.getConfigManager().getCropLimit(location.getWorld().getName())) {
|
||||
AdventureUtils.playerMessage(player, MessageManager.prefix + MessageManager.reachChunkLimit);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -93,12 +93,18 @@ public class ItemsAdderPluginImpl implements PlatformInterface {
|
||||
|
||||
@Override
|
||||
public void placeNoteBlock(Location location, String id) {
|
||||
CustomBlock.place(id, location);
|
||||
CustomBlock customBlock = CustomBlock.place(id, location);
|
||||
if (customBlock == null) {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] NoteBlock not exists: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeTripWire(Location location, String id) {
|
||||
CustomBlock.place(id, location);
|
||||
CustomBlock customBlock = CustomBlock.place(id, location);
|
||||
if (customBlock == null) {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Tripwire not exists: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -125,7 +131,10 @@ public class ItemsAdderPluginImpl implements PlatformInterface {
|
||||
|
||||
@Override
|
||||
public void placeChorus(Location location, String id) {
|
||||
CustomBlock.place(id, location);
|
||||
CustomBlock customBlock = CustomBlock.place(id, location);
|
||||
if (customBlock == null) {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Chorus not exists: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -104,12 +104,20 @@ public class OraxenPluginImpl implements PlatformInterface {
|
||||
|
||||
@Override
|
||||
public void placeNoteBlock(Location location, String id) {
|
||||
NoteBlockMechanicFactory.setBlockModel(location.getBlock(), id);
|
||||
try {
|
||||
NoteBlockMechanicFactory.setBlockModel(location.getBlock(), id);
|
||||
} catch (NullPointerException e) {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrop] NoteBlock not exists: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeTripWire(Location location, String id) {
|
||||
StringBlockMechanicFactory.setBlockModel(location.getBlock(), id);
|
||||
try {
|
||||
StringBlockMechanicFactory.setBlockModel(location.getBlock(), id);
|
||||
} catch (NullPointerException e) {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrop] Tripwire not exists: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class CrowTask extends BukkitRunnable {
|
||||
@@ -34,22 +33,22 @@ public class CrowTask extends BukkitRunnable {
|
||||
private int timer;
|
||||
private final int entityID;
|
||||
private final Vector vectorUp;
|
||||
private final Location from;
|
||||
private final Location cropLoc;
|
||||
private final Player player;
|
||||
private final float yaw;
|
||||
private final ItemStack fly;
|
||||
|
||||
public CrowTask(Player player, Location crop, String fly_model, String stand_model) {
|
||||
public CrowTask(Player player, Location crop_location, String fly_model, String stand_model) {
|
||||
this.cropLoc = crop_location.clone();
|
||||
this.timer = 0;
|
||||
this.fly = CustomCrops.getInstance().getIntegrationManager().build(fly_model);
|
||||
ItemStack stand = CustomCrops.getInstance().getIntegrationManager().build(stand_model);
|
||||
this.player = player;
|
||||
this.entityID = ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE);
|
||||
this.yaw = ThreadLocalRandom.current().nextInt(361) - 180;
|
||||
this.from = crop.clone().add(10 * Math.sin((Math.PI * yaw)/180), 10, - 10 * Math.cos((Math.PI * yaw)/180));
|
||||
Location relative = crop.clone().subtract(from);
|
||||
this.vectorUp = new Vector(relative.getX() / 50, 0.1, relative.getZ() / 50);
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getSpawnPacket(entityID, crop, EntityType.ARMOR_STAND));
|
||||
Location relative = crop_location.clone().subtract(crop_location.clone().add(10 * Math.sin((Math.PI * yaw)/180), 10, - 10 * Math.cos((Math.PI * yaw)/180)));
|
||||
this.vectorUp = new Vector(relative.getX() / 75, 0.1, relative.getZ() / 75);
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getSpawnPacket(entityID, crop_location, EntityType.ARMOR_STAND));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getVanishArmorStandMetaPacket(entityID));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getEquipPacket(entityID, stand));
|
||||
}
|
||||
@@ -57,10 +56,10 @@ public class CrowTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
timer++;
|
||||
if (timer == 30) {
|
||||
if (timer == 40) {
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getEquipPacket(entityID, fly));
|
||||
} else if (timer > 30) {
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getTeleportPacket(entityID, from.add(vectorUp), yaw));
|
||||
} else if (timer > 40) {
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getTeleportPacket(entityID, cropLoc.add(vectorUp), yaw));
|
||||
}
|
||||
if (timer > 100) {
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getDestroyPacket(entityID));
|
||||
|
||||
@@ -19,22 +19,25 @@ package net.momirealms.customcrops.api.object;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import net.momirealms.customcrops.api.object.requirement.Requirement;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class InteractWithItem {
|
||||
public class InteractCrop {
|
||||
|
||||
private final boolean consume;
|
||||
private final String id;
|
||||
private final String returned;
|
||||
private final Action[] actions;
|
||||
private final Requirement[] requirements;
|
||||
|
||||
public InteractWithItem(@NotNull String id, boolean consume, @Nullable String returned, @Nullable Action[] actions) {
|
||||
public InteractCrop(@NotNull String id, boolean consume, @Nullable String returned, @Nullable Action[] actions, @Nullable Requirement[] requirements) {
|
||||
this.consume = consume;
|
||||
this.id = id;
|
||||
this.returned = returned;
|
||||
this.actions = actions;
|
||||
this.requirements = requirements;
|
||||
}
|
||||
|
||||
public boolean isRightItem(String item) {
|
||||
@@ -54,4 +57,9 @@ public class InteractWithItem {
|
||||
public Action[] getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Requirement[] getRequirements() {
|
||||
return requirements;
|
||||
}
|
||||
}
|
||||
@@ -19,12 +19,15 @@ package net.momirealms.customcrops.api.object.basic;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.Function;
|
||||
import net.momirealms.customcrops.api.util.AdventureUtils;
|
||||
import net.momirealms.customcrops.api.util.ConfigUtils;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ConfigManager extends Function {
|
||||
@@ -59,10 +62,12 @@ public class ConfigManager extends Function {
|
||||
public static int cacheSaveInterval;
|
||||
public static boolean setUpMode;
|
||||
|
||||
private final HashMap<String, Integer> cropPerWorld;
|
||||
private final CustomCrops plugin;
|
||||
|
||||
public ConfigManager(CustomCrops plugin) {
|
||||
this.plugin = plugin;
|
||||
this.cropPerWorld = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,6 +75,11 @@ public class ConfigManager extends Function {
|
||||
this.loadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
this.cropPerWorld.clear();
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
if (new File(plugin.getDataFolder(), "config.yml").exists()) ConfigUtils.update("config.yml");
|
||||
YamlConfiguration config = ConfigUtils.getConfig("config.yml");
|
||||
@@ -85,8 +95,17 @@ public class ConfigManager extends Function {
|
||||
}
|
||||
|
||||
private void loadOptimization(ConfigurationSection section) {
|
||||
enableLimitation = section.getBoolean("limitation.enable");
|
||||
maxCropPerChunk = section.getInt("limitation.valid-crop-amount");
|
||||
enableLimitation = section.getBoolean("limitation.growing-crop-amount.enable", true);
|
||||
maxCropPerChunk = section.getInt("limitation.growing-crop-amount.default", 64);
|
||||
List<String> worldSettings = section.getStringList("limitation.growing-crop-amount.worlds");
|
||||
for (String setting : worldSettings) {
|
||||
String[] split = setting.split(":", 2);
|
||||
try {
|
||||
cropPerWorld.put(split[0], Integer.parseInt(split[1]));
|
||||
} catch (NumberFormatException e) {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Wrong number format found at: optimization.limitation.growing-crop-amount.worlds in config.yml");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadWorlds(ConfigurationSection section) {
|
||||
@@ -121,4 +140,8 @@ public class ConfigManager extends Function {
|
||||
enableSkillBonus = section.getBoolean("skill-bonus.enable", false);
|
||||
bonusFormula = section.getString("skill-bonus.formula");
|
||||
}
|
||||
|
||||
public int getCropLimit(String world) {
|
||||
return Objects.requireNonNullElse(cropPerWorld.get(world), maxCropPerChunk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package net.momirealms.customcrops.api.object.crop;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.customplugin.Platform;
|
||||
import net.momirealms.customcrops.api.object.Function;
|
||||
import net.momirealms.customcrops.api.object.InteractCrop;
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
import net.momirealms.customcrops.api.object.condition.Condition;
|
||||
import net.momirealms.customcrops.api.object.condition.DeathCondition;
|
||||
@@ -121,7 +122,13 @@ public class CropManager extends Function implements Listener {
|
||||
ConfigUtils.getActions(pointSec.getConfigurationSection(point + ".events.break"), stageModel),
|
||||
ConfigUtils.getActions(pointSec.getConfigurationSection(point + ".events.grow"), stageModel),
|
||||
ConfigUtils.getInteractActions(pointSec.getConfigurationSection(point + ".events.interact-with-item"), stageModel),
|
||||
ConfigUtils.getActions(pointSec.getConfigurationSection(point + ".events.interact-by-hand"), stageModel),
|
||||
pointSec.contains(point + ".events.interact-by-hand") ? new InteractCrop(
|
||||
"AIR",
|
||||
false,
|
||||
null,
|
||||
ConfigUtils.getActions(pointSec.getConfigurationSection(point + ".events.interact-by-hand"), stageModel),
|
||||
ConfigUtils.getRequirementsWithMsg(pointSec.getConfigurationSection(point + ".events.interact-by-hand.requirements"))
|
||||
) : null,
|
||||
pointSec.getDouble(point + ".hologram-offset-correction", 0d)
|
||||
);
|
||||
stageMap.put(parsed, stageConfig);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package net.momirealms.customcrops.api.object.crop;
|
||||
|
||||
import net.momirealms.customcrops.api.object.InteractWithItem;
|
||||
import net.momirealms.customcrops.api.object.InteractCrop;
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -26,17 +26,17 @@ public class StageConfig {
|
||||
private final int point;
|
||||
private final String model;
|
||||
private final Action[] breakActions;
|
||||
private final InteractWithItem[] interactActions;
|
||||
private final InteractCrop[] interactWithItem;
|
||||
private final Action[] growActions;
|
||||
private final Action[] interactByHandActions;
|
||||
private final InteractCrop interactByHand;
|
||||
private final double offsetCorrection;
|
||||
|
||||
public StageConfig(int point, @Nullable String model, @Nullable Action[] breakActions, @Nullable Action[] growActions, @Nullable InteractWithItem[] interactActions, @Nullable Action[] interactByHandActions, double offsetCorrection) {
|
||||
public StageConfig(int point, @Nullable String model, @Nullable Action[] breakActions, @Nullable Action[] growActions, @Nullable InteractCrop[] interactWithItem, @Nullable InteractCrop interactByHand, double offsetCorrection) {
|
||||
this.point = point;
|
||||
this.breakActions = breakActions;
|
||||
this.interactActions = interactActions;
|
||||
this.interactWithItem = interactWithItem;
|
||||
this.growActions = growActions;
|
||||
this.interactByHandActions = interactByHandActions;
|
||||
this.interactByHand = interactByHand;
|
||||
this.model = model;
|
||||
this.offsetCorrection = offsetCorrection;
|
||||
}
|
||||
@@ -47,8 +47,8 @@ public class StageConfig {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public InteractWithItem[] getInteractActions() {
|
||||
return interactActions;
|
||||
public InteractCrop[] getInteractCropWithItem() {
|
||||
return interactWithItem;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -57,8 +57,8 @@ public class StageConfig {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Action[] getInteractByHandActions() {
|
||||
return interactByHandActions;
|
||||
public InteractCrop getInteractByHand() {
|
||||
return interactByHand;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -246,5 +246,4 @@ public class WorldDataManager extends Function {
|
||||
public CCWorld getWorld(String world) {
|
||||
return worldMap.get(world);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.customplugin.Platform;
|
||||
import net.momirealms.customcrops.api.object.BoneMeal;
|
||||
import net.momirealms.customcrops.api.object.InteractWithItem;
|
||||
import net.momirealms.customcrops.api.object.InteractCrop;
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
import net.momirealms.customcrops.api.object.Pair;
|
||||
import net.momirealms.customcrops.api.object.action.*;
|
||||
@@ -221,6 +221,7 @@ public class ConfigUtils {
|
||||
if (section != null) {
|
||||
List<Action> actions = new ArrayList<>();
|
||||
for (String action_key : section.getKeys(false)) {
|
||||
if (action_key.equals("requirements")) continue;
|
||||
ConfigurationSection actionSec = section.getConfigurationSection(action_key);
|
||||
if (actionSec == null) continue;
|
||||
String type = actionSec.getString("type");
|
||||
@@ -430,21 +431,22 @@ public class ConfigUtils {
|
||||
return methods.toArray(new PositiveFillMethod[0]);
|
||||
}
|
||||
|
||||
public static InteractWithItem[] getInteractActions(ConfigurationSection section, String stageModel) {
|
||||
public static InteractCrop[] getInteractActions(ConfigurationSection section, String stageModel) {
|
||||
if (section == null) return null;
|
||||
ArrayList<InteractWithItem> interactWithItems = new ArrayList<>();
|
||||
ArrayList<InteractCrop> interactCrops = new ArrayList<>();
|
||||
for (String key : section.getKeys(false)) {
|
||||
ConfigurationSection innerSec = section.getConfigurationSection(key);
|
||||
if (innerSec == null) continue;
|
||||
InteractWithItem interactWithItem = new InteractWithItem(
|
||||
InteractCrop interactCrop = new InteractCrop(
|
||||
innerSec.getString("item", "AIR"),
|
||||
innerSec.getBoolean("reduce-amount", false),
|
||||
innerSec.getString("return"),
|
||||
getActions(innerSec.getConfigurationSection("actions"), stageModel)
|
||||
getActions(innerSec.getConfigurationSection("actions"), stageModel),
|
||||
getRequirementsWithMsg(innerSec.getConfigurationSection("requirements"))
|
||||
);
|
||||
interactWithItems.add(interactWithItem);
|
||||
interactCrops.add(interactCrop);
|
||||
}
|
||||
return interactWithItems.toArray(new InteractWithItem[0]);
|
||||
return interactCrops.toArray(new InteractCrop[0]);
|
||||
}
|
||||
|
||||
public static int rgbToDecimal(String rgba) {
|
||||
|
||||
@@ -137,10 +137,12 @@ public class IntegrationManager extends Function {
|
||||
|
||||
@NotNull
|
||||
public ItemStack build(String key) {
|
||||
for (ItemInterface itemInterface : itemInterfaces) {
|
||||
ItemStack itemStack = itemInterface.build(key);
|
||||
if (itemStack != null) {
|
||||
return itemStack;
|
||||
if (key != null) {
|
||||
for (ItemInterface itemInterface : itemInterfaces) {
|
||||
ItemStack itemStack = itemInterface.build(key);
|
||||
if (itemStack != null) {
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ItemStack(Material.AIR);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Don't change
|
||||
config-version: '26'
|
||||
config-version: '27'
|
||||
# BStats
|
||||
metrics: true
|
||||
# Language: english / spanish / chinese / turkish
|
||||
@@ -49,10 +49,15 @@ optimization:
|
||||
# 推荐启用区块限制来防止玩家种植大量农作物
|
||||
# 如果你使用ItemsAdder的展示框模式,你需要在ItemsAdder的配置文件中设置"max-furniture-vehicles-per-chunk"到较高值,否则农作物种植后会消失
|
||||
limitation:
|
||||
enable: true
|
||||
# max amount per chunk
|
||||
# max crop amount per chunk
|
||||
# 每个区块的限制数量
|
||||
valid-crop-amount: 64
|
||||
growing-crop-amount:
|
||||
enable: true
|
||||
default: 48
|
||||
# settings for a specified world
|
||||
# 指定世界的设置
|
||||
worlds:
|
||||
- world:64
|
||||
|
||||
mechanics:
|
||||
# 17/2/1 = 85%/10%/5%
|
||||
|
||||
@@ -256,6 +256,11 @@ tomato:
|
||||
interact_1:
|
||||
item: GOLDEN_HOE
|
||||
reduce-amount: false
|
||||
requirements:
|
||||
requirement_1:
|
||||
type: permission
|
||||
value: golden_hoe.use
|
||||
message: "You don't have permission to use golden hoe."
|
||||
actions:
|
||||
action_1:
|
||||
type: break
|
||||
|
||||
Reference in New Issue
Block a user