mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 08:29:35 +00:00
1.6.1.0
This commit is contained in:
@@ -19,16 +19,13 @@ package net.momirealms.customcrops;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.momirealms.customcrops.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.fertilizer.RetainingSoil;
|
||||
import net.momirealms.customcrops.fertilizer.SpeedGrow;
|
||||
import net.momirealms.customcrops.helper.Log;
|
||||
import net.momirealms.customcrops.integrations.protection.*;
|
||||
import net.momirealms.customcrops.integrations.skill.*;
|
||||
import net.momirealms.customcrops.objects.Crop;
|
||||
import net.momirealms.customcrops.objects.Sprinkler;
|
||||
import net.momirealms.customcrops.objects.WateringCan;
|
||||
import net.momirealms.customcrops.objects.fertilizer.*;
|
||||
import net.momirealms.customcrops.requirements.Biome;
|
||||
import net.momirealms.customcrops.requirements.Permission;
|
||||
import net.momirealms.customcrops.requirements.Requirement;
|
||||
@@ -492,8 +489,10 @@ public class ConfigReader {
|
||||
if (config.contains("speed")){
|
||||
config.getConfigurationSection("speed").getKeys(false).forEach(key -> {
|
||||
String id = StringUtils.split(config.getString("speed." + key + ".item"), ":")[1];
|
||||
SpeedGrow speedGrow = new SpeedGrow(id, config.getInt("speed." + key + ".times"), config.getDouble("speed." + key + ".chance"), config.getBoolean("speed." + key + ".before-plant"));
|
||||
speedGrow.setName(config.getString("speed." + key + ".name"));
|
||||
SpeedGrow speedGrow = new SpeedGrow(id, config.getInt("speed." + key + ".times"));
|
||||
speedGrow.setName(config.getString("speed." + key + ".name",""));
|
||||
speedGrow.setBefore(config.getBoolean("speed." + key + ".before-plant",false));
|
||||
speedGrow.setChance(config.getDouble("speed." + key + ".chance"));
|
||||
if (config.contains("speed." + key + ".particle"))
|
||||
speedGrow.setParticle(Particle.valueOf(config.getString("speed." + key + ".particle").toUpperCase()));
|
||||
FERTILIZERS.put(id, speedGrow);
|
||||
@@ -502,8 +501,10 @@ public class ConfigReader {
|
||||
if (config.contains("retaining")){
|
||||
config.getConfigurationSection("retaining").getKeys(false).forEach(key -> {
|
||||
String id = StringUtils.split(config.getString("retaining." + key + ".item"), ":")[1];
|
||||
RetainingSoil retainingSoil = new RetainingSoil(id, config.getInt("retaining." + key + ".times"), config.getDouble("retaining." + key + ".chance"), config.getBoolean("retaining." + key + ".before-plant"));
|
||||
retainingSoil.setName(config.getString("retaining." + key + ".name"));
|
||||
RetainingSoil retainingSoil = new RetainingSoil(id, config.getInt("retaining." + key + ".times"));
|
||||
retainingSoil.setBefore(config.getBoolean("retaining." + key + ".before-plant",false));
|
||||
retainingSoil.setChance(config.getDouble("retaining." + key + ".chance"));
|
||||
retainingSoil.setName(config.getString("retaining." + key + ".name",""));
|
||||
if (config.contains("retaining." + key + ".particle"))
|
||||
retainingSoil.setParticle(Particle.valueOf(config.getString("retaining." + key + ".particle").toUpperCase()));
|
||||
FERTILIZERS.put(id, retainingSoil);
|
||||
@@ -517,13 +518,28 @@ public class ConfigReader {
|
||||
weight[0] = Integer.parseInt(split[0]);
|
||||
weight[1] = Integer.parseInt(split[1]);
|
||||
weight[2] = Integer.parseInt(split[2]);
|
||||
QualityCrop qualityCrop = new QualityCrop(key, config.getInt("quality." + key + ".times"), weight, config.getBoolean("quality." + key + ".before-plant"));
|
||||
qualityCrop.setName(config.getString("quality." + key + ".name"));
|
||||
QualityCrop qualityCrop = new QualityCrop(key, config.getInt("quality." + key + ".times"));
|
||||
qualityCrop.setChance(weight);
|
||||
qualityCrop.setName(config.getString("quality." + key + ".name",""));
|
||||
qualityCrop.setBefore(config.getBoolean("quality." + key + ".before-plant",false));
|
||||
if (config.contains("quality." + key + ".particle"))
|
||||
qualityCrop.setParticle(Particle.valueOf(config.getString("quality." + key + ".particle").toUpperCase()));
|
||||
FERTILIZERS.put(id, qualityCrop);
|
||||
});
|
||||
}
|
||||
if (config.contains("quantity")){
|
||||
config.getConfigurationSection("quantity").getKeys(false).forEach(key -> {
|
||||
String id = StringUtils.split(config.getString("quantity." + key + ".item"), ":")[1];
|
||||
YieldIncreasing yieldIncreasing = new YieldIncreasing(key, config.getInt("quantity." + key + ".times",14));
|
||||
yieldIncreasing.setBonus(config.getInt("quantity." + key + ".bonus",1));
|
||||
yieldIncreasing.setName(config.getString("quantity." + key + ".name",""));
|
||||
yieldIncreasing.setBefore(config.getBoolean("quantity." + key + ".before-plant",false));
|
||||
yieldIncreasing.setChance(config.getDouble("quantity." + key + ".chance"));
|
||||
if (config.contains("quantity." + key + ".particle"))
|
||||
yieldIncreasing.setParticle(Particle.valueOf(config.getString("quantity." + key + ".particle").toUpperCase()));
|
||||
FERTILIZERS.put(id, yieldIncreasing);
|
||||
});
|
||||
}
|
||||
AdventureManager.consoleMessage("<gradient:#ff206c:#fdee55>[CustomCrops] </gradient><white>" + FERTILIZERS.size() + " <color:#FFEBCD>fertilizers loaded!");
|
||||
}
|
||||
|
||||
|
||||
@@ -60,12 +60,6 @@ public class Executor implements CommandExecutor {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "test" -> {
|
||||
CustomCrops.plugin.getCropManager().testData();
|
||||
}
|
||||
case "test2" -> {
|
||||
CustomCrops.plugin.getCropManager().testData2();
|
||||
}
|
||||
case "forcegrow" -> {
|
||||
if (args.length < 2) {
|
||||
lackArgs(sender);
|
||||
|
||||
@@ -19,14 +19,11 @@ package net.momirealms.customcrops.datamanager;
|
||||
|
||||
import dev.lone.itemsadder.api.CustomBlock;
|
||||
import dev.lone.itemsadder.api.CustomFurniture;
|
||||
import net.momirealms.customcrops.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.listener.JoinAndQuit;
|
||||
import net.momirealms.customcrops.objects.fertilizer.*;
|
||||
import net.momirealms.customcrops.utils.AdventureManager;
|
||||
import net.momirealms.customcrops.ConfigReader;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.fertilizer.RetainingSoil;
|
||||
import net.momirealms.customcrops.fertilizer.SpeedGrow;
|
||||
import net.momirealms.customcrops.objects.Crop;
|
||||
import net.momirealms.customcrops.utils.FurnitureUtil;
|
||||
import net.momirealms.customcrops.utils.JedisUtil;
|
||||
@@ -108,25 +105,6 @@ public class CropManager{
|
||||
RemoveCache.clear();
|
||||
}
|
||||
|
||||
public void testData(){
|
||||
for (int i = -100; i <= 100; i++){
|
||||
for (int j = -100; j <= 100; j++){
|
||||
SimpleLocation simpleLocation = new SimpleLocation("world",i,128,j);
|
||||
Cache.put(simpleLocation, "XiaoMoMi");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testData2(){
|
||||
World world = Bukkit.getWorld("world");
|
||||
for (int i = -100; i <= 100; i++){
|
||||
for (int j = -100; j <= 100; j++){
|
||||
Location location = new Location(world, i, 128,j);
|
||||
FurnitureUtil.placeCrop("customcrops:tomato_stage_1", location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除无用数据
|
||||
*/
|
||||
@@ -417,8 +395,10 @@ public class CropManager{
|
||||
int times = fertilizer.getTimes();
|
||||
if (times > 0){
|
||||
fertilizer.setTimes(times - 1);
|
||||
|
||||
Fertilizer fertilizerConfig = ConfigReader.FERTILIZERS.get(fertilizer.getKey());
|
||||
//生长激素
|
||||
if (fertilizer instanceof SpeedGrow speedGrow){
|
||||
if (fertilizerConfig instanceof SpeedGrow speedGrow){
|
||||
if (cropInstance.getGrowChance() > Math.random()){
|
||||
//农作物存在下两个阶段
|
||||
if (Math.random() < speedGrow.getChance() && CustomBlock.getInstance(StringUtils.chop(namespacedID) + (nextStage + 1)) != null){
|
||||
@@ -431,7 +411,7 @@ public class CropManager{
|
||||
}
|
||||
}
|
||||
//保湿土壤
|
||||
else if(fertilizer instanceof RetainingSoil retainingSoil){
|
||||
else if(fertilizerConfig instanceof RetainingSoil retainingSoil){
|
||||
if (Math.random() < retainingSoil.getChance()){
|
||||
if (cropInstance.getGrowChance() > Math.random()){
|
||||
addStage(seedLocation, namespacedID, nextStage);
|
||||
@@ -445,7 +425,7 @@ public class CropManager{
|
||||
}
|
||||
}
|
||||
//品质肥料
|
||||
else if(fertilizer instanceof QualityCrop){
|
||||
else if(fertilizerConfig instanceof QualityCrop || fertilizerConfig instanceof YieldIncreasing){
|
||||
if (cropInstance.getGrowChance() > Math.random()){
|
||||
addStage(potLocation, seedLocation, namespacedID, nextStage);
|
||||
}else {
|
||||
@@ -643,9 +623,12 @@ public class CropManager{
|
||||
//查询剩余使用次数
|
||||
int times = fertilizer.getTimes();
|
||||
if (times > 0){
|
||||
|
||||
fertilizer.setTimes(times - 1);
|
||||
|
||||
Fertilizer fertilizerConfig = ConfigReader.FERTILIZERS.get(fertilizer.getKey());
|
||||
//生长激素
|
||||
if (fertilizer instanceof SpeedGrow speedGrow){
|
||||
if (fertilizerConfig instanceof SpeedGrow speedGrow){
|
||||
if (cropInstance.getGrowChance() > Math.random()){
|
||||
//农作物存在下两个阶段
|
||||
if (Math.random() < speedGrow.getChance() && CustomBlock.getInstance(StringUtils.chop(namespacedID) + (nextStage + 1)) != null){
|
||||
@@ -653,13 +636,14 @@ public class CropManager{
|
||||
}else {
|
||||
addStageEntity(potLocation, seedLocation, crop.getArmorstand(), StringUtils.chop(namespacedID) + nextStage);
|
||||
}
|
||||
}else {
|
||||
}
|
||||
else {
|
||||
CustomBlock.remove(potLocation);
|
||||
CustomBlock.place(ConfigReader.Basic.pot, potLocation);
|
||||
}
|
||||
}
|
||||
//保湿土壤
|
||||
else if(fertilizer instanceof RetainingSoil retainingSoil){
|
||||
else if(fertilizerConfig instanceof RetainingSoil retainingSoil){
|
||||
if (Math.random() < retainingSoil.getChance()){
|
||||
if (cropInstance.getGrowChance() > Math.random()){
|
||||
addStageEntity(seedLocation, crop.getArmorstand(), StringUtils.chop(namespacedID) + nextStage);
|
||||
@@ -674,7 +658,7 @@ public class CropManager{
|
||||
}
|
||||
}
|
||||
//品质肥料
|
||||
else if(fertilizer instanceof QualityCrop){
|
||||
else if(fertilizerConfig instanceof QualityCrop || fertilizerConfig instanceof YieldIncreasing){
|
||||
if (cropInstance.getGrowChance() > Math.random()){
|
||||
addStageEntity(potLocation, seedLocation, crop.getArmorstand(), StringUtils.chop(namespacedID) + nextStage);
|
||||
}else {
|
||||
|
||||
@@ -17,13 +17,10 @@
|
||||
|
||||
package net.momirealms.customcrops.datamanager;
|
||||
|
||||
import net.momirealms.customcrops.utils.AdventureManager;
|
||||
import net.momirealms.customcrops.ConfigReader;
|
||||
import net.momirealms.customcrops.objects.fertilizer.*;
|
||||
import net.momirealms.customcrops.utils.AdventureManager;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.fertilizer.RetainingSoil;
|
||||
import net.momirealms.customcrops.fertilizer.SpeedGrow;
|
||||
import net.momirealms.customcrops.objects.SimpleLocation;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
@@ -53,18 +50,24 @@ public class PotManager {
|
||||
}
|
||||
YamlConfiguration data = YamlConfiguration.loadConfiguration(file);
|
||||
data.getKeys(false).forEach(worldName -> {
|
||||
data.getConfigurationSection(worldName).getValues(false).forEach((key, value) ->{
|
||||
String[] split = StringUtils.split(key, ",");
|
||||
data.getConfigurationSection(worldName).getValues(false).forEach((keys, value) ->{
|
||||
String[] split = StringUtils.split(keys, ",");
|
||||
if (value instanceof MemorySection map){
|
||||
String name = (String) map.get("fertilizer");
|
||||
Fertilizer fertilizer = ConfigReader.FERTILIZERS.get(name);
|
||||
String key = map.getString("fertilizer");
|
||||
Fertilizer fertilizer = ConfigReader.FERTILIZERS.get(key);
|
||||
if (fertilizer == null) return;
|
||||
if (fertilizer instanceof SpeedGrow speedGrow){
|
||||
Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), new SpeedGrow(name, (int) map.get("times"), speedGrow.getChance(), speedGrow.isBefore()));
|
||||
}else if (fertilizer instanceof QualityCrop qualityCrop){
|
||||
Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), new QualityCrop(name, (int) map.get("times"), qualityCrop.getChance(), qualityCrop.isBefore()));
|
||||
}else if (fertilizer instanceof RetainingSoil retainingSoil){
|
||||
Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), new RetainingSoil(name, (int) map.get("times"), retainingSoil.getChance(), retainingSoil.isBefore()));
|
||||
if (fertilizer instanceof SpeedGrow){
|
||||
SpeedGrow speedGrow = new SpeedGrow(key, map.getInt("times"));
|
||||
Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), speedGrow);
|
||||
}else if (fertilizer instanceof QualityCrop){
|
||||
QualityCrop qualityCrop = new QualityCrop(key, map.getInt("times"));
|
||||
Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), qualityCrop);
|
||||
}else if (fertilizer instanceof RetainingSoil){
|
||||
RetainingSoil retainingSoil = new RetainingSoil(key, map.getInt("times"));
|
||||
Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), retainingSoil);
|
||||
}else if(fertilizer instanceof YieldIncreasing){
|
||||
YieldIncreasing yieldIncreasing = new YieldIncreasing(key, map.getInt("times"));
|
||||
Cache.put(new SimpleLocation(worldName, Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])), yieldIncreasing);
|
||||
}else {
|
||||
AdventureManager.consoleMessage("<red>[CustomCrops] 未知肥料类型错误!</red>");
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* 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.fertilizer;
|
||||
|
||||
import org.bukkit.Particle;
|
||||
|
||||
public class QualityCrop implements Fertilizer{
|
||||
|
||||
private int[] chance;
|
||||
private String key;
|
||||
private int times;
|
||||
private final boolean before;
|
||||
private String name;
|
||||
private Particle particle;
|
||||
|
||||
public QualityCrop(String key, int times, int[] chance, boolean before) {
|
||||
this.chance = chance;
|
||||
this.times = times;
|
||||
this.before = before;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {return this.key;}
|
||||
@Override
|
||||
public int getTimes() {return this.times;}
|
||||
@Override
|
||||
public void setTimes(int times) {this.times = times;}
|
||||
@Override
|
||||
public boolean isBefore() {return this.before;}
|
||||
@Override
|
||||
public String getName() {return this.name;}
|
||||
@Override
|
||||
public Particle getParticle() {return this.particle;}
|
||||
public int[] getChance() {return chance;}
|
||||
|
||||
public void setName(String name) {this.name = name;}
|
||||
public void setChance(int[] chance) {this.chance = chance;}
|
||||
public void setKey(String key) {this.key = key;}
|
||||
public void setParticle(Particle particle) {this.particle = particle;}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* 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.fertilizer;
|
||||
|
||||
import org.bukkit.Particle;
|
||||
|
||||
public class RetainingSoil implements Fertilizer{
|
||||
|
||||
private double chance;
|
||||
private String key;
|
||||
private int times;
|
||||
private final boolean before;
|
||||
private String name;
|
||||
private Particle particle;
|
||||
|
||||
public RetainingSoil(String key, int times, double chance, boolean before){
|
||||
this.times = times;
|
||||
this.chance = chance;
|
||||
this.before = before;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {return this.key;}
|
||||
@Override
|
||||
public int getTimes() {return this.times;}
|
||||
@Override
|
||||
public void setTimes(int times) {this.times = times;}
|
||||
@Override
|
||||
public boolean isBefore() {return this.before;}
|
||||
@Override
|
||||
public String getName() {return this.name;}
|
||||
@Override
|
||||
public Particle getParticle() {return this.particle;}
|
||||
public double getChance() {return chance;}
|
||||
|
||||
public void setName(String name) {this.name = name;}
|
||||
public void setChance(double chance) {this.chance = chance;}
|
||||
public void setKey(String key) {this.key = key;}
|
||||
public void setParticle(Particle particle) {this.particle = particle;}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* 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.fertilizer;
|
||||
|
||||
import org.bukkit.Particle;
|
||||
|
||||
public class SpeedGrow implements Fertilizer{
|
||||
|
||||
private double chance;
|
||||
private String key;
|
||||
private int times;
|
||||
private final boolean before;
|
||||
private String name;
|
||||
private Particle particle;
|
||||
|
||||
public SpeedGrow(String key, int times, double chance, boolean before){
|
||||
this.chance = chance;
|
||||
this.times = times;
|
||||
this.before = before;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {return this.key;}
|
||||
@Override
|
||||
public int getTimes() {return this.times;}
|
||||
@Override
|
||||
public void setTimes(int times) {this.times = times;}
|
||||
@Override
|
||||
public boolean isBefore() {return this.before;}
|
||||
@Override
|
||||
public String getName() {return this.name;}
|
||||
@Override
|
||||
public Particle getParticle() {return this.particle;}
|
||||
public double getChance() {return chance;}
|
||||
|
||||
public void setName(String name) {this.name = name;}
|
||||
public void setParticle(Particle particle) {this.particle = particle;}
|
||||
public void setChance(double chance) {this.chance = chance;}
|
||||
public void setKey(String key) {this.key = key;}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.momirealms.customcrops.integrations.skill;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class JobsReborn implements SkillXP{
|
||||
@Override
|
||||
public void addXp(Player player, double amount) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.limits;
|
||||
|
||||
import net.momirealms.customcrops.ConfigReader;
|
||||
import net.momirealms.customcrops.utils.FurnitureUtil;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class CropsPerChunkEntity {
|
||||
|
||||
public static boolean isLimited(Location location){
|
||||
if (!ConfigReader.Config.enableLimit) return false;
|
||||
int n = 1;
|
||||
Location chunkLocation = new Location(location.getWorld(),location.getChunk().getX()*16+0.5,ConfigReader.Config.yMin+0.1,location.getChunk().getZ()*16+0.5);
|
||||
Label_out:
|
||||
for (int i = 0; i < 16; ++i)
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
Location square = chunkLocation.clone().add(i, 0, j);
|
||||
for (int k = ConfigReader.Config.yMin; k <= ConfigReader.Config.yMax; ++k) {
|
||||
square.add(0.0, 1.0, 0.0);
|
||||
String namespacedID = FurnitureUtil.getNamespacedID(square);
|
||||
if(namespacedID != null && namespacedID.contains("_stage_")){
|
||||
if (n++ > ConfigReader.Config.cropLimit)
|
||||
break Label_out;
|
||||
}
|
||||
}
|
||||
}
|
||||
return n > ConfigReader.Config.cropLimit;
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import dev.lone.itemsadder.api.Events.CustomBlockBreakEvent;
|
||||
import net.momirealms.customcrops.ConfigReader;
|
||||
import net.momirealms.customcrops.datamanager.CropManager;
|
||||
import net.momirealms.customcrops.datamanager.PotManager;
|
||||
import net.momirealms.customcrops.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.objects.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.integrations.protection.Integration;
|
||||
import net.momirealms.customcrops.objects.Crop;
|
||||
import net.momirealms.customcrops.objects.SimpleLocation;
|
||||
|
||||
@@ -7,12 +7,13 @@ import net.momirealms.customcrops.ConfigReader;
|
||||
import net.momirealms.customcrops.datamanager.CropManager;
|
||||
import net.momirealms.customcrops.datamanager.PotManager;
|
||||
import net.momirealms.customcrops.datamanager.SprinklerManager;
|
||||
import net.momirealms.customcrops.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.objects.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.integrations.protection.Integration;
|
||||
import net.momirealms.customcrops.objects.Crop;
|
||||
import net.momirealms.customcrops.objects.SimpleLocation;
|
||||
import net.momirealms.customcrops.objects.Sprinkler;
|
||||
import net.momirealms.customcrops.objects.fertilizer.YieldIncreasing;
|
||||
import net.momirealms.customcrops.utils.DropUtil;
|
||||
import net.momirealms.customcrops.utils.LocUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -73,6 +74,11 @@ public class BreakFurnitureI implements Listener {
|
||||
else if(ran > 1 - weights[1]/(weightTotal)) world.dropItem(itemLoc, CustomStack.getInstance(cropInstance.getQuality_2()).getItemStack());
|
||||
else world.dropItem(itemLoc, CustomStack.getInstance(cropInstance.getQuality_3()).getItemStack());
|
||||
}
|
||||
}else if (fertilizer instanceof YieldIncreasing yieldIncreasing){
|
||||
if (Math.random() < yieldIncreasing.getChance()){
|
||||
random += yieldIncreasing.getBonus();
|
||||
}
|
||||
DropUtil.normalDrop(cropInstance, random , itemLoc, world);
|
||||
}
|
||||
else DropUtil.normalDrop(cropInstance, random, itemLoc, world);
|
||||
}
|
||||
|
||||
@@ -11,14 +11,15 @@ import net.momirealms.customcrops.ConfigReader;
|
||||
import net.momirealms.customcrops.datamanager.CropManager;
|
||||
import net.momirealms.customcrops.datamanager.PotManager;
|
||||
import net.momirealms.customcrops.datamanager.SprinklerManager;
|
||||
import net.momirealms.customcrops.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.objects.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.integrations.protection.Integration;
|
||||
import net.momirealms.customcrops.listener.JoinAndQuit;
|
||||
import net.momirealms.customcrops.objects.Crop;
|
||||
import net.momirealms.customcrops.objects.SimpleLocation;
|
||||
import net.momirealms.customcrops.objects.Sprinkler;
|
||||
import net.momirealms.customcrops.objects.WateringCan;
|
||||
import net.momirealms.customcrops.objects.fertilizer.YieldIncreasing;
|
||||
import net.momirealms.customcrops.utils.*;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.*;
|
||||
@@ -196,13 +197,16 @@ public class InteractFurnitureI implements Listener {
|
||||
if (ConfigReader.Message.hasCropInfo && nsID.equals(ConfigReader.Basic.soilDetector)){
|
||||
Fertilizer fertilizer = PotManager.Cache.get(LocUtil.fromLocation(location.subtract(0,1,0)));
|
||||
if (fertilizer != null){
|
||||
Fertilizer fertilizer1 = ConfigReader.FERTILIZERS.get(fertilizer.getKey());
|
||||
if (fertilizer1 == null) return;
|
||||
Fertilizer fConfig = ConfigReader.FERTILIZERS.get(fertilizer.getKey());
|
||||
if (fConfig == null) {
|
||||
PotManager.Cache.remove(LocUtil.fromLocation(location));
|
||||
return;
|
||||
}
|
||||
HoloUtil.showHolo(
|
||||
ConfigReader.Message.cropText
|
||||
.replace("{fertilizer}", fertilizer1.getName())
|
||||
.replace("{fertilizer}", fConfig.getName())
|
||||
.replace("{times}", String.valueOf(fertilizer.getTimes()))
|
||||
.replace("{max_times}", String.valueOf(fertilizer1.getTimes())),
|
||||
.replace("{max_times}", String.valueOf(fConfig.getTimes())),
|
||||
player,
|
||||
location.add(0, ConfigReader.Message.cropOffset, 0),
|
||||
ConfigReader.Message.cropTime);
|
||||
@@ -267,7 +271,9 @@ public class InteractFurnitureI implements Listener {
|
||||
if (ConfigReader.Config.skillXP != null && cropInstance.getSkillXP() != 0) ConfigReader.Config.skillXP.addXp(player, cropInstance.getSkillXP());
|
||||
if (cropInstance.getOtherLoots() != null) cropInstance.getOtherLoots().forEach(s -> location.getWorld().dropItem(itemLoc, CustomStack.getInstance(s).getItemStack()));
|
||||
if (fertilizer != null){
|
||||
if (fertilizer instanceof QualityCrop qualityCrop){
|
||||
Fertilizer fConfig = ConfigReader.FERTILIZERS.get(fertilizer.getKey());
|
||||
if (fConfig == null) return;
|
||||
if (fConfig instanceof QualityCrop qualityCrop){
|
||||
int[] weights = qualityCrop.getChance();
|
||||
double weightTotal = weights[0] + weights[1] + weights[2];
|
||||
for (int i = 0; i < random; i++){
|
||||
@@ -276,6 +282,11 @@ public class InteractFurnitureI implements Listener {
|
||||
else if(ran > 1 - weights[1]/(weightTotal)) world.dropItem(itemLoc, CustomStack.getInstance(cropInstance.getQuality_2()).getItemStack());
|
||||
else world.dropItem(itemLoc, CustomStack.getInstance(cropInstance.getQuality_3()).getItemStack());
|
||||
}
|
||||
}else if (fConfig instanceof YieldIncreasing yieldIncreasing){
|
||||
if (Math.random() < yieldIncreasing.getChance()){
|
||||
random += yieldIncreasing.getBonus();
|
||||
}
|
||||
DropUtil.normalDrop(cropInstance, random , itemLoc, world);
|
||||
}
|
||||
else DropUtil.normalDrop(cropInstance, random, itemLoc, world);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ import net.momirealms.customcrops.datamanager.CropManager;
|
||||
import net.momirealms.customcrops.datamanager.PotManager;
|
||||
import net.momirealms.customcrops.datamanager.SeasonManager;
|
||||
import net.momirealms.customcrops.datamanager.SprinklerManager;
|
||||
import net.momirealms.customcrops.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.integrations.protection.Integration;
|
||||
import net.momirealms.customcrops.limits.CropsPerChunk;
|
||||
import net.momirealms.customcrops.limits.CropsPerChunkEntity;
|
||||
import net.momirealms.customcrops.limits.SprinklersPerChunk;
|
||||
import net.momirealms.customcrops.listener.JoinAndQuit;
|
||||
import net.momirealms.customcrops.objects.Crop;
|
||||
@@ -94,7 +94,7 @@ public class RightClickI implements Listener {
|
||||
}
|
||||
if (location.getBlock().getType() != Material.AIR) return;
|
||||
if (player.getGameMode() != GameMode.CREATIVE) itemStack.setAmount(itemStack.getAmount() - 1);
|
||||
if (CropsPerChunk.isLimited(location)){
|
||||
if (CropsPerChunkEntity.isLimited(location)){
|
||||
AdventureManager.playerMessage(player,ConfigReader.Message.prefix + ConfigReader.Message.crop_limit.replace("{max}", String.valueOf(ConfigReader.Config.cropLimit)));
|
||||
return;
|
||||
}
|
||||
@@ -237,16 +237,18 @@ public class RightClickI implements Listener {
|
||||
String namespacedID = customBlock.getNamespacedID();
|
||||
if(namespacedID.equals(ConfigReader.Basic.pot) || namespacedID.equals(ConfigReader.Basic.watered_pot)){
|
||||
Location location = block.getLocation();
|
||||
Fertilizer fertilizer = PotManager.Cache.get(LocUtil.fromLocation(block.getLocation()));
|
||||
Fertilizer fertilizer = PotManager.Cache.get(LocUtil.fromLocation(location));
|
||||
if (fertilizer != null){
|
||||
Fertilizer config = ConfigReader.FERTILIZERS.get(fertilizer.getKey());
|
||||
String name = config.getName();
|
||||
int max_times = config.getTimes();
|
||||
if (config == null){
|
||||
PotManager.Cache.remove(LocUtil.fromLocation(location));
|
||||
return;
|
||||
}
|
||||
HoloUtil.showHolo(
|
||||
ConfigReader.Message.cropText
|
||||
.replace("{fertilizer}", name)
|
||||
.replace("{fertilizer}", config.getName())
|
||||
.replace("{times}", String.valueOf(fertilizer.getTimes()))
|
||||
.replace("{max_times}", String.valueOf(max_times)),
|
||||
.replace("{max_times}", String.valueOf(config.getTimes())),
|
||||
player,
|
||||
location.add(0.5,ConfigReader.Message.cropOffset,0.5),
|
||||
ConfigReader.Message.cropTime);
|
||||
|
||||
@@ -24,11 +24,12 @@ import net.momirealms.customcrops.ConfigReader;
|
||||
import net.momirealms.customcrops.CustomCrops;
|
||||
import net.momirealms.customcrops.datamanager.CropManager;
|
||||
import net.momirealms.customcrops.datamanager.PotManager;
|
||||
import net.momirealms.customcrops.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.objects.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.integrations.protection.Integration;
|
||||
import net.momirealms.customcrops.objects.Crop;
|
||||
import net.momirealms.customcrops.objects.SimpleLocation;
|
||||
import net.momirealms.customcrops.objects.fertilizer.YieldIncreasing;
|
||||
import net.momirealms.customcrops.utils.DropUtil;
|
||||
import net.momirealms.customcrops.utils.LocUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -142,6 +143,11 @@ public class BreakBlockT implements Listener {
|
||||
else if(ran > 1 - weights[1]/(weightTotal)) world.dropItem(itemLoc, CustomStack.getInstance(cropInstance.getQuality_2()).getItemStack());
|
||||
else world.dropItem(itemLoc, CustomStack.getInstance(cropInstance.getQuality_3()).getItemStack());
|
||||
}
|
||||
}else if (fertilizer instanceof YieldIncreasing yieldIncreasing){
|
||||
if (Math.random() < yieldIncreasing.getChance()){
|
||||
random += yieldIncreasing.getBonus();
|
||||
}
|
||||
DropUtil.normalDrop(cropInstance, random , itemLoc, world);
|
||||
}
|
||||
}
|
||||
else DropUtil.normalDrop(cropInstance, random, itemLoc, world);
|
||||
|
||||
@@ -28,8 +28,8 @@ import net.momirealms.customcrops.datamanager.CropManager;
|
||||
import net.momirealms.customcrops.datamanager.PotManager;
|
||||
import net.momirealms.customcrops.datamanager.SeasonManager;
|
||||
import net.momirealms.customcrops.datamanager.SprinklerManager;
|
||||
import net.momirealms.customcrops.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.objects.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.objects.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.integrations.protection.Integration;
|
||||
import net.momirealms.customcrops.limits.CropsPerChunk;
|
||||
import net.momirealms.customcrops.limits.SprinklersPerChunk;
|
||||
@@ -38,6 +38,7 @@ import net.momirealms.customcrops.objects.Crop;
|
||||
import net.momirealms.customcrops.objects.SimpleLocation;
|
||||
import net.momirealms.customcrops.objects.Sprinkler;
|
||||
import net.momirealms.customcrops.objects.WateringCan;
|
||||
import net.momirealms.customcrops.objects.fertilizer.YieldIncreasing;
|
||||
import net.momirealms.customcrops.requirements.PlantingCondition;
|
||||
import net.momirealms.customcrops.requirements.Requirement;
|
||||
import net.momirealms.customcrops.utils.*;
|
||||
@@ -297,7 +298,10 @@ public class RightClickT implements Listener {
|
||||
Fertilizer fertilizer = PotManager.Cache.get(LocUtil.fromLocation(location));
|
||||
if (fertilizer != null){
|
||||
Fertilizer config = ConfigReader.FERTILIZERS.get(fertilizer.getKey());
|
||||
if (config == null) return;
|
||||
if (config == null){
|
||||
PotManager.Cache.remove(LocUtil.fromLocation(location));
|
||||
return;
|
||||
}
|
||||
HoloUtil.showHolo(
|
||||
ConfigReader.Message.cropText
|
||||
.replace("{fertilizer}", config.getName())
|
||||
@@ -307,18 +311,21 @@ public class RightClickT implements Listener {
|
||||
location.add(0.5, ConfigReader.Message.cropOffset, 0.5),
|
||||
ConfigReader.Message.cropTime);
|
||||
}
|
||||
}else if(namespacedID.equals(ConfigReader.Basic.pot) || namespacedID.equals(ConfigReader.Basic.watered_pot)){
|
||||
}
|
||||
else if(namespacedID.equals(ConfigReader.Basic.pot) || namespacedID.equals(ConfigReader.Basic.watered_pot)){
|
||||
Location location = block.getLocation();
|
||||
Fertilizer fertilizer = PotManager.Cache.get(LocUtil.fromLocation(block.getLocation()));
|
||||
if (fertilizer != null){
|
||||
Fertilizer config = ConfigReader.FERTILIZERS.get(fertilizer.getKey());
|
||||
String name = config.getName();
|
||||
int max_times = config.getTimes();
|
||||
if (config == null){
|
||||
PotManager.Cache.remove(LocUtil.fromLocation(location));
|
||||
return;
|
||||
}
|
||||
HoloUtil.showHolo(
|
||||
ConfigReader.Message.cropText
|
||||
.replace("{fertilizer}", name)
|
||||
.replace("{times}", String.valueOf(fertilizer.getTimes()))
|
||||
.replace("{max_times}", String.valueOf(max_times)),
|
||||
.replace("{fertilizer}", config.getName())
|
||||
.replace("{times}", String.valueOf(fertilizer.getTimes()))
|
||||
.replace("{max_times}", String.valueOf(config.getTimes())),
|
||||
player,
|
||||
location.add(0.5,ConfigReader.Message.cropOffset,0.5),
|
||||
ConfigReader.Message.cropTime);
|
||||
@@ -388,7 +395,9 @@ public class RightClickT implements Listener {
|
||||
if (cropInstance.doesDropIALoot()) customBlock.getLoot().forEach(itemStack -> location.getWorld().dropItem(location.clone().add(0.5,0.2,0.5), itemStack));
|
||||
if (cropInstance.getOtherLoots() != null) cropInstance.getOtherLoots().forEach(s -> location.getWorld().dropItem(location.clone().add(0.5,0.2,0.5), CustomStack.getInstance(s).getItemStack()));
|
||||
if (fertilizer != null){
|
||||
if (fertilizer instanceof QualityCrop qualityCrop){
|
||||
Fertilizer fConfig = ConfigReader.FERTILIZERS.get(fertilizer.getKey());
|
||||
if (fConfig == null) return;
|
||||
if (fConfig instanceof QualityCrop qualityCrop){
|
||||
int[] weights = qualityCrop.getChance();
|
||||
double weightTotal = weights[0] + weights[1] + weights[2];
|
||||
for (int i = 0; i < random; i++){
|
||||
@@ -397,6 +406,11 @@ public class RightClickT implements Listener {
|
||||
else if(ran > 1 - weights[1]/(weightTotal)) world.dropItem(itemLoc, CustomStack.getInstance(cropInstance.getQuality_2()).getItemStack());
|
||||
else world.dropItem(itemLoc, CustomStack.getInstance(cropInstance.getQuality_3()).getItemStack());
|
||||
}
|
||||
}else if (fConfig instanceof YieldIncreasing yieldIncreasing){
|
||||
if (Math.random() < yieldIncreasing.getChance()){
|
||||
random += yieldIncreasing.getBonus();
|
||||
}
|
||||
DropUtil.normalDrop(cropInstance, random, itemLoc, world);
|
||||
}
|
||||
else DropUtil.normalDrop(cropInstance, random, itemLoc, world);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package net.momirealms.customcrops.objects.fertilizer;
|
||||
|
||||
import org.bukkit.Particle;
|
||||
|
||||
public class Fertilizer {
|
||||
|
||||
String key;
|
||||
int times;
|
||||
boolean before;
|
||||
String name;
|
||||
Particle particle;
|
||||
|
||||
protected Fertilizer(String key, int times) {
|
||||
this.key = key;
|
||||
this.times = times;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public int getTimes() {
|
||||
return times;
|
||||
}
|
||||
|
||||
public void setTimes(int times) {
|
||||
this.times = times;
|
||||
}
|
||||
|
||||
public boolean isBefore() {
|
||||
return before;
|
||||
}
|
||||
|
||||
public void setBefore(boolean before) {
|
||||
this.before = before;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Particle getParticle() {
|
||||
return particle;
|
||||
}
|
||||
|
||||
public void setParticle(Particle particle) {
|
||||
this.particle = particle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.objects.fertilizer;
|
||||
|
||||
|
||||
public class QualityCrop extends Fertilizer {
|
||||
|
||||
private int[] chance;
|
||||
|
||||
public QualityCrop(String key, int times) {
|
||||
super(key, times);
|
||||
}
|
||||
|
||||
public int[] getChance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public void setChance(int[] chance) {
|
||||
this.chance = chance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.objects.fertilizer;
|
||||
|
||||
public class RetainingSoil extends Fertilizer {
|
||||
|
||||
double chance;
|
||||
|
||||
public double getChance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public void setChance(double chance) {
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
public RetainingSoil(String key, int times){
|
||||
super(key, times);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,15 +15,21 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.fertilizer;
|
||||
package net.momirealms.customcrops.objects.fertilizer;
|
||||
|
||||
import org.bukkit.Particle;
|
||||
public class SpeedGrow extends Fertilizer {
|
||||
|
||||
public interface Fertilizer {
|
||||
String getKey();
|
||||
int getTimes();
|
||||
void setTimes(int times);
|
||||
boolean isBefore();
|
||||
String getName();
|
||||
Particle getParticle();
|
||||
private double chance;
|
||||
|
||||
public SpeedGrow(String key, int times){
|
||||
super(key, times);
|
||||
}
|
||||
|
||||
public double getChance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public void setChance(double chance) {
|
||||
this.chance = chance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.momirealms.customcrops.objects.fertilizer;
|
||||
|
||||
public class YieldIncreasing extends Fertilizer {
|
||||
|
||||
private int bonus;
|
||||
private double chance;
|
||||
|
||||
public YieldIncreasing(String key, int times) {
|
||||
super(key, times);
|
||||
}
|
||||
|
||||
public double getChance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public void setChance(double chance) {
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
public int getBonus() {
|
||||
return bonus;
|
||||
}
|
||||
|
||||
public void setBonus(int bonus) {
|
||||
this.bonus = bonus;
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,7 @@ package net.momirealms.customcrops.utils;
|
||||
import dev.lone.itemsadder.api.CustomBlock;
|
||||
import net.momirealms.customcrops.ConfigReader;
|
||||
import net.momirealms.customcrops.datamanager.PotManager;
|
||||
import net.momirealms.customcrops.fertilizer.Fertilizer;
|
||||
import net.momirealms.customcrops.fertilizer.QualityCrop;
|
||||
import net.momirealms.customcrops.fertilizer.RetainingSoil;
|
||||
import net.momirealms.customcrops.fertilizer.SpeedGrow;
|
||||
import net.momirealms.customcrops.objects.SimpleLocation;
|
||||
import net.momirealms.customcrops.objects.fertilizer.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
|
||||
@@ -97,14 +93,17 @@ public class PotUtil {
|
||||
*/
|
||||
public static void addFertilizer(Fertilizer fertilizerConfig, Location location) {
|
||||
if (fertilizerConfig instanceof QualityCrop config){
|
||||
QualityCrop qualityCrop = new QualityCrop(config.getKey(), config.getTimes(), config.getChance(), config.isBefore());
|
||||
QualityCrop qualityCrop = new QualityCrop(config.getKey(), config.getTimes());
|
||||
PotManager.Cache.put(LocUtil.fromLocation(location), qualityCrop);
|
||||
}else if (fertilizerConfig instanceof SpeedGrow config){
|
||||
SpeedGrow speedGrow = new SpeedGrow(config.getKey(), config.getTimes(),config.getChance(), config.isBefore());
|
||||
SpeedGrow speedGrow = new SpeedGrow(config.getKey(), config.getTimes());
|
||||
PotManager.Cache.put(LocUtil.fromLocation(location), speedGrow);
|
||||
}else if (fertilizerConfig instanceof RetainingSoil config){
|
||||
RetainingSoil retainingSoil = new RetainingSoil(config.getKey(), config.getTimes(),config.getChance(), config.isBefore());
|
||||
RetainingSoil retainingSoil = new RetainingSoil(config.getKey(), config.getTimes());
|
||||
PotManager.Cache.put(LocUtil.fromLocation(location), retainingSoil);
|
||||
}else if (fertilizerConfig instanceof YieldIncreasing config){
|
||||
YieldIncreasing yieldIncreasing = new YieldIncreasing(config.getKey(), config.getTimes());
|
||||
PotManager.Cache.put(LocUtil.fromLocation(location), yieldIncreasing);
|
||||
}
|
||||
if (fertilizerConfig.getParticle() != null) location.getWorld().spawnParticle(fertilizerConfig.getParticle(), location.add(0.5,1.3,0.5), 5,0.2,0.2,0.2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user