From 19a0080aae14c2db28f801b5e9e81ba12045a72a Mon Sep 17 00:00:00 2001 From: XiaoMoMi <972454774@qq.com> Date: Sat, 9 Mar 2024 08:23:54 +0800 Subject: [PATCH] add languages and farmland support --- .../customcrops/api/mechanic/item/Pot.java | 2 ++ .../manager/PlaceholderManagerImpl.java | 17 +++++++++++++++++ .../mechanic/item/ItemManagerImpl.java | 10 ++++++++++ .../mechanic/item/function/FunctionTrigger.java | 17 +++++++++++++++++ .../mechanic/item/impl/PotConfig.java | 8 ++++++++ .../world/adaptor/SlimeWorldAdaptor.java | 5 ++++- plugin/src/main/resources/config.yml | 3 +-- plugin/src/main/resources/messages/chinese.yml | 8 ++++++++ plugin/src/main/resources/messages/french.yml | 8 ++++++++ plugin/src/main/resources/messages/russian.yml | 8 ++++++++ plugin/src/main/resources/messages/spanish.yml | 8 ++++++++ plugin/src/main/resources/plugin.yml | 3 ++- 12 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 plugin/src/main/resources/messages/chinese.yml create mode 100644 plugin/src/main/resources/messages/french.yml create mode 100644 plugin/src/main/resources/messages/russian.yml create mode 100644 plugin/src/main/resources/messages/spanish.yml diff --git a/api/src/main/java/net/momirealms/customcrops/api/mechanic/item/Pot.java b/api/src/main/java/net/momirealms/customcrops/api/mechanic/item/Pot.java index 3a865ed..f4f4007 100644 --- a/api/src/main/java/net/momirealms/customcrops/api/mechanic/item/Pot.java +++ b/api/src/main/java/net/momirealms/customcrops/api/mechanic/item/Pot.java @@ -54,4 +54,6 @@ public interface Pot extends KeyItem { boolean isNearbyWaterAccepted(); String getBlockState(boolean water, FertilizerType type); + + boolean isVanillaBlock(); } diff --git a/plugin/src/main/java/net/momirealms/customcrops/manager/PlaceholderManagerImpl.java b/plugin/src/main/java/net/momirealms/customcrops/manager/PlaceholderManagerImpl.java index 9a586c4..13da54c 100644 --- a/plugin/src/main/java/net/momirealms/customcrops/manager/PlaceholderManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customcrops/manager/PlaceholderManagerImpl.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customcrops.manager; import net.momirealms.customcrops.api.CustomCropsPlugin; diff --git a/plugin/src/main/java/net/momirealms/customcrops/mechanic/item/ItemManagerImpl.java b/plugin/src/main/java/net/momirealms/customcrops/mechanic/item/ItemManagerImpl.java index 7a69086..c1340d4 100644 --- a/plugin/src/main/java/net/momirealms/customcrops/mechanic/item/ItemManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customcrops/mechanic/item/ItemManagerImpl.java @@ -59,7 +59,9 @@ import net.momirealms.customcrops.utils.ItemUtils; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Waterlogged; +import org.bukkit.block.data.type.Farmland; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Entity; @@ -2268,6 +2270,14 @@ public class ItemManagerImpl implements ItemManager { @Override public void updatePotState(Location location, Pot pot, boolean hasWater, Fertilizer fertilizer) { + if (pot.isVanillaBlock()) { + Block block = location.getBlock(); + if (block.getBlockData() instanceof Farmland farmland) { + farmland.setMoisture(hasWater ? 7 : 0); + block.setBlockData(farmland); + return; + } + } this.customProvider.placeBlock( location, pot.getBlockState( diff --git a/plugin/src/main/java/net/momirealms/customcrops/mechanic/item/function/FunctionTrigger.java b/plugin/src/main/java/net/momirealms/customcrops/mechanic/item/function/FunctionTrigger.java index 540015d..909b7d9 100644 --- a/plugin/src/main/java/net/momirealms/customcrops/mechanic/item/function/FunctionTrigger.java +++ b/plugin/src/main/java/net/momirealms/customcrops/mechanic/item/function/FunctionTrigger.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customcrops.mechanic.item.function; public enum FunctionTrigger { diff --git a/plugin/src/main/java/net/momirealms/customcrops/mechanic/item/impl/PotConfig.java b/plugin/src/main/java/net/momirealms/customcrops/mechanic/item/impl/PotConfig.java index 5e5fc99..a2c4cff 100644 --- a/plugin/src/main/java/net/momirealms/customcrops/mechanic/item/impl/PotConfig.java +++ b/plugin/src/main/java/net/momirealms/customcrops/mechanic/item/impl/PotConfig.java @@ -26,6 +26,7 @@ import net.momirealms.customcrops.api.mechanic.item.water.PassiveFillMethod; import net.momirealms.customcrops.api.mechanic.misc.image.WaterBar; import net.momirealms.customcrops.api.mechanic.requirement.Requirement; import net.momirealms.customcrops.mechanic.item.AbstractEventItem; +import net.momirealms.customcrops.utils.ConfigUtils; import java.util.HashMap; import java.util.HashSet; @@ -45,6 +46,7 @@ public class PotConfig extends AbstractEventItem implements Pot { private final Requirement[] useRequirements; private final boolean acceptRainDrop; private final boolean acceptNearbyWater; + private boolean isVanillaBlock; public PotConfig( String key, @@ -76,6 +78,7 @@ public class PotConfig extends AbstractEventItem implements Pot { this.placeRequirements = placeRequirements; this.breakRequirements = breakRequirements; this.useRequirements = useRequirements; + this.isVanillaBlock = ConfigUtils.isVanillaItem(dryModel) && ConfigUtils.isVanillaItem(wetModel); } @Override @@ -153,4 +156,9 @@ public class PotConfig extends AbstractEventItem implements Pot { return water ? wetModel : dryModel; } } + + @Override + public boolean isVanillaBlock() { + return isVanillaBlock; + } } diff --git a/plugin/src/main/java/net/momirealms/customcrops/mechanic/world/adaptor/SlimeWorldAdaptor.java b/plugin/src/main/java/net/momirealms/customcrops/mechanic/world/adaptor/SlimeWorldAdaptor.java index c1bf008..9d8d48a 100644 --- a/plugin/src/main/java/net/momirealms/customcrops/mechanic/world/adaptor/SlimeWorldAdaptor.java +++ b/plugin/src/main/java/net/momirealms/customcrops/mechanic/world/adaptor/SlimeWorldAdaptor.java @@ -39,11 +39,14 @@ public class SlimeWorldAdaptor extends AbstractWorldAdaptor { @EventHandler (ignoreCancelled = true) public void onSlimeWorldLoad(LoadSlimeWorldEvent event) { + } @EventHandler(ignoreCancelled = true) public void onWorldLoad(WorldLoadEvent event) { - + if (worldManager.isMechanicEnabled(event.getWorld())) { + worldManager.loadWorld(event.getWorld()); + } } @EventHandler (ignoreCancelled = true) diff --git a/plugin/src/main/resources/config.yml b/plugin/src/main/resources/config.yml index 650a68d..85f85ba 100644 --- a/plugin/src/main/resources/config.yml +++ b/plugin/src/main/resources/config.yml @@ -25,8 +25,6 @@ worlds: mode: blacklist list: - blacklist_world - - world_nether - - world_the_end settings: _DEFAULT_: # Whether to enable the plugin's pre-made system @@ -86,6 +84,7 @@ worlds: # as it may cause chunks that have been unloaded for a long time # to consume too much server performance during loading max-offline-seconds: 1200 + # You can override the default settings for worlds here _WORLDS_: world_nether: enable: false diff --git a/plugin/src/main/resources/messages/chinese.yml b/plugin/src/main/resources/messages/chinese.yml new file mode 100644 index 0000000..3fef4d4 --- /dev/null +++ b/plugin/src/main/resources/messages/chinese.yml @@ -0,0 +1,8 @@ +messages: + prefix: '[CustomCrops] ' + reload: '重载完成! 耗时 {time}ms.' + spring: '春季' + summer: '夏季' + autumn: '秋季' + winter: '冬季' + no-season: '未启用季节' \ No newline at end of file diff --git a/plugin/src/main/resources/messages/french.yml b/plugin/src/main/resources/messages/french.yml new file mode 100644 index 0000000..e7dc40c --- /dev/null +++ b/plugin/src/main/resources/messages/french.yml @@ -0,0 +1,8 @@ +messages: + prefix: '[CustomCrops] ' + reload: 'Rechargé ! A pris {time}ms.' + spring: 'Printemps' + summer: 'Été' + autumn: 'Automne' + winter: 'Hiver' + no-season: 'SAISON DÉSACTIVÉE DANS CE MONDE' \ No newline at end of file diff --git a/plugin/src/main/resources/messages/russian.yml b/plugin/src/main/resources/messages/russian.yml new file mode 100644 index 0000000..c15e60c --- /dev/null +++ b/plugin/src/main/resources/messages/russian.yml @@ -0,0 +1,8 @@ +messages: + prefix: '[CustomCrops] ' + reload: 'Перезагружено! Заняло {time}мс.' + spring: 'Весна' + summer: 'Лето' + autumn: 'Осень' + winter: 'Зима' + no-season: 'СЕЗОНЫ ОТКЛЮЧЕНЫ В ЭТОМ МИРЕ' \ No newline at end of file diff --git a/plugin/src/main/resources/messages/spanish.yml b/plugin/src/main/resources/messages/spanish.yml new file mode 100644 index 0000000..d91d0c9 --- /dev/null +++ b/plugin/src/main/resources/messages/spanish.yml @@ -0,0 +1,8 @@ +messages: + prefix: '[CustomCrops] ' + reload: '¡Recargado! Tomó {time}ms.' + spring: 'Primavera' + summer: 'Verano' + autumn: 'Otoño' + winter: 'Invierno' + no-season: 'LAS TEMPORADAS ESTAN DESACTIVADAS EN ESTE MUNDO' \ No newline at end of file diff --git a/plugin/src/main/resources/plugin.yml b/plugin/src/main/resources/plugin.yml index a3c51a8..66fbf56 100644 --- a/plugin/src/main/resources/plugin.yml +++ b/plugin/src/main/resources/plugin.yml @@ -22,4 +22,5 @@ softdepend: - EcoSkills - Jobs - RealisticSeasons - - AdvancedSeasons \ No newline at end of file + - AdvancedSeasons + - SlimeWorldManager \ No newline at end of file