mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-25 18:09:28 +00:00
3.3.1.13
This commit is contained in:
@@ -40,6 +40,7 @@ public class SprinklerConfig {
|
||||
private final SprinklerAnimation sprinklerAnimation;
|
||||
private final Requirement[] requirements;
|
||||
private final int water;
|
||||
private boolean infinite;
|
||||
|
||||
public SprinklerConfig(
|
||||
String key,
|
||||
@@ -54,7 +55,8 @@ public class SprinklerConfig {
|
||||
@NotNull PassiveFillMethod[] passiveFillMethods,
|
||||
@Nullable WaterAmountHologram waterAmountHologram,
|
||||
SprinklerAnimation sprinklerAnimation,
|
||||
@Nullable Requirement[] requirements
|
||||
@Nullable Requirement[] requirements,
|
||||
boolean infinite
|
||||
) {
|
||||
this.key = key;
|
||||
this.storage = storage;
|
||||
@@ -69,6 +71,7 @@ public class SprinklerConfig {
|
||||
this.sprinklerAnimation = sprinklerAnimation;
|
||||
this.waterAmountHologram = waterAmountHologram;
|
||||
this.requirements = requirements;
|
||||
this.infinite = infinite;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
@@ -127,6 +130,10 @@ public class SprinklerConfig {
|
||||
return water;
|
||||
}
|
||||
|
||||
public boolean isInfinite() {
|
||||
return infinite;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Requirement[] getRequirements() {
|
||||
return requirements;
|
||||
|
||||
@@ -130,8 +130,8 @@ public class SprinklerManager extends Function implements Listener {
|
||||
sprinklerSec.getDouble("animation.vertical-offset"),
|
||||
ItemMode.valueOf(sprinklerSec.getString("animation.type", "ARMOR_STAND").toUpperCase(Locale.ENGLISH))
|
||||
) : null,
|
||||
ConfigUtils.getRequirementsWithMsg(sprinklerSec.getConfigurationSection("requirements"))
|
||||
);
|
||||
ConfigUtils.getRequirementsWithMsg(sprinklerSec.getConfigurationSection("requirements")),
|
||||
sprinklerSec.getBoolean("infinite", false));
|
||||
this.itemToKey.put(threeD, key);
|
||||
if (twoD != null) this.itemToKey.put(twoD, key);
|
||||
this.sprinklerConfigMap.put(key, sprinklerConfig);
|
||||
|
||||
@@ -535,10 +535,12 @@ public class CCWorld extends Function {
|
||||
return;
|
||||
}
|
||||
|
||||
int water = sprinkler.getWater();
|
||||
sprinkler.setWater(--water);
|
||||
if (water <= 0) {
|
||||
removeSprinklerData(simpleLocation);
|
||||
if (!sprinklerConfig.isInfinite()) {
|
||||
int water = sprinkler.getWater();
|
||||
sprinkler.setWater(--water);
|
||||
if (water <= 0) {
|
||||
removeSprinklerData(simpleLocation);
|
||||
}
|
||||
}
|
||||
|
||||
SprinklerAnimation sprinklerAnimation = sprinklerConfig.getSprinklerAnimation();
|
||||
|
||||
@@ -44,12 +44,14 @@ import net.momirealms.customcrops.api.object.wateringcan.WateringCanConfig;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
import net.momirealms.customcrops.customplugin.itemsadder.ItemsAdderHandler;
|
||||
import net.momirealms.customcrops.customplugin.oraxen.OraxenHandler;
|
||||
import net.momirealms.customcrops.helper.Log;
|
||||
import net.momirealms.customcrops.util.AdventureUtils;
|
||||
import net.momirealms.customcrops.util.RotationUtils;
|
||||
import net.momirealms.protectionlib.ProtectionLib;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ItemDisplay;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
@@ -543,6 +545,11 @@ public class PlatformManager extends Function {
|
||||
|
||||
if (player.getGameMode() != GameMode.CREATIVE) item_in_hand.setAmount(item_in_hand.getAmount() - 1);
|
||||
CustomCrops.getInstance().getPlatformInterface().placeCustomItem(sprinkler_loc, sprinklerConfig.getThreeD(), sprinklerConfig.getItemMode());
|
||||
|
||||
if (sprinklerConfig.isInfinite()) {
|
||||
plugin.getWorldDataManager().addWaterToSprinkler(SimpleLocation.getByBukkitLocation(location), -1, sprinklerConfig);
|
||||
}
|
||||
|
||||
if (sprinklerConfig.getSound() != null) {
|
||||
AdventureUtils.playerSound(player, sprinklerConfig.getSound());
|
||||
}
|
||||
@@ -1058,12 +1065,10 @@ public class PlatformManager extends Function {
|
||||
|
||||
outer: {
|
||||
if (id != null && location != null) {
|
||||
|
||||
if (!ProtectionLib.canPlace(player, location))
|
||||
return true;
|
||||
if (!wateringCanConfig.canUse(player, location))
|
||||
return true;
|
||||
|
||||
for (PositiveFillMethod positiveFillMethod : wateringCanConfig.getPositiveFillMethods()) {
|
||||
if (positiveFillMethod.getId().equals(id)) {
|
||||
add = positiveFillMethod.getAmount();
|
||||
@@ -1079,7 +1084,15 @@ public class PlatformManager extends Function {
|
||||
}
|
||||
|
||||
List<Block> lineOfSight = player.getLineOfSight(null, 5);
|
||||
List<String> blockIds = lineOfSight.stream().map(block -> plugin.getPlatformInterface().getBlockID(block)).toList();
|
||||
List<String> blockIds = lineOfSight.stream().map(block -> {
|
||||
if (block == null) {
|
||||
return "AIR";
|
||||
}
|
||||
if (block.getBlockData() instanceof Waterlogged waterlogged && waterlogged.isWaterlogged()) {
|
||||
return "WATER";
|
||||
}
|
||||
return plugin.getPlatformInterface().getBlockID(block);
|
||||
}).toList();
|
||||
|
||||
for (PositiveFillMethod positiveFillMethod : wateringCanConfig.getPositiveFillMethods()) {
|
||||
int index = 0;
|
||||
|
||||
@@ -36,6 +36,7 @@ import net.momirealms.customcrops.customplugin.PlatformInterface;
|
||||
import net.momirealms.customcrops.util.AdventureUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Rotation;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -88,17 +89,26 @@ public class OraxenPluginImpl implements PlatformInterface {
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemDisplay placeItemDisplay(Location location, String id) {
|
||||
FurnitureMechanic mechanic = (FurnitureMechanic) FurnitureFactory.getInstance().getMechanic(id);
|
||||
if (mechanic == null) {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Furniture not exists: " + id);
|
||||
return null;
|
||||
}
|
||||
Entity entity = mechanic.place(location);
|
||||
// FurnitureMechanic mechanic = (FurnitureMechanic) FurnitureFactory.getInstance().getMechanic(id);
|
||||
// if (mechanic == null) {
|
||||
// AdventureUtils.consoleMessage("<red>[CustomCrops] Furniture not exists: " + id);
|
||||
// return null;
|
||||
// }
|
||||
// Entity entity = mechanic.place(location);
|
||||
// if (entity instanceof ItemDisplay itemDisplay)
|
||||
// return itemDisplay;
|
||||
// else {
|
||||
// AdventureUtils.consoleMessage("<red>[CustomCrops] ItemDisplay not exists: " + id);
|
||||
// // use oraxen method to remove sub entities
|
||||
// OraxenFurniture.remove(entity, null);
|
||||
// return null;
|
||||
// }
|
||||
|
||||
Entity entity = OraxenFurniture.place(id, location, Rotation.NONE, BlockFace.UP);
|
||||
if (entity instanceof ItemDisplay itemDisplay)
|
||||
return itemDisplay;
|
||||
else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] ItemDisplay not exists: " + id);
|
||||
// use oraxen method to remove sub entities
|
||||
OraxenFurniture.remove(entity, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user