mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-25 09:59:20 +00:00
3.5.6
This commit is contained in:
@@ -30,6 +30,7 @@ import net.momirealms.customcrops.api.manager.MessageManager;
|
||||
import net.momirealms.customcrops.api.mechanic.item.ItemType;
|
||||
import net.momirealms.customcrops.api.mechanic.world.ChunkPos;
|
||||
import net.momirealms.customcrops.api.mechanic.world.CustomCropsBlock;
|
||||
import net.momirealms.customcrops.api.mechanic.world.SimpleLocation;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsChunk;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsSection;
|
||||
import net.momirealms.customcrops.api.mechanic.world.level.CustomCropsWorld;
|
||||
@@ -37,6 +38,7 @@ import net.momirealms.customcrops.api.mechanic.world.season.Season;
|
||||
import net.momirealms.customcrops.compatibility.season.InBuiltSeason;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -88,7 +90,7 @@ public class CommandManager implements Initable {
|
||||
return new CommandAPICommand("unsafe")
|
||||
.withSubcommands(
|
||||
new CommandAPICommand("delete-chunk-data").executesPlayer((player, args) -> {
|
||||
CustomCropsPlugin.get().getWorldManager().getCustomCropsWorld(player.getWorld()).ifPresent(customCropsWorld -> {
|
||||
plugin.getWorldManager().getCustomCropsWorld(player.getWorld()).ifPresent(customCropsWorld -> {
|
||||
var optionalChunk = customCropsWorld.getLoadedChunkAt(ChunkPos.getByBukkitChunk(player.getChunk()));
|
||||
if (optionalChunk.isEmpty()) {
|
||||
AdventureManager.getInstance().sendMessageWithPrefix(player, "<white>This chunk doesn't have any data.");
|
||||
@@ -97,6 +99,17 @@ public class CommandManager implements Initable {
|
||||
customCropsWorld.deleteChunk(ChunkPos.getByBukkitChunk(player.getChunk()));
|
||||
AdventureManager.getInstance().sendMessageWithPrefix(player, "<white>Done.");
|
||||
});
|
||||
}),
|
||||
new CommandAPICommand("check-data").executesPlayer((player, args) -> {
|
||||
Block block = player.getTargetBlockExact(10);
|
||||
if (block != null) {
|
||||
Optional<CustomCropsBlock> customCropsBlock = plugin.getWorldManager().getBlockAt(SimpleLocation.of(block.getLocation()));
|
||||
if (customCropsBlock.isPresent()) {
|
||||
AdventureManager.getInstance().sendMessageWithPrefix(player, customCropsBlock.get().getType() + ":" + customCropsBlock.get().getCompoundMap());
|
||||
return;
|
||||
}
|
||||
}
|
||||
AdventureManager.getInstance().sendMessageWithPrefix(player, "Data not found");
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ public class ConditionManagerImpl implements ConditionManager {
|
||||
this.registerPotCondition();
|
||||
this.registerLightCondition();
|
||||
this.registerPointCondition();
|
||||
this.registerWorldRequirement();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -199,6 +200,17 @@ public class ConditionManagerImpl implements ConditionManager {
|
||||
}));
|
||||
}
|
||||
|
||||
private void registerWorldRequirement() {
|
||||
registerCondition("world", (args) -> {
|
||||
HashSet<String> worlds = new HashSet<>(ConfigUtils.stringListArgs(args));
|
||||
return (block, offline) -> worlds.contains(block.getLocation().getWorldName());
|
||||
});
|
||||
registerCondition("!world", (args) -> {
|
||||
HashSet<String> worlds = new HashSet<>(ConfigUtils.stringListArgs(args));
|
||||
return (block, offline) -> !worlds.contains(block.getLocation().getWorldName());
|
||||
});
|
||||
}
|
||||
|
||||
private void registerBiomeRequirement() {
|
||||
registerCondition("biome", (args) -> {
|
||||
HashSet<String> biomes = new HashSet<>(ConfigUtils.stringListArgs(args));
|
||||
|
||||
@@ -133,7 +133,7 @@ public class ItemManagerImpl implements ItemManager {
|
||||
oraxenListenerConstructor.setAccessible(true);
|
||||
this.listener = (AbstractCustomListener) oraxenListenerConstructor.newInstance(this);
|
||||
Class<?> oraxenProviderClass = Class.forName("net.momirealms.customcrops.mechanic.item.custom.oraxen.OraxenProvider");
|
||||
Constructor<?> oraxenProviderConstructor = oraxenProviderClass.getDeclaredConstructor(ItemManager.class);
|
||||
Constructor<?> oraxenProviderConstructor = oraxenProviderClass.getDeclaredConstructor();
|
||||
oraxenProviderConstructor.setAccessible(true);
|
||||
this.customProvider = (CustomProvider) oraxenProviderConstructor.newInstance();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
|
||||
@@ -106,6 +106,10 @@ public class ItemsAdderProvider implements CustomProvider {
|
||||
|
||||
@Override
|
||||
public boolean isFurniture(Entity entity) {
|
||||
return CustomFurniture.byAlreadySpawned(entity) != null;
|
||||
try {
|
||||
return CustomFurniture.byAlreadySpawned(entity) != null;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user