mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-22 08:29:35 +00:00
2.0-r1
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'net.momirealms'
|
group = 'net.momirealms'
|
||||||
version = '2.0-PRE-2'
|
version = '2.0-r1-hotfix'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import net.momirealms.customcrops.api.utils.SeasonUtils;
|
|||||||
import net.momirealms.customcrops.commands.AbstractSubCommand;
|
import net.momirealms.customcrops.commands.AbstractSubCommand;
|
||||||
import net.momirealms.customcrops.commands.SubCommand;
|
import net.momirealms.customcrops.commands.SubCommand;
|
||||||
import net.momirealms.customcrops.config.MessageConfig;
|
import net.momirealms.customcrops.config.MessageConfig;
|
||||||
|
import net.momirealms.customcrops.config.SeasonConfig;
|
||||||
import net.momirealms.customcrops.integrations.season.CCSeason;
|
import net.momirealms.customcrops.integrations.season.CCSeason;
|
||||||
import net.momirealms.customcrops.utils.AdventureUtil;
|
import net.momirealms.customcrops.utils.AdventureUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -40,6 +41,10 @@ public class SetSeasonCommand extends AbstractSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, List<String> args) {
|
public boolean onCommand(CommandSender sender, List<String> args) {
|
||||||
|
if (!SeasonConfig.enable) {
|
||||||
|
AdventureUtil.sendMessage(sender, MessageConfig.prefix + MessageConfig.seasonDisabled);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
AdventureUtil.sendMessage(sender, MessageConfig.prefix + MessageConfig.lackArgs);
|
AdventureUtil.sendMessage(sender, MessageConfig.prefix + MessageConfig.lackArgs);
|
||||||
return true;
|
return true;
|
||||||
@@ -66,6 +71,7 @@ public class SetSeasonCommand extends AbstractSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, List<String> args) {
|
public List<String> onTabComplete(CommandSender sender, List<String> args) {
|
||||||
|
if (!SeasonConfig.enable) return null;
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
return getWorlds(args);
|
return getWorlds(args);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,5 +74,9 @@ public class ConfigUtil {
|
|||||||
CustomCrops.plugin.getPlaceholderManager().unload();
|
CustomCrops.plugin.getPlaceholderManager().unload();
|
||||||
CustomCrops.plugin.getPlaceholderManager().load();
|
CustomCrops.plugin.getPlaceholderManager().load();
|
||||||
}
|
}
|
||||||
|
if (CustomCrops.plugin.getCropManager() != null) {
|
||||||
|
CustomCrops.plugin.getCropManager().loadMode();
|
||||||
|
CustomCrops.plugin.getCropManager().loadSeason();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public class CropConfig {
|
|||||||
config.getString(key + ".requirements." + requirement + ".message")
|
config.getString(key + ".requirements." + requirement + ".message")
|
||||||
));
|
));
|
||||||
case "papi-condition" -> requirementList.add(new CustomPapi(
|
case "papi-condition" -> requirementList.add(new CustomPapi(
|
||||||
Objects.requireNonNull(config.getConfigurationSection(key + ".requirements." + requirement + ".papi-condition")).getValues(false),
|
Objects.requireNonNull(config.getConfigurationSection(key + ".requirements." + requirement + ".value")).getValues(false),
|
||||||
config.getString(key + ".requirements." + requirement + ".message")
|
config.getString(key + ".requirements." + requirement + ".message")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ public class MainConfig {
|
|||||||
public static boolean syncSeason;
|
public static boolean syncSeason;
|
||||||
public static World syncWorld;
|
public static World syncWorld;
|
||||||
public static boolean autoBackUp;
|
public static boolean autoBackUp;
|
||||||
|
public static boolean needSkyLight;
|
||||||
|
public static int skyLightLevel;
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
ConfigUtil.update("config.yml");
|
ConfigUtil.update("config.yml");
|
||||||
@@ -146,6 +148,9 @@ public class MainConfig {
|
|||||||
enableCrow = config.getBoolean("mechanics.crow.enable", false);
|
enableCrow = config.getBoolean("mechanics.crow.enable", false);
|
||||||
crowChance = config.getDouble("mechanics.crow.chance", 0.001);
|
crowChance = config.getDouble("mechanics.crow.chance", 0.001);
|
||||||
|
|
||||||
|
skyLightLevel = config.getInt("mechanics.dead-if-no-sky-light.level", 10);
|
||||||
|
needSkyLight = config.getBoolean("mechanics.dead-if-no-sky-light.enable", true);
|
||||||
|
|
||||||
String[] split = StringUtils.split(config.getString("mechanics.default-quality-ratio", "17/2/1"), "/");
|
String[] split = StringUtils.split(config.getString("mechanics.default-quality-ratio", "17/2/1"), "/");
|
||||||
double[] weight = new double[3];
|
double[] weight = new double[3];
|
||||||
assert split != null;
|
assert split != null;
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ public abstract class OraxenHandler extends HandlerP {
|
|||||||
if (waterEvent.isCancelled()) {
|
if (waterEvent.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
nbtItem.setInteger("WaterAmount", water - 1);
|
nbtItem.setInteger("WaterAmount", --water);
|
||||||
|
|
||||||
if (SoundConfig.waterPot.isEnable()) {
|
if (SoundConfig.waterPot.isEnable()) {
|
||||||
AdventureUtil.playerSound(
|
AdventureUtil.playerSound(
|
||||||
|
|||||||
@@ -85,21 +85,41 @@ public class CropManager extends Function {
|
|||||||
public void load() {
|
public void load() {
|
||||||
super.load();
|
super.load();
|
||||||
this.customWorlds = new ConcurrentHashMap<>();
|
this.customWorlds = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
this.itemSpawnListener = new ItemSpawnListener(this);
|
this.itemSpawnListener = new ItemSpawnListener(this);
|
||||||
this.worldListener = new WorldListener(this);
|
this.worldListener = new WorldListener(this);
|
||||||
this.armorStandUtil = new ArmorStandUtil(this);
|
this.armorStandUtil = new ArmorStandUtil(this);
|
||||||
|
|
||||||
|
loadMode();
|
||||||
|
loadSeason();
|
||||||
|
|
||||||
|
//load Worlds
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
onWorldLoad(world);
|
||||||
|
}
|
||||||
|
//new Time Check task
|
||||||
|
this.timerTask = new TimerTask(this);
|
||||||
|
this.timerTask.runTaskTimerAsynchronously(CustomCrops.plugin, 1,100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadMode() {
|
||||||
|
|
||||||
|
if (this.handler != null) {
|
||||||
|
handler.unload();
|
||||||
|
handler = null;
|
||||||
|
}
|
||||||
|
|
||||||
//Custom Plugin
|
//Custom Plugin
|
||||||
if (MainConfig.customPlugin.equals("itemsadder")) {
|
if (MainConfig.customPlugin.equals("itemsadder")) {
|
||||||
customInterface = new ItemsAdderHook();
|
customInterface = new ItemsAdderHook();
|
||||||
if (MainConfig.cropMode) {
|
if (MainConfig.cropMode) {
|
||||||
this.handler = new ItemsAdderWireHandler(this);
|
this.handler = new ItemsAdderWireHandler(this);
|
||||||
this.cropMode = new ItemsAdderWireCropImpl(this);
|
this.cropMode = new ItemsAdderWireCropImpl(this);
|
||||||
|
this.handler.load();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.handler = new ItemsAdderFrameHandler(this);
|
this.handler = new ItemsAdderFrameHandler(this);
|
||||||
this.cropMode = new ItemsAdderFrameCropImpl(this);
|
this.cropMode = new ItemsAdderFrameCropImpl(this);
|
||||||
|
this.handler.load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MainConfig.customPlugin.equals("oraxen")){
|
else if (MainConfig.customPlugin.equals("oraxen")){
|
||||||
@@ -107,29 +127,25 @@ public class CropManager extends Function {
|
|||||||
if (MainConfig.cropMode) {
|
if (MainConfig.cropMode) {
|
||||||
this.handler = new OraxenWireHandler(this);
|
this.handler = new OraxenWireHandler(this);
|
||||||
this.cropMode = new OraxenWireCropImpl(this);
|
this.cropMode = new OraxenWireCropImpl(this);
|
||||||
|
this.handler.load();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.handler = new OraxenFrameHandler(this);
|
this.handler = new OraxenFrameHandler(this);
|
||||||
this.cropMode = new OraxenFrameCropImpl(this);
|
this.cropMode = new OraxenFrameCropImpl(this);
|
||||||
|
this.handler.load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//new Time Check task
|
public void loadSeason() {
|
||||||
this.timerTask = new TimerTask(this);
|
|
||||||
this.timerTask.runTaskTimerAsynchronously(CustomCrops.plugin, 1,100);
|
|
||||||
|
|
||||||
handler.load();
|
|
||||||
|
|
||||||
if (SeasonConfig.enable) {
|
if (SeasonConfig.enable) {
|
||||||
if (MainConfig.realisticSeasonHook) seasonInterface = new RealisticSeasonsHook();
|
if (MainConfig.realisticSeasonHook) seasonInterface = new RealisticSeasonsHook();
|
||||||
else seasonInterface = new InternalSeason();
|
else seasonInterface = new InternalSeason();
|
||||||
}
|
|
||||||
|
|
||||||
seasonInterface.load();
|
seasonInterface.load();
|
||||||
|
}
|
||||||
//load Worlds
|
else if (this.seasonInterface != null) {
|
||||||
for (World world : Bukkit.getWorlds()) {
|
this.seasonInterface.unload();
|
||||||
onWorldLoad(world);
|
this.seasonInterface = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,9 +157,7 @@ public class CustomWorld {
|
|||||||
}
|
}
|
||||||
scarecrowCache.put(en.getKey(), simpleLocations);
|
scarecrowCache.put(en.getKey(), simpleLocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
SeasonUtils.setSeason(world, CCSeason.UNKNOWN);
|
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException e) {
|
catch (FileNotFoundException e) {
|
||||||
//bypass
|
//bypass
|
||||||
@@ -183,7 +181,6 @@ public class CustomWorld {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
SeasonUtils.unloadSeason(world);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadSeason() {
|
private void loadSeason() {
|
||||||
|
|||||||
@@ -62,6 +62,12 @@ public class ItemsAdderFrameCropImpl implements CropModeInterface {
|
|||||||
String cropKey = StringUtils.split(cropNameList[0], ":")[1];
|
String cropKey = StringUtils.split(cropNameList[0], ":")[1];
|
||||||
Crop crop = CropConfig.CROPS.get(cropKey);
|
Crop crop = CropConfig.CROPS.get(cropKey);
|
||||||
if (crop == null) return true;
|
if (crop == null) return true;
|
||||||
|
|
||||||
|
if (MainConfig.needSkyLight && location.getBlock().getLightFromSky() < MainConfig.skyLightLevel) {
|
||||||
|
itemFrame.setItem(customInterface.getItemStack(BasicItemConfig.deadCrop), false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (cropManager.isWrongSeason(location, crop.getSeasons())) {
|
if (cropManager.isWrongSeason(location, crop.getSeasons())) {
|
||||||
itemFrame.setItem(customInterface.getItemStack(BasicItemConfig.deadCrop), false);
|
itemFrame.setItem(customInterface.getItemStack(BasicItemConfig.deadCrop), false);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -50,6 +50,15 @@ public class ItemsAdderWireCropImpl implements CropModeInterface{
|
|||||||
String cropKey = StringUtils.split(cropNameList[0], ":")[1];
|
String cropKey = StringUtils.split(cropNameList[0], ":")[1];
|
||||||
Crop crop = CropConfig.CROPS.get(cropKey);
|
Crop crop = CropConfig.CROPS.get(cropKey);
|
||||||
if (crop == null) return true;
|
if (crop == null) return true;
|
||||||
|
|
||||||
|
if (MainConfig.needSkyLight && location.getBlock().getLightFromSky() < MainConfig.skyLightLevel) {
|
||||||
|
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
|
||||||
|
customInterface.removeBlock(location);
|
||||||
|
customInterface.placeWire(location, BasicItemConfig.deadCrop);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (cropManager.isWrongSeason(location, crop.getSeasons())) {
|
if (cropManager.isWrongSeason(location, crop.getSeasons())) {
|
||||||
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
|
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
|
||||||
customInterface.removeBlock(location);
|
customInterface.removeBlock(location);
|
||||||
|
|||||||
@@ -64,6 +64,13 @@ public class OraxenFrameCropImpl implements CropModeInterface {
|
|||||||
String cropKey = cropNameList[0];
|
String cropKey = cropNameList[0];
|
||||||
Crop crop = CropConfig.CROPS.get(cropKey);
|
Crop crop = CropConfig.CROPS.get(cropKey);
|
||||||
if (crop == null) return true;
|
if (crop == null) return true;
|
||||||
|
|
||||||
|
if (MainConfig.needSkyLight && location.getBlock().getLightFromSky() < MainConfig.skyLightLevel) {
|
||||||
|
itemFrame.setItem(customInterface.getItemStack(BasicItemConfig.deadCrop), false);
|
||||||
|
itemFrame.getPersistentDataContainer().set(OraxenHook.FURNITURE, PersistentDataType.STRING, BasicItemConfig.deadCrop);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (cropManager.isWrongSeason(location, crop.getSeasons())) {
|
if (cropManager.isWrongSeason(location, crop.getSeasons())) {
|
||||||
itemFrame.setItem(customInterface.getItemStack(BasicItemConfig.deadCrop), false);
|
itemFrame.setItem(customInterface.getItemStack(BasicItemConfig.deadCrop), false);
|
||||||
itemFrame.getPersistentDataContainer().set(OraxenHook.FURNITURE, PersistentDataType.STRING, BasicItemConfig.deadCrop);
|
itemFrame.getPersistentDataContainer().set(OraxenHook.FURNITURE, PersistentDataType.STRING, BasicItemConfig.deadCrop);
|
||||||
|
|||||||
@@ -50,9 +50,16 @@ public class OraxenWireCropImpl implements CropModeInterface{
|
|||||||
String cropKey = cropNameList[0];
|
String cropKey = cropNameList[0];
|
||||||
Crop crop = CropConfig.CROPS.get(cropKey);
|
Crop crop = CropConfig.CROPS.get(cropKey);
|
||||||
if (crop == null) return true;
|
if (crop == null) return true;
|
||||||
|
|
||||||
|
if (MainConfig.needSkyLight && location.getBlock().getLightFromSky() < MainConfig.skyLightLevel) {
|
||||||
|
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
|
||||||
|
customInterface.placeWire(location, BasicItemConfig.deadCrop);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (cropManager.isWrongSeason(location, crop.getSeasons())) {
|
if (cropManager.isWrongSeason(location, crop.getSeasons())) {
|
||||||
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
|
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> {
|
||||||
customInterface.removeBlock(location);
|
|
||||||
customInterface.placeWire(location, BasicItemConfig.deadCrop);
|
customInterface.placeWire(location, BasicItemConfig.deadCrop);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class CustomPapi implements RequirementInterface {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isConditionMet(PlantingCondition plantingCondition) {
|
public boolean isConditionMet(PlantingCondition plantingCondition) {
|
||||||
if (!papiRequirement.isMet(plantingCondition.getPapiMap())) {
|
if (!papiRequirement.isMet(plantingCondition.getPapiMap())) {
|
||||||
AdventureUtil.playerMessage(plantingCondition.getPlayer(), msg);
|
if (msg != null) AdventureUtil.playerMessage(plantingCondition.getPlayer(), msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
config-version: '10'
|
config-version: '10'
|
||||||
|
|
||||||
# lang: english / spanish / chinese
|
# lang: english / spanish / chinese
|
||||||
lang: chinese
|
lang: english
|
||||||
|
|
||||||
integration:
|
integration:
|
||||||
# AntiGrief
|
# AntiGrief
|
||||||
@@ -33,6 +33,7 @@ worlds:
|
|||||||
|
|
||||||
optimization:
|
optimization:
|
||||||
# Recommend enabling this to prevent large quantities of crops/itemframes lagging the server
|
# Recommend enabling this to prevent large quantities of crops/itemframes lagging the server
|
||||||
|
# When you are using both item_frame mode and ItemsAdder, you should set "max-furniture-vehicles-per-chunk" in ItemsAdder's config.yml to a higher value
|
||||||
limitation:
|
limitation:
|
||||||
enable: true
|
enable: true
|
||||||
# max amount per chunk
|
# max amount per chunk
|
||||||
@@ -47,7 +48,6 @@ optimization:
|
|||||||
auto-back-up: true
|
auto-back-up: true
|
||||||
|
|
||||||
mechanics:
|
mechanics:
|
||||||
# Requires a restart tp change mode
|
|
||||||
# Mode: tripwire/item_frame
|
# Mode: tripwire/item_frame
|
||||||
crops-mode: tripwire
|
crops-mode: tripwire
|
||||||
|
|
||||||
@@ -102,6 +102,7 @@ mechanics:
|
|||||||
world: world
|
world: world
|
||||||
|
|
||||||
auto-season-change:
|
auto-season-change:
|
||||||
|
# If enabled, setseason command would only work for only one day
|
||||||
enable: true
|
enable: true
|
||||||
#duration of each season
|
#duration of each season
|
||||||
duration: 28
|
duration: 28
|
||||||
@@ -114,8 +115,15 @@ mechanics:
|
|||||||
crow:
|
crow:
|
||||||
enable: true
|
enable: true
|
||||||
chance: 0.005
|
chance: 0.005
|
||||||
|
|
||||||
|
# 17/2/1 means 85%/10%/5%
|
||||||
|
# 2/2/1 means 40%/40%/20%
|
||||||
default-quality-ratio: 17/2/1
|
default-quality-ratio: 17/2/1
|
||||||
|
|
||||||
|
# A crop would go to dead stage if the sky-light level is lower than a value.
|
||||||
|
dead-if-no-sky-light:
|
||||||
|
enable: true
|
||||||
|
level: 10
|
||||||
|
|
||||||
|
|
||||||
sounds:
|
sounds:
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ tomato:
|
|||||||
chance: 0.01
|
chance: 0.01
|
||||||
|
|
||||||
harvest-actions:
|
harvest-actions:
|
||||||
|
# https://docs.adventure.kyori.net/minimessage/format.html
|
||||||
messages:
|
messages:
|
||||||
- 'Hello, {player}! <u><click:open_url:xxx.xxx>Click here to read the CustomCrops wiki'
|
- 'Hello, {player}! <u><click:open_url:https://www.yuque.com/docs/share/3e23f953-ccf0-4de5-bfe6-23868380c599>Click here to read the CustomCrops wiki'
|
||||||
- '<u>This plugin uses MiniMessage Format, check it here</u><click:open_url:https://docs.adventure.kyori.net/minimessage/format.html> <gold>[Click Me]'
|
|
||||||
commands:
|
commands:
|
||||||
- 'say {player} harvested a tomato! lol'
|
- 'say {player} harvested a tomato! lol'
|
||||||
xp: 10
|
xp: 10
|
||||||
|
|||||||
Reference in New Issue
Block a user