mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-23 08:59:28 +00:00
3.0.0-beta
This commit is contained in:
@@ -26,15 +26,16 @@ import net.momirealms.customcrops.api.customplugin.PlatformInterface;
|
||||
import net.momirealms.customcrops.api.customplugin.PlatformManager;
|
||||
import net.momirealms.customcrops.api.customplugin.itemsadder.ItemsAdderPluginImpl;
|
||||
import net.momirealms.customcrops.api.customplugin.oraxen.OraxenPluginImpl;
|
||||
import net.momirealms.customcrops.api.object.HologramManager;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.object.basic.MessageManager;
|
||||
import net.momirealms.customcrops.api.object.crop.CropManager;
|
||||
import net.momirealms.customcrops.api.object.pot.PotManager;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.FertilizerManager;
|
||||
import net.momirealms.customcrops.api.object.pot.PotManager;
|
||||
import net.momirealms.customcrops.api.object.schedule.Scheduler;
|
||||
import net.momirealms.customcrops.api.object.season.SeasonManager;
|
||||
import net.momirealms.customcrops.api.object.sprinkler.SprinklerManager;
|
||||
import net.momirealms.customcrops.api.object.wateringcan.WateringCanManager;
|
||||
import net.momirealms.customcrops.api.object.world.CCWorld;
|
||||
import net.momirealms.customcrops.api.object.world.WorldDataManager;
|
||||
import net.momirealms.customcrops.api.util.AdventureUtils;
|
||||
import net.momirealms.customcrops.command.CustomCropsCommand;
|
||||
@@ -68,8 +69,10 @@ public final class CustomCrops extends JavaPlugin {
|
||||
private ConfigManager configManager;
|
||||
private MessageManager messageManager;
|
||||
private PlatformManager platformManager;
|
||||
private HologramManager hologramManager;
|
||||
private VersionHelper versionHelper;
|
||||
private CustomCropsAPI customCropsAPI;
|
||||
private Scheduler scheduler;
|
||||
|
||||
@Override
|
||||
public void onLoad(){
|
||||
@@ -85,6 +88,7 @@ public final class CustomCrops extends JavaPlugin {
|
||||
this.registerCommands();
|
||||
this.loadPlatform();
|
||||
|
||||
this.scheduler = new Scheduler(this);
|
||||
this.configManager = new ConfigManager(this);
|
||||
this.messageManager = new MessageManager(this);
|
||||
this.versionHelper = new VersionHelper(this);
|
||||
@@ -96,6 +100,7 @@ public final class CustomCrops extends JavaPlugin {
|
||||
this.wateringCanManager = new WateringCanManager(this);
|
||||
this.fertilizerManager = new FertilizerManager(this);
|
||||
this.potManager = new PotManager(this);
|
||||
this.hologramManager = new HologramManager(this);
|
||||
this.platformManager = new PlatformManager(this);
|
||||
this.customCropsAPI = new CustomCropsAPI(this);
|
||||
|
||||
@@ -122,6 +127,7 @@ public final class CustomCrops extends JavaPlugin {
|
||||
this.potManager.unload();
|
||||
this.seasonManager.unload();
|
||||
this.platformManager.unload();
|
||||
this.hologramManager.unload();
|
||||
|
||||
this.configManager.load();
|
||||
this.messageManager.load();
|
||||
@@ -134,6 +140,7 @@ public final class CustomCrops extends JavaPlugin {
|
||||
this.potManager.load();
|
||||
this.seasonManager.load();
|
||||
this.platformManager.load();
|
||||
this.hologramManager.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,6 +157,8 @@ public final class CustomCrops extends JavaPlugin {
|
||||
if (this.messageManager != null) this.messageManager.unload();
|
||||
if (this.configManager != null) this.configManager.unload();
|
||||
if (this.integrationManager != null) this.integrationManager.unload();
|
||||
if (this.hologramManager != null) this.hologramManager.unload();
|
||||
if (this.scheduler != null) this.scheduler.disable();
|
||||
}
|
||||
|
||||
private void loadLibs() {
|
||||
@@ -256,7 +265,15 @@ public final class CustomCrops extends JavaPlugin {
|
||||
return platformManager;
|
||||
}
|
||||
|
||||
public HologramManager getHologramManager() {
|
||||
return hologramManager;
|
||||
}
|
||||
|
||||
public CustomCropsAPI getAPI() {
|
||||
return customCropsAPI;
|
||||
}
|
||||
|
||||
public Scheduler getScheduler() {
|
||||
return scheduler;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,26 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.customplugin.PlatformInterface;
|
||||
import net.momirealms.customcrops.api.object.crop.CropConfig;
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
import net.momirealms.customcrops.api.object.crop.CropConfig;
|
||||
import net.momirealms.customcrops.api.object.pot.Pot;
|
||||
import net.momirealms.customcrops.api.object.season.CCSeason;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.customplugin;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.customplugin;
|
||||
|
||||
public enum Platform {
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.customplugin;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
@@ -40,14 +57,28 @@ public interface PlatformInterface {
|
||||
|
||||
void dropBlockLoot(Block block);
|
||||
|
||||
boolean removeItemDisplay(Location location);
|
||||
|
||||
void placeChorus(Location location, String id);
|
||||
|
||||
Location getItemFrameLocation(Location location);
|
||||
|
||||
@Nullable
|
||||
String getCustomItemAt(Location location);
|
||||
@NotNull
|
||||
default String getAnyItemIDAt(Location location) {
|
||||
String block = getBlockID(location.getBlock());
|
||||
if (!block.equals("AIR")) return block;
|
||||
|
||||
String item_frame_id = getItemFrameIDAt(location);
|
||||
if (item_frame_id != null) {
|
||||
return item_frame_id;
|
||||
}
|
||||
|
||||
if (CustomCrops.getInstance().getVersionHelper().isVersionNewerThan1_19_R3()) {
|
||||
String item_display_id = getItemDisplayIDAt(location);
|
||||
if (item_display_id != null) {
|
||||
return item_display_id;
|
||||
}
|
||||
}
|
||||
return "AIR";
|
||||
}
|
||||
|
||||
default void removeCustomItemAt(Location location) {
|
||||
removeCustomBlock(location);
|
||||
@@ -55,16 +86,35 @@ public interface PlatformInterface {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String getItemID(@NotNull ItemStack itemStack);
|
||||
String getItemStackID(@NotNull ItemStack itemStack);
|
||||
|
||||
@Nullable
|
||||
default String getItemDisplayIDAt(Location location) {
|
||||
ItemDisplay itemDisplay = getItemDisplayAt(location);
|
||||
if (itemDisplay == null) return null;
|
||||
return getItemDisplayID(itemDisplay);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default String getItemFrameIDAt(Location location) {
|
||||
ItemFrame itemFrame = getItemFrameAt(location);
|
||||
if (itemFrame == null) return null;
|
||||
return getItemFrameID(itemFrame);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String getItemDisplayID(ItemDisplay itemDisplay);
|
||||
|
||||
@Nullable
|
||||
String getItemFrameID(ItemFrame itemFrame);
|
||||
|
||||
@Nullable
|
||||
default ItemFrame getItemFrameAt(Location location) {
|
||||
Collection<ItemFrame> itemFrames = getItemFrameLocation(location).getNearbyEntitiesByType(ItemFrame.class, 0, 0, 0);
|
||||
Collection<ItemFrame> itemFrames = getItemFrameLocation(location).getNearbyEntitiesByType(ItemFrame.class, 0.5, 0.5, 0.5);
|
||||
int i = itemFrames.size();
|
||||
int j = 1;
|
||||
for (ItemFrame itemFrame : itemFrames) {
|
||||
if (j != i) {
|
||||
// To prevent item frames stack in one block
|
||||
itemFrame.remove();
|
||||
j++;
|
||||
}
|
||||
@@ -73,6 +123,21 @@ public interface PlatformInterface {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default ItemDisplay getItemDisplayAt(Location location) {
|
||||
Collection<ItemDisplay> itemDisplays = getItemFrameLocation(location).getNearbyEntitiesByType(ItemDisplay.class, 0.5, 0.5, 0.5);
|
||||
int i = itemDisplays.size();
|
||||
int j = 1;
|
||||
for (ItemDisplay itemDisplay : itemDisplays) {
|
||||
if (j != i) {
|
||||
itemDisplay.remove();
|
||||
j++;
|
||||
}
|
||||
else return itemDisplay;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
default boolean removeItemFrame(Location location) {
|
||||
ItemFrame itemFrame = getItemFrameAt(location);
|
||||
if (itemFrame != null) {
|
||||
@@ -82,6 +147,15 @@ public interface PlatformInterface {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean removeItemDisplay(Location location) {
|
||||
ItemDisplay itemDisplay = getItemDisplayAt(location);
|
||||
if (itemDisplay != null) {
|
||||
itemDisplay.remove();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean detectAnyThing(Location location) {
|
||||
Block block = location.getBlock();
|
||||
if (block.getType() != Material.AIR) return true;
|
||||
|
||||
@@ -1,14 +1,31 @@
|
||||
/*
|
||||
* 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.customplugin;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.CustomCropsAPI;
|
||||
import net.momirealms.customcrops.api.customplugin.itemsadder.ItemsAdderHandler;
|
||||
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.ItemType;
|
||||
import net.momirealms.customcrops.api.object.fill.PassiveFillMethod;
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.object.basic.MessageManager;
|
||||
@@ -17,6 +34,7 @@ import net.momirealms.customcrops.api.object.crop.GrowingCrop;
|
||||
import net.momirealms.customcrops.api.object.crop.StageConfig;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.FertilizerConfig;
|
||||
import net.momirealms.customcrops.api.object.fill.PassiveFillMethod;
|
||||
import net.momirealms.customcrops.api.object.fill.PositiveFillMethod;
|
||||
import net.momirealms.customcrops.api.object.pot.Pot;
|
||||
import net.momirealms.customcrops.api.object.pot.PotConfig;
|
||||
@@ -26,10 +44,10 @@ import net.momirealms.customcrops.api.object.sprinkler.SprinklerConfig;
|
||||
import net.momirealms.customcrops.api.object.wateringcan.WateringCanConfig;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
import net.momirealms.customcrops.api.util.AdventureUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -115,10 +133,10 @@ public class PlatformManager extends Function {
|
||||
@NotNull
|
||||
public ItemType onInteractAir(Player player) {
|
||||
ItemStack item_in_hand = player.getInventory().getItemInMainHand();
|
||||
String id = plugin.getPlatformInterface().getItemID(item_in_hand);
|
||||
String id = plugin.getPlatformInterface().getItemStackID(item_in_hand);
|
||||
|
||||
if (onInteractWithWateringCan(player, id, item_in_hand)) {
|
||||
return ItemType.WATERINGCAN;
|
||||
return ItemType.WATERING_CAN;
|
||||
}
|
||||
|
||||
return ItemType.UNKNOWN;
|
||||
@@ -171,7 +189,7 @@ public class PlatformManager extends Function {
|
||||
@NotNull ItemType onInteractSomething(Player player, Location location, String id, Cancellable event) {
|
||||
|
||||
ItemStack item_in_hand = player.getInventory().getItemInMainHand();
|
||||
String item_in_hand_id = plugin.getPlatformInterface().getItemID(item_in_hand);
|
||||
String item_in_hand_id = plugin.getPlatformInterface().getItemStackID(item_in_hand);
|
||||
|
||||
if (onInteractWithSprinkler(player, location, item_in_hand, item_in_hand_id)) {
|
||||
return ItemType.SPRINKLER;
|
||||
@@ -190,7 +208,7 @@ public class PlatformManager extends Function {
|
||||
}
|
||||
|
||||
if (onInteractWithWateringCan(player, item_in_hand_id, item_in_hand)) {
|
||||
return ItemType.WATERINGCAN;
|
||||
return ItemType.WATERING_CAN;
|
||||
}
|
||||
|
||||
return ItemType.UNKNOWN;
|
||||
@@ -250,8 +268,15 @@ public class PlatformManager extends Function {
|
||||
PassiveFillMethod[] passiveFillMethods = sprinklerConfig.getPassiveFillMethods();
|
||||
for (PassiveFillMethod passiveFillMethod : passiveFillMethods) {
|
||||
if (passiveFillMethod.isRightItem(item_in_hand_id)) {
|
||||
|
||||
SprinklerFillEvent sprinklerFillEvent = new SprinklerFillEvent(player, item_in_hand, passiveFillMethod.getAmount(), location);
|
||||
Bukkit.getPluginManager().callEvent(sprinklerFillEvent);
|
||||
if (sprinklerFillEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
doPassiveFillAction(player, item_in_hand, passiveFillMethod, location.clone().add(0,0.2,0));
|
||||
plugin.getWorldDataManager().addWaterToSprinkler(SimpleLocation.getByBukkitLocation(location), passiveFillMethod.getAmount(), sprinklerConfig.getRange(), sprinklerConfig.getStorage());
|
||||
plugin.getWorldDataManager().addWaterToSprinkler(SimpleLocation.getByBukkitLocation(location), sprinklerFillEvent.getWater(), sprinklerConfig.getRange(), sprinklerConfig.getStorage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -272,7 +297,11 @@ public class PlatformManager extends Function {
|
||||
int current_water = plugin.getWateringCanManager().getCurrentWater(item_in_hand);
|
||||
if (current_water <= 0) return true;
|
||||
|
||||
//TODO API Events
|
||||
SprinklerFillEvent sprinklerFillEvent = new SprinklerFillEvent(player, item_in_hand, 1, location);
|
||||
Bukkit.getPluginManager().callEvent(sprinklerFillEvent);
|
||||
if (sprinklerFillEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
current_water--;
|
||||
if (wateringCanConfig.hasActionBar()) {
|
||||
@@ -364,17 +393,16 @@ public class PlatformManager extends Function {
|
||||
int current_water = plugin.getWateringCanManager().getCurrentWater(item_in_hand);
|
||||
if (current_water <= 0) return true;
|
||||
|
||||
//TODO API Events
|
||||
Location pot_loc = location.clone().subtract(0,1,0);
|
||||
PotWaterEvent potWaterEvent = new PotWaterEvent(player, item_in_hand, 1, pot_loc);
|
||||
Bukkit.getPluginManager().callEvent(potWaterEvent);
|
||||
if (potWaterEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
current_water--;
|
||||
this.waterPot(wateringCanConfig.getWidth(), wateringCanConfig.getLength(), location.clone().subtract(0,1,0), player.getLocation().getYaw(), potData.getPotKey(), wateringCanConfig.getParticle());
|
||||
if (wateringCanConfig.hasActionBar()) {
|
||||
AdventureUtils.playerActionbar(player, wateringCanConfig.getActionBarMsg(current_water));
|
||||
}
|
||||
if (wateringCanConfig.getSound() != null) {
|
||||
AdventureUtils.playerSound(player, wateringCanConfig.getSound());
|
||||
}
|
||||
plugin.getWateringCanManager().setWater(item_in_hand, current_water, wateringCanConfig);
|
||||
this.waterPot(wateringCanConfig.getWidth(), wateringCanConfig.getLength(), pot_loc, player.getLocation().getYaw(), potData.getPotKey(), wateringCanConfig.getParticle(), potWaterEvent.getWater());
|
||||
this.doWateringCanActions(player, item_in_hand, wateringCanConfig, current_water);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -437,125 +465,182 @@ public class PlatformManager extends Function {
|
||||
return false;
|
||||
}
|
||||
|
||||
// water
|
||||
PassiveFillMethod[] passiveFillMethods = potConfig.getPassiveFillMethods();
|
||||
for (PassiveFillMethod passiveFillMethod : passiveFillMethods) {
|
||||
if (passiveFillMethod.isRightItem(item_in_hand_id)) {
|
||||
doPassiveFillAction(player, item_in_hand, passiveFillMethod, location);
|
||||
plugin.getWorldDataManager().addWaterToPot(SimpleLocation.getByBukkitLocation(location), passiveFillMethod.getAmount(), pot_id);
|
||||
return true;
|
||||
}
|
||||
PotInteractEvent potInteractEvent = new PotInteractEvent(player, item_in_hand, location, potConfig);
|
||||
Bukkit.getPluginManager().callEvent(potInteractEvent);
|
||||
if (potInteractEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CropConfig cropConfig = plugin.getCropManager().getCropConfigBySeed(item_in_hand_id);
|
||||
if (cropConfig != null) {
|
||||
String[] pot_whitelist = cropConfig.getBottom_blocks();
|
||||
outer: {
|
||||
for (String bottom_block : pot_whitelist) {
|
||||
if (bottom_block.equals(pot_id)) {
|
||||
break outer;
|
||||
outer: {
|
||||
// plant
|
||||
CropConfig cropConfig = plugin.getCropManager().getCropConfigBySeed(item_in_hand_id);
|
||||
if (cropConfig != null) {
|
||||
String[] pot_whitelist = cropConfig.getPotWhitelist();
|
||||
inner: {
|
||||
for (String bottom_block : pot_whitelist) {
|
||||
if (bottom_block.equals(pot_id)) {
|
||||
break inner;
|
||||
}
|
||||
}
|
||||
AdventureUtils.playerMessage(player, MessageManager.prefix + MessageManager.unsuitablePot);
|
||||
return true;
|
||||
}
|
||||
|
||||
Location crop_loc = location.clone().add(0,1,0);
|
||||
Requirement[] requirements = cropConfig.getPlantRequirements();
|
||||
if (requirements != null) {
|
||||
CurrentState currentState = new CurrentState(crop_loc, player);
|
||||
for (Requirement requirement : requirements) {
|
||||
if (!requirement.isConditionMet(currentState)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
AdventureUtils.playerMessage(player, MessageManager.prefix + MessageManager.unsuitablePot);
|
||||
|
||||
if (plugin.getPlatformInterface().detectAnyThing(crop_loc)) return true;
|
||||
if (ConfigManager.enableLimitation && plugin.getWorldDataManager().getChunkCropAmount(SimpleLocation.getByBukkitLocation(crop_loc)) >= ConfigManager.maxCropPerChunk) {
|
||||
AdventureUtils.playerMessage(player, MessageManager.prefix + MessageManager.reachChunkLimit);
|
||||
return true;
|
||||
}
|
||||
|
||||
String crop_model = Objects.requireNonNull(cropConfig.getStageConfig(0)).getModel();
|
||||
CropPlantEvent cropPlantEvent = new CropPlantEvent(player, item_in_hand, location, cropConfig.getKey(), 0, crop_model);
|
||||
Bukkit.getPluginManager().callEvent(cropPlantEvent);
|
||||
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();
|
||||
CustomCropsAPI.getInstance().placeCustomItem(crop_loc, cropPlantEvent.getCropModel(), cropConfig.getCropMode());
|
||||
plugin.getWorldDataManager().addCropData(SimpleLocation.getByBukkitLocation(crop_loc), new GrowingCrop(cropConfig.getKey(), cropPlantEvent.getPoint()));
|
||||
return true;
|
||||
}
|
||||
|
||||
Location crop_loc = location.clone().add(0,1,0);
|
||||
Requirement[] requirements = cropConfig.getPlantRequirements();
|
||||
if (requirements != null) {
|
||||
CurrentState currentState = new CurrentState(crop_loc, player);
|
||||
for (Requirement requirement : requirements) {
|
||||
if (!requirement.isConditionMet(currentState)) {
|
||||
// water
|
||||
PassiveFillMethod[] passiveFillMethods = potConfig.getPassiveFillMethods();
|
||||
for (PassiveFillMethod passiveFillMethod : passiveFillMethods) {
|
||||
if (passiveFillMethod.isRightItem(item_in_hand_id)) {
|
||||
|
||||
PotWaterEvent potWaterEvent = new PotWaterEvent(player, item_in_hand, passiveFillMethod.getAmount(), location);
|
||||
Bukkit.getPluginManager().callEvent(potWaterEvent);
|
||||
if (potWaterEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
doPassiveFillAction(player, item_in_hand, passiveFillMethod, location);
|
||||
plugin.getWorldDataManager().addWaterToPot(SimpleLocation.getByBukkitLocation(location), potWaterEvent.getWater(), pot_id);
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
|
||||
// use watering can
|
||||
WateringCanConfig wateringCanConfig = plugin.getWateringCanManager().getConfigByItemID(item_in_hand_id);
|
||||
if (wateringCanConfig != null) {
|
||||
String[] pot_whitelist = wateringCanConfig.getPotWhitelist();
|
||||
if (pot_whitelist != null) {
|
||||
inner: {
|
||||
for (String pot : pot_whitelist) {
|
||||
if (pot.equals(pot_id)) {
|
||||
break inner;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getPlatformInterface().detectAnyThing(crop_loc)) return true;
|
||||
if (ConfigManager.enableLimitation && plugin.getWorldDataManager().getChunkCropAmount(SimpleLocation.getByBukkitLocation(crop_loc)) >= ConfigManager.maxCropPerChunk) {
|
||||
AdventureUtils.playerMessage(player, MessageManager.prefix + MessageManager.reachChunkLimit);
|
||||
return true;
|
||||
}
|
||||
int current_water = plugin.getWateringCanManager().getCurrentWater(item_in_hand);
|
||||
if (current_water <= 0) return true;
|
||||
|
||||
if (player.getGameMode() != GameMode.CREATIVE) item_in_hand.setAmount(item_in_hand.getAmount() - 1);
|
||||
player.swingMainHand();
|
||||
CustomCropsAPI.getInstance().placeCustomItem(crop_loc, Objects.requireNonNull(cropConfig.getStageConfig(0)).getModel(), cropConfig.getCropMode());
|
||||
plugin.getWorldDataManager().addCropData(SimpleLocation.getByBukkitLocation(crop_loc), new GrowingCrop(cropConfig.getKey(), 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
// use fertilizer
|
||||
FertilizerConfig fertilizerConfig = plugin.getFertilizerManager().getConfigByItemID(item_in_hand_id);
|
||||
if (fertilizerConfig != null) {
|
||||
if (fertilizerConfig.isBeforePlant() && plugin.getCropManager().containsStage(plugin.getPlatformInterface().getCustomItemAt(location.clone().add(0,1,0)))) {
|
||||
AdventureUtils.playerMessage(player, MessageManager.prefix + MessageManager.beforePlant);
|
||||
return true;
|
||||
}
|
||||
if (player.getGameMode() != GameMode.CREATIVE) item_in_hand.setAmount(item_in_hand.getAmount() - 1);
|
||||
player.swingMainHand();
|
||||
if (fertilizerConfig.getSound() != null) {
|
||||
AdventureUtils.playerSound(player, fertilizerConfig.getSound());
|
||||
}
|
||||
if (fertilizerConfig.getParticle() != null) {
|
||||
location.getWorld().spawnParticle(fertilizerConfig.getParticle(), location.clone().add(0.5,1.1,0.5), 5,0.25,0.1,0.25, 0);
|
||||
}
|
||||
plugin.getWorldDataManager().addFertilizerToPot(SimpleLocation.getByBukkitLocation(location), new Fertilizer(fertilizerConfig), pot_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
// use watering can
|
||||
WateringCanConfig wateringCanConfig = plugin.getWateringCanManager().getConfigByItemID(item_in_hand_id);
|
||||
if (wateringCanConfig != null) {
|
||||
String[] pot_whitelist = wateringCanConfig.getPotWhitelist();
|
||||
if (pot_whitelist != null) {
|
||||
outer: {
|
||||
for (String pot : pot_whitelist) {
|
||||
if (pot.equals(pot_id)) {
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
PotWaterEvent potWaterEvent = new PotWaterEvent(player, item_in_hand, 1, location);
|
||||
Bukkit.getPluginManager().callEvent(potWaterEvent);
|
||||
if (potWaterEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
current_water--;
|
||||
this.waterPot(wateringCanConfig.getWidth(), wateringCanConfig.getLength(), location, player.getLocation().getYaw(), pot_id, wateringCanConfig.getParticle(), potWaterEvent.getWater());
|
||||
this.doWateringCanActions(player, item_in_hand, wateringCanConfig, current_water);
|
||||
break outer;
|
||||
}
|
||||
|
||||
int current_water = plugin.getWateringCanManager().getCurrentWater(item_in_hand);
|
||||
if (current_water <= 0) return true;
|
||||
// use fertilizer
|
||||
FertilizerConfig fertilizerConfig = plugin.getFertilizerManager().getConfigByItemID(item_in_hand_id);
|
||||
if (fertilizerConfig != null) {
|
||||
|
||||
//TODO API Events
|
||||
FertilizerUseEvent fertilizerUseEvent = new FertilizerUseEvent(player, item_in_hand, fertilizerConfig, location);
|
||||
Bukkit.getPluginManager().callEvent(fertilizerUseEvent);
|
||||
if (fertilizerUseEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
current_water--;
|
||||
this.waterPot(wateringCanConfig.getWidth(), wateringCanConfig.getLength(), location, player.getLocation().getYaw(), pot_id, wateringCanConfig.getParticle());
|
||||
if (fertilizerConfig.isBeforePlant() && plugin.getCropManager().containsStage(plugin.getPlatformInterface().getAnyItemIDAt(location.clone().add(0,1,0)))) {
|
||||
AdventureUtils.playerMessage(player, MessageManager.prefix + MessageManager.beforePlant);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (wateringCanConfig.hasActionBar()) {
|
||||
AdventureUtils.playerActionbar(player, wateringCanConfig.getActionBarMsg(current_water));
|
||||
}
|
||||
if (wateringCanConfig.getSound() != null) {
|
||||
AdventureUtils.playerSound(player, wateringCanConfig.getSound());
|
||||
if (player.getGameMode() != GameMode.CREATIVE) item_in_hand.setAmount(item_in_hand.getAmount() - 1);
|
||||
player.swingMainHand();
|
||||
|
||||
if (fertilizerConfig.getSound() != null) {
|
||||
AdventureUtils.playerSound(player, fertilizerConfig.getSound());
|
||||
}
|
||||
if (fertilizerConfig.getParticle() != null) {
|
||||
location.getWorld().spawnParticle(fertilizerConfig.getParticle(), location.clone().add(0.5,1.1,0.5), 5,0.25,0.1,0.25, 0);
|
||||
}
|
||||
plugin.getWorldDataManager().addFertilizerToPot(SimpleLocation.getByBukkitLocation(location), new Fertilizer(fertilizerConfig), pot_id);
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getWateringCanManager().setWater(item_in_hand, current_water, wateringCanConfig);
|
||||
return true;
|
||||
Pot potData = plugin.getWorldDataManager().getPotData(SimpleLocation.getByBukkitLocation(location));
|
||||
GrowingCrop growingCrop = plugin.getWorldDataManager().getCropData(SimpleLocation.getByBukkitLocation(location));
|
||||
PotInfoEvent potInfoEvent = new PotInfoEvent(player, location, item_in_hand, potConfig, potData == null ? null : potData.getFertilizer(), potData == null ? 0 : potData.getWater(), growingCrop);
|
||||
Bukkit.getPluginManager().callEvent(potInfoEvent);
|
||||
|
||||
if (potConfig.isHologramEnabled() && potData != null) {
|
||||
double offset = 0;
|
||||
StageConfig stageConfig = plugin.getCropManager().getStageConfig(plugin.getPlatformInterface().getAnyItemIDAt(location.clone().add(0,1,0)));
|
||||
if (stageConfig != null) {
|
||||
offset = stageConfig.getOffsetCorrection();
|
||||
}
|
||||
potConfig.getPotHologram().show(player, potData, location.clone().add(0.5,0,0.5), offset);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void doWateringCanActions(Player player, ItemStack item_in_hand, WateringCanConfig wateringCanConfig, int current_water) {
|
||||
if (wateringCanConfig.hasActionBar()) {
|
||||
AdventureUtils.playerActionbar(player, wateringCanConfig.getActionBarMsg(current_water));
|
||||
}
|
||||
if (wateringCanConfig.getSound() != null) {
|
||||
AdventureUtils.playerSound(player, wateringCanConfig.getSound());
|
||||
}
|
||||
plugin.getWateringCanManager().setWater(item_in_hand, current_water, wateringCanConfig);
|
||||
}
|
||||
|
||||
public boolean onBreakPot(Player player, String id, Location location, Cancellable event) {
|
||||
if (!plugin.getPotManager().containsPotBlock(id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Location above_loc = location.clone().add(0,1,0);
|
||||
String above_id = plugin.getPlatformInterface().getCustomItemAt(above_loc);
|
||||
String above_id = plugin.getPlatformInterface().getAnyItemIDAt(above_loc);
|
||||
// has item above
|
||||
if (above_id != null) {
|
||||
// is a crop
|
||||
if (onBreakCrop(player, above_id, above_loc, event)) {
|
||||
// The event might be cancelled if the player doesn't meet the break requirements
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
plugin.getPlatformInterface().removeCustomItemAt(above_loc);
|
||||
// is a crop
|
||||
if (onBreakCrop(player, above_id, above_loc, event)) {
|
||||
// The event might be cancelled if the player doesn't meet the break requirements
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
plugin.getPlatformInterface().removeCustomItemAt(above_loc);
|
||||
}
|
||||
|
||||
plugin.getWorldDataManager().removePotData(SimpleLocation.getByBukkitLocation(location));
|
||||
@@ -612,7 +697,7 @@ public class PlatformManager extends Function {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void waterPot(int width, int length, Location location, float yaw, String id, @Nullable Particle particle){
|
||||
private void waterPot(int width, int length, Location location, float yaw, String id, @Nullable Particle particle, int water){
|
||||
int extend = width / 2;
|
||||
if (yaw < 45 && yaw > -135) {
|
||||
if (yaw > -45) {
|
||||
@@ -620,7 +705,7 @@ public class PlatformManager extends Function {
|
||||
Location tempLoc = location.clone().add(i, 0, -1);
|
||||
for (int j = 0; j < length; j++){
|
||||
tempLoc.add(0,0,1);
|
||||
tryToWaterPot(tempLoc, id, particle);
|
||||
tryToWaterPot(tempLoc, id, particle, water);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -629,7 +714,7 @@ public class PlatformManager extends Function {
|
||||
Location tempLoc = location.clone().add(-1, 0, i);
|
||||
for (int j = 0; j < length; j++){
|
||||
tempLoc.add(1,0,0);
|
||||
tryToWaterPot(tempLoc, id, particle);
|
||||
tryToWaterPot(tempLoc, id, particle, water);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -640,7 +725,7 @@ public class PlatformManager extends Function {
|
||||
Location tempLoc = location.clone().add(1, 0, i);
|
||||
for (int j = 0; j < length; j++){
|
||||
tempLoc.subtract(1,0,0);
|
||||
tryToWaterPot(tempLoc, id, particle);
|
||||
tryToWaterPot(tempLoc, id, particle, water);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -649,18 +734,18 @@ public class PlatformManager extends Function {
|
||||
Location tempLoc = location.clone().add(i, 0, 1);
|
||||
for (int j = 0; j < length; j++){
|
||||
tempLoc.subtract(0,0,1);
|
||||
tryToWaterPot(tempLoc, id, particle);
|
||||
tryToWaterPot(tempLoc, id, particle, water);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tryToWaterPot(Location location, String pot_id, @Nullable Particle particle) {
|
||||
private void tryToWaterPot(Location location, String pot_id, @Nullable Particle particle, int water) {
|
||||
String blockID = plugin.getPlatformInterface().getBlockID(location.getBlock());
|
||||
String current_id = plugin.getPotManager().getPotKeyByBlockID(blockID);
|
||||
if (current_id != null && current_id.equals(pot_id)) {
|
||||
plugin.getWorldDataManager().addWaterToPot(SimpleLocation.getByBukkitLocation(location), 1, pot_id);
|
||||
plugin.getWorldDataManager().addWaterToPot(SimpleLocation.getByBukkitLocation(location), water, pot_id);
|
||||
if (particle != null)
|
||||
location.getWorld().spawnParticle(particle, location.clone().add(0.5,1, 0.5),3,0.1,0.1,0.1);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.customplugin.itemsadder;
|
||||
|
||||
import dev.lone.itemsadder.api.Events.*;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.customplugin.itemsadder;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
@@ -89,12 +106,6 @@ public class ItemsAdderPluginImpl implements PlatformInterface {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeItemDisplay(Location location) {
|
||||
//TODO Not implemented
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeChorus(Location location, String id) {
|
||||
CustomBlock.place(id, location);
|
||||
@@ -105,25 +116,9 @@ public class ItemsAdderPluginImpl implements PlatformInterface {
|
||||
return location.clone().add(0.5, 0.5, 0.5);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getCustomItemAt(Location location) {
|
||||
String block = getBlockID(location.getBlock());
|
||||
if (!block.equals("AIR")) return block;
|
||||
|
||||
ItemFrame itemFrame = getItemFrameAt(location);
|
||||
if (itemFrame != null) {
|
||||
CustomFurniture customFurniture = CustomFurniture.byAlreadySpawned(itemFrame);
|
||||
if (customFurniture != null) {
|
||||
return customFurniture.getNamespacedID();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getItemID(@NotNull ItemStack itemStack) {
|
||||
public String getItemStackID(@NotNull ItemStack itemStack) {
|
||||
if (itemStack.getType() != Material.AIR) {
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
NBTCompound nbtCompound = nbtItem.getCompound("itemsadder");
|
||||
@@ -131,4 +126,19 @@ public class ItemsAdderPluginImpl implements PlatformInterface {
|
||||
}
|
||||
return itemStack.getType().name();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getItemDisplayID(ItemDisplay itemDisplay) {
|
||||
//TODO Not implemented
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getItemFrameID(ItemFrame itemFrame) {
|
||||
CustomFurniture customFurniture = CustomFurniture.byAlreadySpawned(itemFrame);
|
||||
if (customFurniture == null) return null;
|
||||
return customFurniture.getNamespacedID();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.customplugin.oraxen;
|
||||
|
||||
import io.th0rgal.oraxen.api.events.*;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.customplugin.oraxen;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
@@ -15,6 +32,7 @@ import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanic
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanicFactory;
|
||||
import io.th0rgal.oraxen.utils.drops.Drop;
|
||||
import net.momirealms.customcrops.api.customplugin.PlatformInterface;
|
||||
import net.momirealms.customcrops.api.util.AdventureUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Rotation;
|
||||
@@ -52,26 +70,36 @@ public class OraxenPluginImpl implements PlatformInterface {
|
||||
@Override
|
||||
public ItemFrame placeItemFrame(Location location, String id) {
|
||||
FurnitureMechanic mechanic = (FurnitureMechanic) FurnitureFactory.getInstance().getMechanic(id);
|
||||
if (mechanic == null) {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Item Frame not exists: " + id);
|
||||
return null;
|
||||
}
|
||||
Entity entity = mechanic.place(location, 0, Rotation.NONE, BlockFace.UP);
|
||||
if (entity instanceof ItemFrame itemFrame)
|
||||
return itemFrame;
|
||||
else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Item Frame not exists: " + id);
|
||||
entity.remove();
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemDisplay placeItemDisplay(Location location, String id) {
|
||||
FurnitureMechanic mechanic = (FurnitureMechanic) FurnitureFactory.getInstance().getMechanic(id);
|
||||
if (mechanic == null) {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Item Display not exists: " + id);
|
||||
return null;
|
||||
}
|
||||
Entity entity = mechanic.place(location);
|
||||
if (entity instanceof ItemDisplay itemDisplay)
|
||||
return itemDisplay;
|
||||
else {
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Item Display not exists: " + id);
|
||||
entity.remove();
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,42 +133,40 @@ public class OraxenPluginImpl implements PlatformInterface {
|
||||
drop.spawns(block.getLocation(), new ItemStack(Material.AIR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeItemDisplay(Location location) {
|
||||
//TODO Not implemented
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeChorus(Location location, String id) {
|
||||
//TODO Not implemented
|
||||
//TODO Not implemented, so use tripwire instead
|
||||
StringBlockMechanicFactory.setBlockModel(location.getBlock(), id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getItemFrameLocation(Location location) {
|
||||
return location.clone().add(0.5,0.03125,0.5);
|
||||
return location.clone().add(0.5,0.5,0.5);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getCustomItemAt(Location location) {
|
||||
String block = getBlockID(location.getBlock());
|
||||
if (!block.equals("AIR")) return block;
|
||||
|
||||
ItemFrame itemFrame = getItemFrameAt(location);
|
||||
if (itemFrame != null) {
|
||||
FurnitureMechanic furnitureMechanic = OraxenFurniture.getFurnitureMechanic(itemFrame);
|
||||
if (furnitureMechanic != null) {
|
||||
return furnitureMechanic.getItemID();
|
||||
}
|
||||
public String getItemDisplayID(ItemDisplay itemDisplay) {
|
||||
FurnitureMechanic furnitureMechanic = OraxenFurniture.getFurnitureMechanic(itemDisplay);
|
||||
if (furnitureMechanic != null) {
|
||||
return furnitureMechanic.getItemID();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getItemFrameID(ItemFrame itemFrame) {
|
||||
FurnitureMechanic furnitureMechanic = OraxenFurniture.getFurnitureMechanic(itemFrame);
|
||||
if (furnitureMechanic != null) {
|
||||
return furnitureMechanic.getItemID();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getItemID(@NotNull ItemStack itemStack) {
|
||||
public String getItemStackID(@NotNull ItemStack itemStack) {
|
||||
if (itemStack.getType() != Material.AIR) {
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
NBTCompound bukkitPublic = nbtItem.getCompound("PublicBukkitValues");
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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.event;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CropPlantEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ItemStack hand;
|
||||
private final String crop;
|
||||
private final Location location;
|
||||
private int point;
|
||||
private String crop_model;
|
||||
|
||||
public CropPlantEvent(@NotNull Player who, ItemStack hand, Location location, String crop, int point, String crop_model) {
|
||||
super(who);
|
||||
this.hand = hand;
|
||||
this.location = location;
|
||||
this.crop = crop;
|
||||
this.point = point;
|
||||
this.crop_model = crop_model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
public ItemStack getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
public String getCrop() {
|
||||
return crop;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public int getPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
public void setPoint(int point) {
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the crop stage model key
|
||||
* @return crop model
|
||||
*/
|
||||
public String getCropModel() {
|
||||
return crop_model;
|
||||
}
|
||||
|
||||
public void setCropModel(String crop_model) {
|
||||
this.crop_model = crop_model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.event;
|
||||
|
||||
import net.momirealms.customcrops.api.object.fertilizer.FertilizerConfig;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FertilizerUseEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ItemStack hand;
|
||||
private final FertilizerConfig fertilizerConfig;
|
||||
private final Location location;
|
||||
|
||||
public FertilizerUseEvent(@NotNull Player who, ItemStack hand, FertilizerConfig fertilizerConfig, Location location) {
|
||||
super(who);
|
||||
this.hand = hand;
|
||||
this.fertilizerConfig = fertilizerConfig;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
public ItemStack getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public FertilizerConfig getFertilizerConfig() {
|
||||
return fertilizerConfig;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.event;
|
||||
|
||||
import net.momirealms.customcrops.api.object.crop.GrowingCrop;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.api.object.pot.PotConfig;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PotInfoEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final PotConfig potConfig;
|
||||
private final Fertilizer fertilizer;
|
||||
private final int water;
|
||||
private final GrowingCrop growingCrop;
|
||||
private final ItemStack hand;
|
||||
private final Location location;
|
||||
|
||||
public PotInfoEvent(@NotNull Player who, Location location, ItemStack hand, PotConfig potConfig, @Nullable Fertilizer fertilizer, int water, GrowingCrop growingCrop) {
|
||||
super(who);
|
||||
this.potConfig = potConfig;
|
||||
this.fertilizer = fertilizer;
|
||||
this.water = water;
|
||||
this.growingCrop = growingCrop;
|
||||
this.hand = hand;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
public PotConfig getPotConfig() {
|
||||
return potConfig;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Fertilizer getFertilizer() {
|
||||
return fertilizer;
|
||||
}
|
||||
|
||||
public int getWater() {
|
||||
return water;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GrowingCrop getGrowingCrop() {
|
||||
return growingCrop;
|
||||
}
|
||||
|
||||
public ItemStack getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.event;
|
||||
|
||||
import net.momirealms.customcrops.api.object.pot.PotConfig;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PotInteractEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ItemStack hand;
|
||||
private final Location location;
|
||||
private final PotConfig potConfig;
|
||||
|
||||
public PotInteractEvent(@NotNull Player who, ItemStack hand, Location location, PotConfig potConfig) {
|
||||
super(who);
|
||||
this.hand = hand;
|
||||
this.location = location;
|
||||
this.potConfig = potConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
public ItemStack getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public PotConfig getPotConfig() {
|
||||
return potConfig;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.event;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PotWaterEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ItemStack hand;
|
||||
private int water;
|
||||
private final Location location;
|
||||
|
||||
public PotWaterEvent(@NotNull Player who, ItemStack hand, int water, Location location) {
|
||||
super(who);
|
||||
this.hand = hand;
|
||||
this.water = water;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public ItemStack getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of water
|
||||
* @return the amount of water that adds to the pot
|
||||
*/
|
||||
public int getWater() {
|
||||
return water;
|
||||
}
|
||||
|
||||
public void setWater(int water) {
|
||||
this.water = water;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.event;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SprinklerFillEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final ItemStack hand;
|
||||
private int water;
|
||||
private final Location location;
|
||||
|
||||
public SprinklerFillEvent(@NotNull Player who, ItemStack hand, int water, Location location) {
|
||||
super(who);
|
||||
this.hand = hand;
|
||||
this.water = water;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return getHandlerList();
|
||||
}
|
||||
|
||||
public ItemStack getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of water
|
||||
* @return the amount of water that adds to the sprinkler
|
||||
*/
|
||||
public int getWater() {
|
||||
return water;
|
||||
}
|
||||
|
||||
public void setWater(int water) {
|
||||
this.water = water;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package net.momirealms.customcrops.api.event;
|
||||
|
||||
public class WaterPotEvent {
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
|
||||
package net.momirealms.customcrops.api.object;
|
||||
|
||||
import com.willfp.eco.core.items.Items;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.util.ArmorStandUtils;
|
||||
import net.momirealms.customcrops.api.util.FakeEntityUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class CrowTask extends BukkitRunnable {
|
||||
public class CrowTask implements Runnable {
|
||||
|
||||
private int timer;
|
||||
private final int entityID;
|
||||
@@ -39,38 +39,43 @@ public class CrowTask extends BukkitRunnable {
|
||||
private final float yaw;
|
||||
private final ItemStack fly;
|
||||
private final ItemStack stand;
|
||||
private ScheduledFuture<?> scheduledFuture;
|
||||
|
||||
public CrowTask(Player player, Location crop, String fly_model, String stand_model) {
|
||||
this.timer = 0;
|
||||
this.fly = CustomCrops.getInstance().getIntegrationManager().build(fly_model);
|
||||
this.stand = CustomCrops.getInstance().getIntegrationManager().build(stand_model);
|
||||
this.player = player;
|
||||
this.entityID = new Random().nextInt(10000000);
|
||||
this.yaw = new Random().nextInt(361) - 180;
|
||||
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.vectorDown = new Vector(relative.getX() / 100, -0.1, relative.getZ() / 100);
|
||||
this.vectorUp = new Vector(relative.getX() / 100, 0.1, relative.getZ() / 100);
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, ArmorStandUtils.getSpawnPacket(entityID, from));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, ArmorStandUtils.getMetaPacket(entityID));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, ArmorStandUtils.getEquipPacket(entityID, fly));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getSpawnPacket(entityID, from, EntityType.ARMOR_STAND));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getMetaPacket(entityID));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getEquipPacket(entityID, fly));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
timer++;
|
||||
if (timer < 100) {
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, ArmorStandUtils.getTeleportPacket(entityID, from.add(vectorDown), yaw));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getTeleportPacket(entityID, from.add(vectorDown), yaw));
|
||||
} else if (timer == 100){
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, ArmorStandUtils.getEquipPacket(entityID, stand));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getEquipPacket(entityID, stand));
|
||||
} else if (timer == 150) {
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, ArmorStandUtils.getEquipPacket(entityID, fly));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getEquipPacket(entityID, fly));
|
||||
} else if (timer > 150) {
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, ArmorStandUtils.getTeleportPacket(entityID, from.add(vectorUp), yaw));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getTeleportPacket(entityID, from.add(vectorUp), yaw));
|
||||
}
|
||||
if (timer > 300) {
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, ArmorStandUtils.getDestroyPacket(entityID));
|
||||
cancel();
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getDestroyPacket(entityID));
|
||||
if (scheduledFuture != null) scheduledFuture.cancel(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setScheduledFuture(ScheduledFuture<?> scheduledFuture) {
|
||||
this.scheduledFuture = scheduledFuture;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class Function {
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.util.FakeEntityUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class HologramManager extends Function implements Listener {
|
||||
|
||||
private final ConcurrentHashMap<UUID, HologramCache> hologramMap;
|
||||
private final CustomCrops plugin;
|
||||
private ScheduledFuture<?> scheduledFuture;
|
||||
|
||||
public HologramManager(CustomCrops plugin) {
|
||||
this.plugin = plugin;
|
||||
this.hologramMap = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
scheduledFuture = plugin.getScheduler().runTaskTimerAsync(() -> {
|
||||
ArrayList<UUID> removed = new ArrayList<>(4);
|
||||
long current = System.currentTimeMillis();
|
||||
for (Map.Entry<UUID, HologramCache> entry : hologramMap.entrySet()) {
|
||||
Player player = Bukkit.getPlayer(entry.getKey());
|
||||
if (player == null || !player.isOnline()) {
|
||||
removed.add(entry.getKey());
|
||||
} else {
|
||||
entry.getValue().removeOutDated(current, player);
|
||||
}
|
||||
}
|
||||
for (UUID uuid : removed) {
|
||||
hologramMap.remove(uuid);
|
||||
}
|
||||
}, 500, 500);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
HandlerList.unregisterAll(this);
|
||||
for (Map.Entry<UUID, HologramCache> entry : hologramMap.entrySet()) {
|
||||
Player player = Bukkit.getPlayer(entry.getKey());
|
||||
if (player != null && player.isOnline()) {
|
||||
entry.getValue().removeAll(player);
|
||||
}
|
||||
}
|
||||
if (scheduledFuture != null) scheduledFuture.cancel(false);
|
||||
this.hologramMap.clear();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
this.hologramMap.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
public void showHologram(Player player, Location location, Component component, int millis, Mode mode) {
|
||||
HologramCache hologramCache = hologramMap.get(player.getUniqueId());
|
||||
if (hologramCache != null) {
|
||||
hologramCache.showHologram(player, location, component, millis, mode);
|
||||
} else {
|
||||
hologramCache = new HologramCache();
|
||||
hologramCache.showHologram(player, location, component, millis, mode);
|
||||
hologramMap.put(player.getUniqueId(), hologramCache);
|
||||
}
|
||||
}
|
||||
|
||||
public enum Mode {
|
||||
ARMOR_STAND,
|
||||
TEXT_DISPLAY
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static class HologramCache {
|
||||
|
||||
private final Vector<Tuple<Location, Integer, Long>> tupleList;
|
||||
private Tuple<Location, Integer, Long>[] tuples;
|
||||
|
||||
public HologramCache() {
|
||||
this.tupleList = new Vector<>();
|
||||
this.tuples = new Tuple[0];
|
||||
}
|
||||
|
||||
public int push(Location new_loc, int time) {
|
||||
for (Tuple<Location, Integer, Long> tuple : tuples) {
|
||||
if (new_loc.equals(tuple.getLeft())) {
|
||||
tuple.setRight(System.currentTimeMillis() + time);
|
||||
return tuple.getMid();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void removeOutDated(long current, Player player) {
|
||||
for (Tuple<Location, Integer, Long> tuple : tuples) {
|
||||
if (tuple.getRight() < current) {
|
||||
tupleList.remove(tuple);
|
||||
this.tuples = tupleList.toArray(new Tuple[0]);
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getDestroyPacket(tuple.getMid()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showHologram(Player player, Location location, Component component, int millis, Mode mode) {
|
||||
int entity_id = push(location, millis);
|
||||
if (entity_id == 0) {
|
||||
int random = ThreadLocalRandom.current().nextInt(Integer.MAX_VALUE);
|
||||
tupleList.add(Tuple.of(location, random, System.currentTimeMillis() + millis));
|
||||
this.tuples = tupleList.toArray(new Tuple[0]);
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getSpawnPacket(random, location, EntityType.ARMOR_STAND));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getMetaPacket(random, component));
|
||||
} else {
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getMetaPacket(entity_id, component));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAll(Player player) {
|
||||
for (Tuple<Location, Integer, Long> tuple : tuples) {
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, FakeEntityUtils.getDestroyPacket(tuple.getMid()));
|
||||
}
|
||||
this.tupleList.clear();
|
||||
this.tuples = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,24 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public enum ItemMode {
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public enum ItemType {
|
||||
@@ -7,5 +24,6 @@ public enum ItemType {
|
||||
CROP,
|
||||
SPRINKLER,
|
||||
SCARECROW,
|
||||
WATERINGCAN, UNKNOWN
|
||||
WATERING_CAN,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public record Pair<L, R>(L left, R right) {
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class Tuple<L, M, R> {
|
||||
|
||||
private L left;
|
||||
private M mid;
|
||||
private R right;
|
||||
|
||||
public Tuple(L left, M mid, R right) {
|
||||
this.left = left;
|
||||
this.mid = mid;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
public static <L, M, R> Tuple<L, M, R> of(final L left, final M mid, final R right) {
|
||||
return new Tuple<>(left, mid, right);
|
||||
}
|
||||
|
||||
public L getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
public void setLeft(L left) {
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
public M getMid() {
|
||||
return mid;
|
||||
}
|
||||
|
||||
public void setMid(M mid) {
|
||||
this.mid = mid;
|
||||
}
|
||||
|
||||
public R getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
public void setRight(R right) {
|
||||
this.right = right;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.action;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
@@ -5,7 +22,6 @@ import net.momirealms.customcrops.api.CustomCropsAPI;
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
import net.momirealms.customcrops.api.object.crop.StageConfig;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -22,7 +38,7 @@ public class BreakImpl implements Action {
|
||||
@Override
|
||||
public void doOn(@Nullable Player player, @Nullable SimpleLocation crop_loc, ItemMode itemMode) {
|
||||
if (crop_loc == null) return;
|
||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.getInstance(), () -> {
|
||||
CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
CustomCropsAPI.getInstance().removeCustomItem(crop_loc.getBukkitLocation(), itemMode);
|
||||
CustomCrops.getInstance().getWorldDataManager().removeCropData(crop_loc);
|
||||
return null;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.action;
|
||||
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.action;
|
||||
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.action;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.action;
|
||||
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
|
||||
@@ -1,15 +1,31 @@
|
||||
/*
|
||||
* 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.action;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.CustomCropsAPI;
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.object.basic.MessageManager;
|
||||
import net.momirealms.customcrops.api.object.crop.CropConfig;
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
import net.momirealms.customcrops.api.object.crop.GrowingCrop;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
import net.momirealms.customcrops.api.util.AdventureUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -31,7 +47,7 @@ public class ReplantImpl implements Action {
|
||||
CropConfig cropConfig = CustomCrops.getInstance().getCropManager().getCropConfigByID(crop);
|
||||
if (crop_loc != null && cropConfig != null) {
|
||||
ItemMode newCMode = cropConfig.getCropMode();
|
||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.getInstance(), () -> {
|
||||
CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
Location location = crop_loc.getBukkitLocation();
|
||||
if (location == null) return null;
|
||||
if (ConfigManager.enableLimitation && CustomCrops.getInstance().getWorldDataManager().getChunkCropAmount(crop_loc) >= ConfigManager.maxCropPerChunk) {
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.action;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
@@ -7,7 +24,6 @@ import net.momirealms.customcrops.api.object.crop.VariationCrop;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.Variation;
|
||||
import net.momirealms.customcrops.api.object.pot.Pot;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -48,7 +64,7 @@ public record VariationImpl(VariationCrop[] variationCrops) implements Action {
|
||||
}
|
||||
|
||||
private void doVariation(@NotNull SimpleLocation crop_loc, ItemMode itemMode, VariationCrop variationCrop) {
|
||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.getInstance(), () -> {
|
||||
CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
Location location = crop_loc.getBukkitLocation();
|
||||
if (CustomCropsAPI.getInstance().removeCustomItem(location, itemMode)) {
|
||||
CustomCropsAPI.getInstance().placeCustomItem(location, variationCrop.getId(), variationCrop.getCropMode());
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
/*
|
||||
* 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.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;
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
/*
|
||||
* 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.basic;
|
||||
|
||||
import com.gmail.nossr50.mcmmo.acf.ACFUtil;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.Function;
|
||||
import net.momirealms.customcrops.api.util.ConfigUtils;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.condition;
|
||||
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.condition;
|
||||
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
@@ -5,4 +22,8 @@ import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
public interface Condition {
|
||||
|
||||
boolean isMet(SimpleLocation simpleLocation);
|
||||
|
||||
default int getDelay() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.condition;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
@@ -7,6 +24,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
public class CrowAttack implements Condition {
|
||||
|
||||
private final double chance;
|
||||
@@ -24,12 +43,19 @@ public class CrowAttack implements Condition {
|
||||
if (Math.random() > chance) return false;
|
||||
Location location = simpleLocation.getBukkitLocation();
|
||||
if (location == null) return false;
|
||||
Bukkit.getScheduler().runTask(CustomCrops.getInstance(), () -> {
|
||||
for (Player player : location.getNearbyPlayers(48)) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
SimpleLocation playerLoc = SimpleLocation.getByBukkitLocation(player.getLocation());
|
||||
if (playerLoc.isNear(simpleLocation, 48)) {
|
||||
CrowTask crowTask = new CrowTask(player, location.clone().add(0.4,0,0.4), fly_model, stand_model);
|
||||
crowTask.runTaskTimerAsynchronously(CustomCrops.getInstance(), 1, 1);
|
||||
ScheduledFuture<?> scheduledFuture = CustomCrops.getInstance().getScheduler().runTaskTimerAsync(crowTask, 50, 50);
|
||||
crowTask.setScheduledFuture(scheduledFuture);
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDelay() {
|
||||
return 7000;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,26 @@
|
||||
/*
|
||||
* 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.condition;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.CustomCropsAPI;
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -19,19 +35,19 @@ public class DeathCondition {
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
public boolean checkIfDead(SimpleLocation simpleLocation) {
|
||||
public int checkIfDead(SimpleLocation simpleLocation) {
|
||||
for (Condition condition : conditions) {
|
||||
if (condition.isMet(simpleLocation)) {
|
||||
return true;
|
||||
return condition.getDelay();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void applyDeadModel(SimpleLocation simpleLocation, ItemMode itemMode) {
|
||||
Location location = simpleLocation.getBukkitLocation();
|
||||
if (location == null) return;
|
||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.getInstance(), () -> {
|
||||
CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
CustomCropsAPI.getInstance().removeCustomItem(location, itemMode);
|
||||
if (dead_model != null) {
|
||||
CustomCropsAPI.getInstance().placeCustomItem(location, dead_model, itemMode);
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.condition;
|
||||
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.condition;
|
||||
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.condition;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.condition;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.condition;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.condition;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.crop;
|
||||
|
||||
import net.momirealms.customcrops.api.object.BoneMeal;
|
||||
@@ -13,7 +30,7 @@ import java.util.HashMap;
|
||||
|
||||
public class CropConfig {
|
||||
|
||||
private String key;
|
||||
private final String key;
|
||||
private final ItemMode itemMode;
|
||||
private final String[] bottom_blocks;
|
||||
private final int max_points;
|
||||
@@ -59,21 +76,17 @@ public class CropConfig {
|
||||
return itemMode;
|
||||
}
|
||||
|
||||
public int getMaxPoints() {
|
||||
return max_points;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public StageConfig getStageConfig(int stage) {
|
||||
return stageMap.get(stage);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String[] getBottom_blocks() {
|
||||
public String[] getPotWhitelist() {
|
||||
return bottom_blocks;
|
||||
}
|
||||
|
||||
public int getMax_points() {
|
||||
public int getMaxPoints() {
|
||||
return max_points;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.crop;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
@@ -96,7 +113,8 @@ 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)
|
||||
ConfigUtils.getActions(pointSec.getConfigurationSection(point + ".events.interact-by-hand"), stageModel),
|
||||
pointSec.getDouble(point + ".hologram-offset-correction", 0d)
|
||||
);
|
||||
stageMap.put(parsed, stageConfig);
|
||||
if (stageModel != null) {
|
||||
@@ -165,7 +183,7 @@ public class CropManager extends Function implements Listener {
|
||||
public void onItemSpawn(ItemSpawnEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
Item item = event.getEntity();
|
||||
String id = plugin.getPlatformInterface().getItemID(item.getItemStack());
|
||||
String id = plugin.getPlatformInterface().getItemStackID(item.getItemStack());
|
||||
if (containsStage(id)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.crop;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.crop;
|
||||
|
||||
import net.momirealms.customcrops.api.object.InteractWithItem;
|
||||
@@ -11,13 +28,15 @@ public class StageConfig {
|
||||
private final InteractWithItem[] interactActions;
|
||||
private final Action[] growActions;
|
||||
private final Action[] interactByHandActions;
|
||||
private final double offsetCorrection;
|
||||
|
||||
public StageConfig(@Nullable String model, @Nullable Action[] breakActions, @Nullable Action[] growActions, @Nullable InteractWithItem[] interactActions, @Nullable Action[] interactByHandActions) {
|
||||
public StageConfig(@Nullable String model, @Nullable Action[] breakActions, @Nullable Action[] growActions, @Nullable InteractWithItem[] interactActions, @Nullable Action[] interactByHandActions, double offsetCorrection) {
|
||||
this.breakActions = breakActions;
|
||||
this.interactActions = interactActions;
|
||||
this.growActions = growActions;
|
||||
this.interactByHandActions = interactByHandActions;
|
||||
this.model = model;
|
||||
this.offsetCorrection = offsetCorrection;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -44,4 +63,8 @@ public class StageConfig {
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public double getOffsetCorrection() {
|
||||
return offsetCorrection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.crop;
|
||||
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
|
||||
@@ -1,7 +1,23 @@
|
||||
/*
|
||||
* 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.fertilizer;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -32,8 +48,11 @@ public class Fertilizer implements Serializable {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FertilizerConfig getConfig() {
|
||||
return CustomCrops.getInstance().getFertilizerManager().getConfigByFertilizer(this);
|
||||
}
|
||||
|
||||
public int getLeftTimes() {
|
||||
return times;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,16 +23,17 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class FertilizerConfig {
|
||||
|
||||
protected int times;
|
||||
protected double chance;
|
||||
protected String key;
|
||||
protected FertilizerType fertilizerType;
|
||||
protected String[] pot_whitelist;
|
||||
protected boolean beforePlant;
|
||||
protected Particle particle;
|
||||
protected Sound sound;
|
||||
private final int times;
|
||||
private final double chance;
|
||||
private final String key;
|
||||
private final FertilizerType fertilizerType;
|
||||
private final String[] pot_whitelist;
|
||||
private final boolean beforePlant;
|
||||
private final Particle particle;
|
||||
private final Sound sound;
|
||||
private final String icon;
|
||||
|
||||
public FertilizerConfig(String key, FertilizerType fertilizerType, int times, double chance, @Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound) {
|
||||
public FertilizerConfig(String key, FertilizerType fertilizerType, int times, double chance, @Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound, @Nullable String icon) {
|
||||
this.times = times;
|
||||
this.chance = chance;
|
||||
this.key = key;
|
||||
@@ -41,6 +42,7 @@ public abstract class FertilizerConfig {
|
||||
this.beforePlant = beforePlant;
|
||||
this.particle = particle;
|
||||
this.sound = sound;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public int getTimes() {
|
||||
@@ -81,4 +83,8 @@ public abstract class FertilizerConfig {
|
||||
public Sound getSound() {
|
||||
return sound;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.fertilizer;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
@@ -55,7 +72,7 @@ public class FertilizerManager extends Function {
|
||||
public FertilizerConfig getConfigByItemID(String id) {
|
||||
String key = itemToKey.get(id);
|
||||
if (key == null) return null;
|
||||
return fertilizerConfigMap.get(id);
|
||||
return getConfigByKey(key);
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
@@ -83,16 +100,20 @@ public class FertilizerManager extends Function {
|
||||
Particle particle = fertilizerSec.contains("particle") ? Particle.valueOf(fertilizerSec.getString("particle")) : null;
|
||||
@Subst("namespace:key") String soundKey = fertilizerSec.getString("sound", "minecraft:item.hoe.till");
|
||||
Sound sound = fertilizerSec.contains("sound") ? Sound.sound(Key.key(soundKey), Sound.Source.PLAYER, 1, 1) : null;
|
||||
String icon = fertilizerSec.getString("icon");
|
||||
switch (fertilizerType) {
|
||||
case SPEED_GROW -> fertilizerConfig = new SpeedGrow(key, fertilizerType, times, getChancePair(fertilizerSec), pot_whitelist, beforePlant, particle, sound);
|
||||
case YIELD_INCREASE -> fertilizerConfig = new YieldIncrease(key, fertilizerType, times, fertilizerSec.getDouble("chance"), getChancePair(fertilizerSec), pot_whitelist, beforePlant, particle, sound);
|
||||
case VARIATION -> fertilizerConfig = new Variation(key, fertilizerType, times, fertilizerSec.getDouble("chance"), pot_whitelist, beforePlant, particle, sound);
|
||||
case QUALITY -> fertilizerConfig = new Quality(key, fertilizerType, times, fertilizerSec.getDouble("chance"), ConfigUtils.getQualityRatio(fertilizerSec.getString("ratio", "2/2/1")), pot_whitelist, beforePlant, particle, sound);
|
||||
case SOIL_RETAIN -> fertilizerConfig = new SoilRetain(key, fertilizerType, times, fertilizerSec.getDouble("chance"), pot_whitelist, beforePlant, particle, sound);
|
||||
case SPEED_GROW -> fertilizerConfig = new SpeedGrow(key, fertilizerType, times, getChancePair(fertilizerSec), pot_whitelist, beforePlant, particle, sound, icon);
|
||||
case YIELD_INCREASE -> fertilizerConfig = new YieldIncrease(key, fertilizerType, times, fertilizerSec.getDouble("chance"), getChancePair(fertilizerSec), pot_whitelist, beforePlant, particle, sound, icon);
|
||||
case VARIATION -> fertilizerConfig = new Variation(key, fertilizerType, times, fertilizerSec.getDouble("chance"), pot_whitelist, beforePlant, particle, sound, icon);
|
||||
case QUALITY -> fertilizerConfig = new Quality(key, fertilizerType, times, fertilizerSec.getDouble("chance"), ConfigUtils.getQualityRatio(fertilizerSec.getString("ratio", "2/2/1")), pot_whitelist, beforePlant, particle, sound, icon);
|
||||
case SOIL_RETAIN -> fertilizerConfig = new SoilRetain(key, fertilizerType, times, fertilizerSec.getDouble("chance"), pot_whitelist, beforePlant, particle, sound, icon);
|
||||
default -> fertilizerConfig = null;
|
||||
}
|
||||
if (fertilizerConfig != null)
|
||||
String item = fertilizerSec.getString("item");
|
||||
if (fertilizerConfig != null && item != null) {
|
||||
fertilizerConfigMap.put(key, fertilizerConfig);
|
||||
itemToKey.put(item, key);
|
||||
}
|
||||
else
|
||||
AdventureUtils.consoleMessage("<red>[CustomCrops] Invalid fertilizer: " + key);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.fertilizer;
|
||||
|
||||
public enum FertilizerType {
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.fertilizer;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
@@ -8,8 +25,9 @@ public class Quality extends FertilizerConfig {
|
||||
|
||||
private final double[] ratio;
|
||||
|
||||
public Quality(String key, FertilizerType fertilizerType, int times, double chance, double[] ratio, @Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound);
|
||||
public Quality(String key, FertilizerType fertilizerType, int times, double chance, double[] ratio,
|
||||
@Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound, @Nullable String icon) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound, icon);
|
||||
this.ratio = ratio;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.fertilizer;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
@@ -6,7 +23,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SoilRetain extends FertilizerConfig {
|
||||
|
||||
public SoilRetain(String key, FertilizerType fertilizerType, int times, double chance, @Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound);
|
||||
public SoilRetain(String key, FertilizerType fertilizerType, int times, double chance,
|
||||
@Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound, String icon) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound, icon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.fertilizer;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
@@ -11,15 +28,12 @@ public class SpeedGrow extends FertilizerConfig {
|
||||
|
||||
private final List<Pair<Double, Integer>> pairs;
|
||||
|
||||
public SpeedGrow(String key, FertilizerType fertilizerType, int times, List<Pair<Double, Integer>> pairs, @Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound) {
|
||||
super(key, fertilizerType, times, 1, pot_whitelist, beforePlant, particle, sound);
|
||||
public SpeedGrow(String key, FertilizerType fertilizerType, int times, List<Pair<Double, Integer>> pairs,
|
||||
@Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound, String icon) {
|
||||
super(key, fertilizerType, times, 1, pot_whitelist, beforePlant, particle, sound, icon);
|
||||
this.pairs = pairs;
|
||||
}
|
||||
|
||||
public List<Pair<Double, Integer>> getPairs() {
|
||||
return pairs;
|
||||
}
|
||||
|
||||
public int getPointBonus() {
|
||||
for (Pair<Double, Integer> pair : pairs) {
|
||||
if (Math.random() < pair.left()) {
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.fertilizer;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
@@ -6,7 +23,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Variation extends FertilizerConfig {
|
||||
|
||||
public Variation(String key, FertilizerType fertilizerType, int times, double chance, @Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound);
|
||||
public Variation(String key, FertilizerType fertilizerType, int times, double chance,
|
||||
@Nullable String[] pot_whitelist, boolean beforePlant,
|
||||
@Nullable Particle particle, @Nullable Sound sound, String icon) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound, icon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.fertilizer;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
@@ -11,15 +28,13 @@ public class YieldIncrease extends FertilizerConfig {
|
||||
|
||||
private final List<Pair<Double, Integer>> pairs;
|
||||
|
||||
public YieldIncrease(String key, FertilizerType fertilizerType, int times, double chance, List<Pair<Double, Integer>> pairs, @Nullable String[] pot_whitelist, boolean beforePlant, @Nullable Particle particle, @Nullable Sound sound) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound);
|
||||
public YieldIncrease(String key, FertilizerType fertilizerType, int times, double chance,
|
||||
List<Pair<Double, Integer>> pairs, @Nullable String[] pot_whitelist, boolean beforePlant,
|
||||
@Nullable Particle particle, @Nullable Sound sound, String icon) {
|
||||
super(key, fertilizerType, times, chance, pot_whitelist, beforePlant, particle, sound, icon);
|
||||
this.pairs = pairs;
|
||||
}
|
||||
|
||||
public List<Pair<Double, Integer>> getPairs() {
|
||||
return pairs;
|
||||
}
|
||||
|
||||
public int getAmountBonus() {
|
||||
for (Pair<Double, Integer> pair : pairs) {
|
||||
if (Math.random() < pair.left()) {
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.fill;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.fill;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.fill;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.object.pot.Pot;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.YieldIncrease;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
import net.momirealms.customcrops.integration.SkillInterface;
|
||||
import net.objecthunter.exp4j.Expression;
|
||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
/*
|
||||
* 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.loot;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.FertilizerConfig;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.Quality;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.YieldIncrease;
|
||||
import net.momirealms.customcrops.api.object.pot.Pot;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.Quality;
|
||||
import net.momirealms.customcrops.api.object.world.SimpleLocation;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.pot;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
@@ -35,11 +52,11 @@ public class Pot implements Serializable {
|
||||
*/
|
||||
public boolean addWater(int amount) {
|
||||
if (water == 0) {
|
||||
this.water = Math.min(getConfig().getMax_storage(), amount);
|
||||
this.water = Math.min(getConfig().getMaxStorage(), amount);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
this.water = Math.min(getConfig().getMax_storage(), water + amount);
|
||||
this.water = Math.min(getConfig().getMaxStorage(), water + amount);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
/*
|
||||
* 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.pot;
|
||||
|
||||
import net.momirealms.customcrops.api.object.Pair;
|
||||
import net.momirealms.customcrops.api.object.fill.PassiveFillMethod;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.FertilizerConfig;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.FertilizerType;
|
||||
import net.momirealms.customcrops.api.object.fill.PassiveFillMethod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -17,13 +34,18 @@ public class PotConfig {
|
||||
private final Pair<String, String> pot;
|
||||
private final boolean enableFertilized;
|
||||
private final PassiveFillMethod[] passiveFillMethods;
|
||||
private final boolean enableHologram;
|
||||
private final PotHologram potHologram;
|
||||
|
||||
public PotConfig(int max_storage, String dry_pot, String wet_pot, boolean enableFertilized, @NotNull PassiveFillMethod[] passiveFillMethods) {
|
||||
public PotConfig(int max_storage, String dry_pot, String wet_pot, boolean enableFertilized,
|
||||
@NotNull PassiveFillMethod[] passiveFillMethods, boolean enableHologram, @Nullable PotHologram potHologram) {
|
||||
this.max_storage = max_storage;
|
||||
this.pot = Pair.of(dry_pot, wet_pot);
|
||||
this.enableFertilized = enableFertilized;
|
||||
this.fertilizerConvertMap = new HashMap<>();
|
||||
this.passiveFillMethods = passiveFillMethods;
|
||||
this.enableHologram = enableHologram;
|
||||
this.potHologram = potHologram;
|
||||
}
|
||||
|
||||
public void registerFertilizedPot(FertilizerType fertilizerType, String dry_pot, String wet_pot) {
|
||||
@@ -50,7 +72,7 @@ public class PotConfig {
|
||||
else return pair.left();
|
||||
}
|
||||
|
||||
public int getMax_storage() {
|
||||
public int getMaxStorage() {
|
||||
return max_storage;
|
||||
}
|
||||
|
||||
@@ -58,4 +80,12 @@ public class PotConfig {
|
||||
public PassiveFillMethod[] getPassiveFillMethods() {
|
||||
return passiveFillMethods;
|
||||
}
|
||||
|
||||
public boolean isHologramEnabled() {
|
||||
return enableHologram;
|
||||
}
|
||||
|
||||
public PotHologram getPotHologram() {
|
||||
return potHologram;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* 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.pot;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.HologramManager;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.api.util.AdventureUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class PotHologram {
|
||||
|
||||
private final String fertilizerText;
|
||||
private final double fertilizerOffset;
|
||||
private final String waterText;
|
||||
private final double waterOffset;
|
||||
private final HologramManager.Mode mode;
|
||||
private final int duration;
|
||||
private final String bar_left;
|
||||
private final String bar_full;
|
||||
private final String bar_empty;
|
||||
private final String bar_right;
|
||||
private final Pattern betterPattern = Pattern.compile("\\{(.+?)\\}");
|
||||
|
||||
public PotHologram(String fertilizerText, double fertilizerOffset, String waterText, double waterOffset, HologramManager.Mode mode, int duration,
|
||||
String bar_left, String bar_full, String bar_empty, String bar_right) {
|
||||
this.mode = mode;
|
||||
this.duration = duration;
|
||||
this.fertilizerText = fertilizerText;
|
||||
this.waterText = waterText;
|
||||
this.fertilizerOffset = fertilizerOffset;
|
||||
this.waterOffset = waterOffset;
|
||||
this.bar_left = bar_left;
|
||||
this.bar_full = bar_full;
|
||||
this.bar_empty = bar_empty;
|
||||
this.bar_right = bar_right;
|
||||
}
|
||||
|
||||
private List<String> detectBetterPlaceholders(String text) {
|
||||
List<String> placeholders = new ArrayList<>();
|
||||
Matcher matcher = betterPattern.matcher(text);
|
||||
while (matcher.find()) placeholders.add(matcher.group());
|
||||
return placeholders;
|
||||
}
|
||||
|
||||
public void show(Player player, Pot pot, Location location, double offset) {
|
||||
if (fertilizerText != null && pot.getFertilizer() != null) {
|
||||
String parsed = CustomCrops.getInstance().getIntegrationManager().getPlaceholderManager().parse(player, fertilizerText);
|
||||
parseAndSend(parsed, player, pot, location, offset + fertilizerOffset);
|
||||
}
|
||||
if (waterText != null) {
|
||||
String parsed = CustomCrops.getInstance().getIntegrationManager().getPlaceholderManager().parse(player, waterText);
|
||||
parseAndSend(parsed, player, pot, location, offset + waterOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public void parseAndSend(String parsed, Player player, Pot pot, Location location, double offset) {
|
||||
for (String detected : detectBetterPlaceholders(parsed)) {
|
||||
String replacer = getReplacer(detected, pot);
|
||||
parsed = parsed.replace(detected, replacer);
|
||||
}
|
||||
CustomCrops.getInstance().getHologramManager().showHologram(player, location.clone().add(0, offset, 0), AdventureUtils.getComponentFromMiniMessage(parsed), duration * 1000, mode);
|
||||
}
|
||||
|
||||
public String getReplacer(String text, Pot pot) {
|
||||
switch (text) {
|
||||
case "{icon}" -> {
|
||||
Fertilizer fertilizer = pot.getFertilizer();
|
||||
if (fertilizer == null) return "";
|
||||
return fertilizer.getConfig().getIcon();
|
||||
}
|
||||
case "{left_times}" -> {
|
||||
Fertilizer fertilizer = pot.getFertilizer();
|
||||
if (fertilizer == null) return "";
|
||||
return String.valueOf(fertilizer.getLeftTimes());
|
||||
}
|
||||
case "{max_times}" -> {
|
||||
Fertilizer fertilizer = pot.getFertilizer();
|
||||
if (fertilizer == null) return "";
|
||||
return String.valueOf(fertilizer.getConfig().getTimes());
|
||||
}
|
||||
case "{current}" -> {
|
||||
return String.valueOf(pot.getWater());
|
||||
}
|
||||
case "{storage}" -> {
|
||||
return String.valueOf(pot.getConfig().getMaxStorage());
|
||||
}
|
||||
case "{water_bar}" -> {
|
||||
return getWaterBar(pot.getWater(), pot.getConfig().getMaxStorage());
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getWaterBar(int current, int storage) {
|
||||
return bar_left +
|
||||
String.valueOf(bar_full).repeat(current) +
|
||||
String.valueOf(bar_empty).repeat(storage - current) +
|
||||
bar_right;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,25 @@
|
||||
/*
|
||||
* 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.pot;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.Function;
|
||||
import net.momirealms.customcrops.api.object.HologramManager;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.FertilizerType;
|
||||
import net.momirealms.customcrops.api.object.fill.PassiveFillMethod;
|
||||
import net.momirealms.customcrops.api.util.AdventureUtils;
|
||||
@@ -63,12 +81,26 @@ public class PotManager extends Function {
|
||||
}
|
||||
blockToPotKey.put(base_wet, key);
|
||||
blockToPotKey.put(base_dry, key);
|
||||
boolean enableHolo = section.getBoolean("hologram.enable", false);
|
||||
PotConfig potConfig = new PotConfig(
|
||||
section.getInt("max-water-storage"),
|
||||
base_dry,
|
||||
base_wet,
|
||||
enableFertilized,
|
||||
methods
|
||||
methods,
|
||||
enableHolo,
|
||||
enableHolo ? new PotHologram(
|
||||
section.getString("hologram.fertilizer.text"),
|
||||
section.getDouble("hologram.fertilizer.vertical-offset"),
|
||||
section.getString("hologram.water.text"),
|
||||
section.getDouble("hologram.water.vertical-offset"),
|
||||
HologramManager.Mode.valueOf(section.getString("hologram.type", "ARMOR_STAND").toUpperCase()),
|
||||
section.getInt("hologram.duration"),
|
||||
section.getString("hologram.water.water-bar.left"),
|
||||
section.getString("hologram.water.water-bar.full"),
|
||||
section.getString("hologram.water.water-bar.empty"),
|
||||
section.getString("hologram.water.water-bar.right")
|
||||
) : null
|
||||
);
|
||||
if (enableFertilized) {
|
||||
ConfigurationSection fertilizedSec = section.getConfigurationSection("fertilized-pots");
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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 java.util.Calendar;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.CustomCrops;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.CustomCrops;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.schedule;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class BukkitSchedulerImpl implements SchedulerPlatform {
|
||||
|
||||
private final CustomCrops plugin;
|
||||
|
||||
public BukkitSchedulerImpl(CustomCrops plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Future<T> callSyncMethod(@NotNull Callable<T> task) {
|
||||
return Bukkit.getScheduler().callSyncMethod(plugin, task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runTask(Runnable runnable) {
|
||||
Bukkit.getScheduler().runTask(plugin, runnable);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.schedule;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.Function;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class Scheduler extends Function {
|
||||
|
||||
private final ScheduledThreadPoolExecutor schedule;
|
||||
private final SchedulerPlatform schedulerPlatform;
|
||||
|
||||
public Scheduler(CustomCrops plugin) {
|
||||
this.schedulerPlatform = new BukkitSchedulerImpl(plugin);
|
||||
this.schedule = new ScheduledThreadPoolExecutor(1);
|
||||
this.schedule.setMaximumPoolSize(2);
|
||||
this.schedule.setKeepAliveTime(ConfigManager.keepAliveTime, TimeUnit.SECONDS);
|
||||
this.schedule.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
this.schedule.shutdown();
|
||||
}
|
||||
|
||||
public ScheduledFuture<?> runTaskAsyncLater(Runnable runnable, long delay) {
|
||||
return this.schedule.schedule(runnable, delay, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public void runTaskAsync(Runnable runnable) {
|
||||
this.schedule.execute(runnable);
|
||||
}
|
||||
|
||||
public void runTask(Runnable runnable) {
|
||||
this.schedulerPlatform.runTask(runnable);
|
||||
}
|
||||
|
||||
public <T> Future<T> callSyncMethod(@NotNull Callable<T> task) {
|
||||
return this.schedulerPlatform.callSyncMethod(task);
|
||||
}
|
||||
|
||||
public ScheduledFuture<?> runTaskTimerAsync(Runnable runnable, long delay, long interval) {
|
||||
return this.schedule.scheduleAtFixedRate(runnable, delay, interval, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.schedule;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public interface SchedulerPlatform {
|
||||
|
||||
<T> Future<T> callSyncMethod(@NotNull Callable<T> task);
|
||||
|
||||
void runTask(Runnable runnable);
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.season;
|
||||
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
/*
|
||||
* 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.season;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.Function;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.integration.SeasonInterface;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.sprinkler;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.sprinkler;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.sprinkler;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
@@ -113,7 +130,7 @@ public class SprinklerManager extends Function implements Listener {
|
||||
public void onItemSpawn(ItemSpawnEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
Item item = event.getEntity();
|
||||
String id = plugin.getPlatformInterface().getItemID(item.getItemStack());
|
||||
String id = plugin.getPlatformInterface().getItemStackID(item.getItemStack());
|
||||
String key = itemToKey.get(id);
|
||||
if (key == null) return;
|
||||
String twoD = sprinklerConfigMap.get(key).getTwoD();
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.wateringcan;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.wateringcan;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
|
||||
@@ -1,19 +1,37 @@
|
||||
/*
|
||||
* 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.world;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.CustomCropsAPI;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.object.crop.GrowingCrop;
|
||||
import net.momirealms.customcrops.api.object.pot.Pot;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.api.object.pot.Pot;
|
||||
import net.momirealms.customcrops.api.object.sprinkler.Sprinkler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@@ -108,7 +126,7 @@ public class CCChunk implements Serializable {
|
||||
Pot pot = potMap.get(simpleLocation);
|
||||
if (pot != null) {
|
||||
if (pot.addWater(amount)) {
|
||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.getInstance(), () -> {
|
||||
CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
CustomCropsAPI.getInstance().changePotModel(simpleLocation, pot);
|
||||
return null;
|
||||
});
|
||||
@@ -117,7 +135,7 @@ public class CCChunk implements Serializable {
|
||||
else if (pot_id != null) {
|
||||
Pot newPot = new Pot(pot_id, null, amount);
|
||||
potMap.put(simpleLocation, newPot);
|
||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.getInstance(), () -> {
|
||||
CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
CustomCropsAPI.getInstance().changePotModel(simpleLocation, newPot);
|
||||
return null;
|
||||
});
|
||||
@@ -128,7 +146,7 @@ public class CCChunk implements Serializable {
|
||||
Pot pot = potMap.get(simpleLocation);
|
||||
if (pot != null) {
|
||||
pot.setFertilizer(fertilizer);
|
||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.getInstance(), () -> {
|
||||
CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
CustomCropsAPI.getInstance().changePotModel(simpleLocation, pot);
|
||||
return null;
|
||||
});
|
||||
@@ -136,7 +154,7 @@ public class CCChunk implements Serializable {
|
||||
else {
|
||||
Pot newPot = new Pot(pot_id, fertilizer, 0);
|
||||
potMap.put(simpleLocation, newPot);
|
||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.getInstance(), () -> {
|
||||
CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
CustomCropsAPI.getInstance().changePotModel(simpleLocation, newPot);
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -1,19 +1,38 @@
|
||||
/*
|
||||
* 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.world;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.CustomCropsAPI;
|
||||
import net.momirealms.customcrops.api.object.Function;
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
import net.momirealms.customcrops.api.object.action.Action;
|
||||
import net.momirealms.customcrops.api.object.action.VariationImpl;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.object.condition.Condition;
|
||||
import net.momirealms.customcrops.api.object.condition.DeathCondition;
|
||||
import net.momirealms.customcrops.api.object.crop.CropConfig;
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
import net.momirealms.customcrops.api.object.crop.GrowingCrop;
|
||||
import net.momirealms.customcrops.api.object.crop.StageConfig;
|
||||
import net.momirealms.customcrops.api.object.crop.VariationCrop;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.*;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.FertilizerConfig;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.SoilRetain;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.SpeedGrow;
|
||||
import net.momirealms.customcrops.api.object.pot.Pot;
|
||||
import net.momirealms.customcrops.api.object.season.CCSeason;
|
||||
import net.momirealms.customcrops.api.object.season.SeasonData;
|
||||
@@ -26,7 +45,6 @@ import org.apache.commons.pool2.PooledObject;
|
||||
import org.apache.commons.pool2.impl.DefaultPooledObject;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPool;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -194,6 +212,9 @@ public class CCWorld extends Function {
|
||||
|
||||
private void closePool() {
|
||||
this.schedule.shutdown();
|
||||
//this.cropTaskPool.close();
|
||||
//this.sprinklerTaskPool.close();
|
||||
//this.consumeTaskPool.close();
|
||||
}
|
||||
|
||||
public void pushCropTask(SimpleLocation simpleLocation, int delay) {
|
||||
@@ -299,7 +320,7 @@ public class CCWorld extends Function {
|
||||
pot.setWater(pot.getWater() + 1);
|
||||
}
|
||||
if (pot.reduceWater() | pot.reduceFertilizer()) {
|
||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.getInstance(), () -> {
|
||||
CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
CustomCropsAPI.getInstance().changePotModel(simpleLocation, pot);
|
||||
return null;
|
||||
});
|
||||
@@ -370,9 +391,18 @@ public class CCWorld extends Function {
|
||||
DeathCondition[] deathConditions = cropConfig.getDeathConditions();
|
||||
if (deathConditions != null) {
|
||||
for (DeathCondition deathCondition : deathConditions) {
|
||||
if (deathCondition.checkIfDead(simpleLocation)) {
|
||||
removeCropData(simpleLocation);
|
||||
deathCondition.applyDeadModel(simpleLocation, itemMode);
|
||||
int delay = deathCondition.checkIfDead(simpleLocation);
|
||||
if (delay != -1) {
|
||||
if (delay == 0) {
|
||||
removeCropData(simpleLocation);
|
||||
deathCondition.applyDeadModel(simpleLocation, itemMode);
|
||||
} else {
|
||||
SimpleLocation copied = simpleLocation.copy();
|
||||
schedule.schedule(() -> {
|
||||
removeCropData(copied);
|
||||
deathCondition.applyDeadModel(copied, itemMode);
|
||||
}, delay, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -440,7 +470,7 @@ public class CCWorld extends Function {
|
||||
|
||||
growingCrop.setPoints(current + points);
|
||||
if (ConfigManager.debug) Log.info(simpleLocation.toString() + ":" + growingCrop.getPoints());
|
||||
if (growingCrop.getPoints() >= cropConfig.getMax_points()) {
|
||||
if (growingCrop.getPoints() >= cropConfig.getMaxPoints()) {
|
||||
removeCropData(simpleLocation);
|
||||
}
|
||||
|
||||
@@ -454,7 +484,7 @@ public class CCWorld extends Function {
|
||||
return chunk.isEntitiesLoaded();
|
||||
});
|
||||
loadEntities.whenComplete((result, throwable) ->
|
||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.getInstance(), () -> {
|
||||
CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
if (CustomCropsAPI.getInstance().removeCustomItem(location, itemMode)) {
|
||||
CustomCropsAPI.getInstance().placeCustomItem(location, finalNextModel, itemMode);
|
||||
} else {
|
||||
@@ -465,7 +495,7 @@ public class CCWorld extends Function {
|
||||
}
|
||||
else {
|
||||
asyncGetChunk.whenComplete((result, throwable) ->
|
||||
Bukkit.getScheduler().callSyncMethod(CustomCrops.getInstance(), () -> {
|
||||
CustomCrops.getInstance().getScheduler().callSyncMethod(() -> {
|
||||
if (CustomCropsAPI.getInstance().removeCustomItem(location, itemMode)) {
|
||||
CustomCropsAPI.getInstance().placeCustomItem(location, finalNextModel, itemMode);
|
||||
} else {
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.world;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
@@ -123,4 +123,21 @@ public class SimpleLocation implements Serializable {
|
||||
public String toString() {
|
||||
return "[" + worldName + "," + x + "," + y + "," + z + "]";
|
||||
}
|
||||
|
||||
public boolean isNear(SimpleLocation simpleLocation, int distance) {
|
||||
if (Math.abs(simpleLocation.x - this.x) > distance) {
|
||||
return false;
|
||||
}
|
||||
if (Math.abs(simpleLocation.z - this.z) > distance) {
|
||||
return false;
|
||||
}
|
||||
if (Math.abs(simpleLocation.y - this.y) > distance) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public SimpleLocation copy() {
|
||||
return new SimpleLocation(worldName, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,29 @@
|
||||
/*
|
||||
* 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.world;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.Function;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.object.crop.CropConfig;
|
||||
import net.momirealms.customcrops.api.object.crop.GrowingCrop;
|
||||
import net.momirealms.customcrops.api.object.pot.Pot;
|
||||
import net.momirealms.customcrops.api.object.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.api.object.pot.Pot;
|
||||
import net.momirealms.customcrops.api.object.sprinkler.Sprinkler;
|
||||
import net.momirealms.customcrops.api.object.sprinkler.SprinklerConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -40,6 +55,7 @@ public class WorldDataManager extends Function {
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
this.unload();
|
||||
for (CCWorld ccWorld : worldMap.values()) {
|
||||
ccWorld.unload();
|
||||
}
|
||||
@@ -174,6 +190,7 @@ public class WorldDataManager extends Function {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Pot getPotData(SimpleLocation simpleLocation) {
|
||||
CCWorld ccWorld = worldMap.get(simpleLocation.getWorldName());
|
||||
if (ccWorld != null) {
|
||||
@@ -208,4 +225,13 @@ public class WorldDataManager extends Function {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GrowingCrop getCropData(SimpleLocation simpleLocation) {
|
||||
CCWorld ccWorld = worldMap.get(simpleLocation.getWorldName());
|
||||
if (ccWorld != null) {
|
||||
return ccWorld.getCropData(simpleLocation);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.world;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
@@ -28,13 +28,13 @@ import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.BoneMeal;
|
||||
import net.momirealms.customcrops.api.object.InteractWithItem;
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
import net.momirealms.customcrops.api.object.Pair;
|
||||
import net.momirealms.customcrops.api.object.fill.PassiveFillMethod;
|
||||
import net.momirealms.customcrops.api.object.action.*;
|
||||
import net.momirealms.customcrops.api.object.condition.Random;
|
||||
import net.momirealms.customcrops.api.object.condition.*;
|
||||
import net.momirealms.customcrops.api.object.ItemMode;
|
||||
import net.momirealms.customcrops.api.object.crop.VariationCrop;
|
||||
import net.momirealms.customcrops.api.object.fill.PassiveFillMethod;
|
||||
import net.momirealms.customcrops.api.object.fill.PositiveFillMethod;
|
||||
import net.momirealms.customcrops.api.object.loot.Loot;
|
||||
import net.momirealms.customcrops.api.object.loot.OtherLoot;
|
||||
|
||||
@@ -1,14 +1,29 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import com.comphenix.protocol.wrappers.Pair;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataValue;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.*;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -16,17 +31,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ArmorStandUtils {
|
||||
public class FakeEntityUtils {
|
||||
|
||||
public static void playWaterAnimation(Player player, Location location, String animation_id) {
|
||||
int id = new Random().nextInt(Integer.MAX_VALUE);
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, getSpawnPacket(id, location));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, getSpawnPacket(id, location, EntityType.ARMOR_STAND));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, getMetaPacket(id));
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, getEquipPacket(id, CustomCrops.getInstance().getIntegrationManager().build(animation_id)));
|
||||
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(CustomCrops.getInstance(), () -> {
|
||||
CustomCrops.getInstance().getScheduler().runTaskAsyncLater(() -> {
|
||||
CustomCrops.getProtocolManager().sendServerPacket(player, getDestroyPacket(id));
|
||||
}, 200);
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
public static WrappedDataWatcher createInvisibleDataWatcher() {
|
||||
@@ -45,11 +59,11 @@ public class ArmorStandUtils {
|
||||
return destroyPacket;
|
||||
}
|
||||
|
||||
public static PacketContainer getSpawnPacket(int id, Location location) {
|
||||
public static PacketContainer getSpawnPacket(int id, Location location, EntityType entityType) {
|
||||
PacketContainer entityPacket = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY);
|
||||
entityPacket.getModifier().write(0, id);
|
||||
entityPacket.getModifier().write(1, UUID.randomUUID());
|
||||
entityPacket.getEntityTypeModifier().write(0, EntityType.ARMOR_STAND);
|
||||
entityPacket.getEntityTypeModifier().write(0, entityType);
|
||||
entityPacket.getDoubles().write(0, location.getX());
|
||||
entityPacket.getDoubles().write(1, location.getY());
|
||||
entityPacket.getDoubles().write(2, location.getZ());
|
||||
@@ -61,12 +75,7 @@ public class ArmorStandUtils {
|
||||
metaPacket.getIntegers().write(0, id);
|
||||
if (CustomCrops.getInstance().getVersionHelper().isVersionNewerThan1_19_R2()) {
|
||||
WrappedDataWatcher wrappedDataWatcher = createInvisibleDataWatcher();
|
||||
List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||
wrappedDataWatcher.getWatchableObjects().stream().filter(Objects::nonNull).forEach(entry -> {
|
||||
final WrappedDataWatcher.WrappedDataWatcherObject dataWatcherObject = entry.getWatcherObject();
|
||||
wrappedDataValueList.add(new WrappedDataValue(dataWatcherObject.getIndex(), dataWatcherObject.getSerializer(), entry.getRawValue()));
|
||||
});
|
||||
metaPacket.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
setWrappedDataValue(metaPacket, wrappedDataWatcher);
|
||||
} else {
|
||||
metaPacket.getWatchableCollectionModifier().write(0, createInvisibleDataWatcher().getWatchableObjects());
|
||||
}
|
||||
@@ -92,9 +101,33 @@ public class ArmorStandUtils {
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static PacketContainer getRotationPacket(int id, float yaw) {
|
||||
PacketContainer rotationPacket = new PacketContainer(PacketType.Play.Server.ENTITY_HEAD_ROTATION);
|
||||
rotationPacket.getIntegers().write(0, id);
|
||||
return rotationPacket;
|
||||
public static PacketContainer getMetaPacket(int id, Component component) {
|
||||
PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||
WrappedDataWatcher wrappedDataWatcher = new WrappedDataWatcher();
|
||||
WrappedDataWatcher.Serializer serializer1 = WrappedDataWatcher.Registry.get(Boolean.class);
|
||||
WrappedDataWatcher.Serializer serializer2 = WrappedDataWatcher.Registry.get(Byte.class);
|
||||
wrappedDataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.getChatComponentSerializer(true)), Optional.of(WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(component)).getHandle()));
|
||||
wrappedDataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(3, serializer1), true);
|
||||
wrappedDataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(5, serializer1), true);
|
||||
byte mask1 = 0x20;
|
||||
byte mask2 = 0x01;
|
||||
wrappedDataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, serializer2), mask1);
|
||||
wrappedDataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, serializer2), mask2);
|
||||
metaPacket.getModifier().write(0, id);
|
||||
if (CustomCrops.getInstance().getVersionHelper().isVersionNewerThan1_19_R2()) {
|
||||
setWrappedDataValue(metaPacket, wrappedDataWatcher);
|
||||
} else {
|
||||
metaPacket.getWatchableCollectionModifier().write(0, wrappedDataWatcher.getWatchableObjects());
|
||||
}
|
||||
return metaPacket;
|
||||
}
|
||||
|
||||
private static void setWrappedDataValue(PacketContainer metaPacket, WrappedDataWatcher wrappedDataWatcher) {
|
||||
List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
||||
wrappedDataWatcher.getWatchableObjects().stream().filter(Objects::nonNull).forEach(entry -> {
|
||||
final WrappedDataWatcher.WrappedDataWatcherObject dataWatcherObject = entry.getWatcherObject();
|
||||
wrappedDataValueList.add(new WrappedDataValue(dataWatcherObject.getIndex(), dataWatcherObject.getSerializer(), entry.getRawValue()));
|
||||
});
|
||||
metaPacket.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package net.momirealms.customcrops.api.util;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class PaperUtils {
|
||||
|
||||
public static CompletableFuture<Chunk> getChunkAtAsync(final World world, final int x, final int z) {
|
||||
if (world == null) return CompletableFuture.completedFuture(null);
|
||||
return world.getChunkAtAsync(x, z, false);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.util;
|
||||
|
||||
import org.bukkit.Rotation;
|
||||
|
||||
@@ -1,9 +1,25 @@
|
||||
/*
|
||||
* 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.command.subcmd;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.object.basic.MessageManager;
|
||||
import net.momirealms.customcrops.api.object.season.CCSeason;
|
||||
import net.momirealms.customcrops.api.object.season.SeasonData;
|
||||
import net.momirealms.customcrops.api.util.AdventureUtils;
|
||||
import net.momirealms.customcrops.command.AbstractSubCommand;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.command.subcmd;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.helper;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.utils.MinecraftVersion;
|
||||
@@ -5,7 +22,6 @@ import de.tr7zw.changeme.nbtapi.utils.VersionChecker;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.api.object.basic.ConfigManager;
|
||||
import net.momirealms.customcrops.api.util.AdventureUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
@@ -89,7 +105,7 @@ public class VersionHelper {
|
||||
}
|
||||
|
||||
public void checkUpdate() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
plugin.getScheduler().runTaskAsync(() -> {
|
||||
try {
|
||||
URL url = new URL("https://api.polymart.org/v1/getResourceInfoSimple/?resource_id=2625&key=version");
|
||||
URLConnection conn = url.openConnection();
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.integration;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.integration;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.integration;
|
||||
|
||||
public interface ProtectionInterface {
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.integration;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.integration.item;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
@@ -14,8 +31,7 @@ public class DefaultImpl implements ItemInterface {
|
||||
public ItemStack build(String id) {
|
||||
if (ConfigUtils.isVanillaItem(id)) {
|
||||
return new ItemStack(Material.valueOf(id));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return CustomCrops.getInstance().getPlatformInterface().getItemStack(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* 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.integration.papi;
|
||||
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user