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