mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-24 09:29:19 +00:00
3.3.1.4
This commit is contained in:
@@ -8,7 +8,7 @@ plugins {
|
||||
allprojects {
|
||||
|
||||
project.group = "net.momirealms"
|
||||
project.version = "3.3.1.3"
|
||||
project.version = "3.3.1.4"
|
||||
|
||||
apply<JavaPlugin>()
|
||||
apply(plugin = "java")
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class LightLevelImpl extends AbstractRequirement implements Requirement {
|
||||
|
||||
private final int level;
|
||||
|
||||
public LightLevelImpl(@Nullable String[] msg, @Nullable Action[] actions, int level) {
|
||||
super(msg, actions);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConditionMet(CurrentState currentState) {
|
||||
if (currentState.getLocation().getBlock().getLightLevel() >= level) {
|
||||
return true;
|
||||
}
|
||||
notMetActions(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.api.object.requirement;
|
||||
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class NaturalLightLevelImpl extends AbstractRequirement implements Requirement {
|
||||
|
||||
private final int level;
|
||||
|
||||
public NaturalLightLevelImpl(@Nullable String[] msg, @Nullable Action[] actions, int level) {
|
||||
super(msg, actions);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConditionMet(CurrentState currentState) {
|
||||
if (currentState.getLocation().getBlock().getLightFromSky() >= level) {
|
||||
return true;
|
||||
}
|
||||
notMetActions(currentState);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
package net.momirealms.customcrops.api.object.world;
|
||||
|
||||
import net.momirealms.customcrops.api.event.CropBreakEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
@@ -734,27 +734,36 @@ public class PlatformManager extends Function {
|
||||
if (cropPlantEvent.isCancelled())
|
||||
return true;
|
||||
|
||||
Action[] plantActions = cropConfig.getPlantActions();
|
||||
if (plantActions != null) {
|
||||
for (Action action : plantActions) {
|
||||
action.doOn(player, SimpleLocation.getByBukkitLocation(crop_loc), cropConfig.getCropMode());
|
||||
}
|
||||
}
|
||||
|
||||
if (player.getGameMode() != GameMode.CREATIVE) item_in_hand.setAmount(item_in_hand.getAmount() - 1);
|
||||
player.swingMainHand();
|
||||
switch (cropConfig.getCropMode()) {
|
||||
case ITEM_DISPLAY -> {
|
||||
ItemDisplay itemDisplay = CustomCrops.getInstance().getPlatformInterface().placeItemDisplay(crop_loc, cropPlantEvent.getCropModel());
|
||||
if (itemDisplay != null && cropConfig.isRotationEnabled()) itemDisplay.setRotation(RotationUtils.getRandomFloatRotation(), itemDisplay.getLocation().getPitch());
|
||||
if (itemDisplay == null)
|
||||
return true;
|
||||
if (cropConfig.isRotationEnabled())
|
||||
itemDisplay.setRotation(RotationUtils.getRandomFloatRotation(), itemDisplay.getLocation().getPitch());
|
||||
}
|
||||
case ITEM_FRAME -> {
|
||||
ItemFrame itemFrame = CustomCrops.getInstance().getPlatformInterface().placeItemFrame(crop_loc, cropPlantEvent.getCropModel());
|
||||
if (itemFrame != null && cropConfig.isRotationEnabled()) itemFrame.setRotation(RotationUtils.getRandomRotation());
|
||||
if (itemFrame == null)
|
||||
return true;
|
||||
if (cropConfig.isRotationEnabled())
|
||||
itemFrame.setRotation(RotationUtils.getRandomRotation());
|
||||
}
|
||||
case TRIPWIRE -> CustomCrops.getInstance().getPlatformInterface().placeTripWire(crop_loc, cropPlantEvent.getCropModel());
|
||||
}
|
||||
|
||||
Action[] plantActions = cropConfig.getPlantActions();
|
||||
if (plantActions != null) {
|
||||
for (Action action : plantActions) {
|
||||
action.doOn(
|
||||
player,
|
||||
SimpleLocation.getByBukkitLocation(crop_loc),
|
||||
cropConfig.getCropMode()
|
||||
);
|
||||
}
|
||||
}
|
||||
player.swingMainHand();
|
||||
if (player.getGameMode() != GameMode.CREATIVE) item_in_hand.setAmount(item_in_hand.getAmount() - 1);
|
||||
plugin.getWorldDataManager().addCropData(SimpleLocation.getByBukkitLocation(crop_loc), new GrowingCrop(cropConfig.getKey(), cropPlantEvent.getPoint()), true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,9 @@ public class ItemsAdderPluginImpl implements PlatformInterface {
|
||||
if (entity instanceof ItemFrame itemFrame)
|
||||
return itemFrame;
|
||||
else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] ItemFrame not exists: " + id);
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] ItemFrame not placed: " + id + ". " +
|
||||
"If you are sure that you are using the right item type, " +
|
||||
"please set max max-furniture-vehicles-per-chunk to a higher value in IA config.yml.");
|
||||
customFurniture.remove(false);
|
||||
}
|
||||
return null;
|
||||
@@ -85,7 +87,9 @@ public class ItemsAdderPluginImpl implements PlatformInterface {
|
||||
if (entity instanceof ItemDisplay itemDisplay)
|
||||
return itemDisplay;
|
||||
else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] ItemDisplay not exists: " + id);
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] ItemFrame not placed: " + id + ". " +
|
||||
"If you are sure that you are using the right item type, " +
|
||||
"please set max max-furniture-vehicles-per-chunk to a higher value in IA config.yml.");
|
||||
customFurniture.remove(false);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -178,13 +178,17 @@ public class IntegrationManager extends Function {
|
||||
if (pluginManager.isPluginEnabled("ClueScrolls")) {
|
||||
ClueScrollCCQuest quest = new ClueScrollCCQuest(plugin);
|
||||
Bukkit.getPluginManager().registerEvents(quest, plugin);
|
||||
hookMessage("ClueScrolls");
|
||||
}
|
||||
if (pluginManager.isPluginEnabled("BetonQuest")) {
|
||||
if (Bukkit.getPluginManager().getPlugin("BetonQuest").getDescription().getVersion().startsWith("2")) BetonQuestCCQuest.register();
|
||||
else LegacyBetonQuestCCQuest.register();
|
||||
hookMessage("BetonQuest");
|
||||
}
|
||||
if (pluginManager.isPluginEnabled("BattlePass")) {
|
||||
BattlePassCCQuest.register();
|
||||
BattlePassCCQuest battlePassCCQuest = new BattlePassCCQuest();
|
||||
Bukkit.getPluginManager().registerEvents(battlePassCCQuest, plugin);
|
||||
hookMessage("BattlePass");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
package net.momirealms.customcrops.integration.quest;
|
||||
|
||||
import io.github.battlepass.BattlePlugin;
|
||||
import io.github.battlepass.quests.quests.external.executor.ExternalQuestExecutor;
|
||||
import io.github.battlepass.api.events.server.PluginReloadEvent;
|
||||
import io.github.battlepass.quests.service.base.ExternalQuestContainer;
|
||||
import io.github.battlepass.registry.quest.QuestRegistry;
|
||||
import net.momirealms.customcrops.api.event.CropBreakEvent;
|
||||
import net.momirealms.customcrops.api.event.CropPlantEvent;
|
||||
@@ -26,31 +27,49 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class BattlePassCCQuest extends ExternalQuestExecutor implements Listener {
|
||||
public class BattlePassCCQuest implements Listener {
|
||||
|
||||
public static void register() {
|
||||
QuestRegistry questRegistry = BattlePlugin.getApi().getQuestRegistry();
|
||||
questRegistry.hook("customcrops", BattlePassCCQuest::new);
|
||||
questRegistry.hook("customcrops", CropQuest::new);
|
||||
}
|
||||
|
||||
public BattlePassCCQuest(BattlePlugin battlePlugin) {
|
||||
super(battlePlugin, "customcrops");
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBattlePassReload(PluginReloadEvent event) {
|
||||
register();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHarvest(CropBreakEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.getEntity() instanceof Player player) {
|
||||
String id = event.getCropItemID();
|
||||
String[] split = id.split(":");
|
||||
this.execute("harvest", player, (result) -> result.root(split[split.length - 1]));
|
||||
private static class CropQuest extends ExternalQuestContainer {
|
||||
|
||||
public CropQuest(BattlePlugin battlePlugin) {
|
||||
super(battlePlugin, "customcrops");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHarvest(CropBreakEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
if (event.getEntity() instanceof Player player) {
|
||||
String id = event.getCropItemID();
|
||||
String[] split = id.split(":");
|
||||
this.executionBuilder("harvest")
|
||||
.player(player)
|
||||
.root(split[split.length - 1])
|
||||
.progress(1)
|
||||
.buildAndExecute();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlant(CropPlantEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
String id = event.getCropKey();
|
||||
this.executionBuilder("plant")
|
||||
.player(event.getPlayer())
|
||||
.root(id)
|
||||
.progress(1)
|
||||
.buildAndExecute();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlant(CropPlantEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
String id = event.getCropKey();
|
||||
this.execute("plant", event.getPlayer(), (result) -> result.root(id));
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,9 @@
|
||||
package net.momirealms.customcrops.integration.skill;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.MMOCoreAPI;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.experience.EXPSource;
|
||||
import net.Indyuce.mmocore.experience.Profession;
|
||||
import net.Indyuce.mmocore.manager.data.PlayerDataManager;
|
||||
import net.momirealms.customcrops.integration.SkillInterface;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -219,6 +219,8 @@ public class ConfigUtils {
|
||||
case "time" -> requirements.add(new TimeImpl(msg, getActions(actionSec), innerSec.getStringList("value")));
|
||||
case "skill-level" -> requirements.add(new SkillLevelImpl(msg, getActions(actionSec), innerSec.getInt("value")));
|
||||
case "job-level" -> requirements.add(new JobLevelImpl(msg, getActions(actionSec), innerSec.getInt("value.level"), innerSec.getString("value.job")));
|
||||
case "light" -> requirements.add(new LightLevelImpl(msg, getActions(actionSec), innerSec.getInt("value")));
|
||||
case "natural-light" -> requirements.add(new NaturalLightLevelImpl(msg, getActions(actionSec), innerSec.getInt("value")));
|
||||
case "date" -> requirements.add(new DateImpl(msg, getActions(actionSec), new HashSet<>(innerSec.getStringList("value"))));
|
||||
case "max-entity-amount-in-chunk" -> requirements.add(new EntityAmountInChunkImpl(msg, getActions(actionSec), innerSec.getInt("value")));
|
||||
case "papi-condition" -> requirements.add(new CustomPapi(msg, getActions(actionSec), Objects.requireNonNull(innerSec.getConfigurationSection("value")).getValues(false)));
|
||||
|
||||
Reference in New Issue
Block a user