9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2026-01-04 15:41:46 +00:00
This commit is contained in:
Xiao-MoMi
2023-02-24 22:13:03 +08:00
parent 978433f9ec
commit 644b6f6a43
17 changed files with 123 additions and 86 deletions

View File

@@ -109,10 +109,10 @@ public class CropConfig {
List<ActionInterface> actions = new ArrayList<>();
for (String action : Objects.requireNonNull(config.getConfigurationSection(key + ".harvest-actions")).getKeys(false)) {
switch (action) {
case "xp" -> actions.add(new ActionXP(config.getInt(key + ".harvest-actions." + action)));
case "skill-xp" -> actions.add(new ActionSkillXP(config.getDouble(key + ".harvest-actions." + action)));
case "commands" -> actions.add(new ActionCommand(config.getStringList(key + ".harvest-actions." + action).toArray(new String[0])));
case "messages" -> actions.add(new ActionMessage(config.getStringList(key + ".harvest-actions." + action).toArray(new String[0])));
case "xp" -> actions.add(new ActionXP(config.getInt(key + ".harvest-actions." + action), config.getDouble(key + ".harvest-actions." + action + "-chance", 1)));
case "skill-xp" -> actions.add(new ActionSkillXP(config.getDouble(key + ".harvest-actions." + action), config.getDouble(key + ".harvest-actions." + action + "-chance", 1)));
case "commands" -> actions.add(new ActionCommand(config.getStringList(key + ".harvest-actions." + action).toArray(new String[0]), config.getDouble(key + ".harvest-actions." + action + "-chance", 1)));
case "messages" -> actions.add(new ActionMessage(config.getStringList(key + ".harvest-actions." + action).toArray(new String[0]), config.getDouble(key + ".harvest-actions." + action + "-chance", 1)));
}
}
crop.setActions(actions.toArray(new ActionInterface[0]));

View File

@@ -355,7 +355,9 @@ public class CropManager extends Function {
public void performActions(ActionInterface[] actions, Player player) {
for (ActionInterface action : actions) {
action.performOn(player);
if (Math.random() <= action.getChance()) {
action.performOn(player);
}
}
}

View File

@@ -23,9 +23,11 @@ import org.bukkit.entity.Player;
public class ActionCommand implements ActionInterface {
private final String[] commands;
private final double chance;
public ActionCommand(String[] commands) {
public ActionCommand(String[] commands, double chance) {
this.commands = commands;
this.chance = chance;
}
@Override
@@ -34,4 +36,9 @@ public class ActionCommand implements ActionInterface {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command.replace("{player}", player.getName()));
}
}
@Override
public double getChance() {
return chance;
}
}

View File

@@ -21,4 +21,6 @@ import org.bukkit.entity.Player;
public interface ActionInterface {
void performOn(Player player);
double getChance();
}

View File

@@ -23,9 +23,11 @@ import org.bukkit.entity.Player;
public class ActionMessage implements ActionInterface{
private final String[] messages;
private final double chance;
public ActionMessage(String[] messages) {
public ActionMessage(String[] messages, double chance) {
this.messages = messages;
this.chance = chance;
}
@Override
@@ -34,4 +36,9 @@ public class ActionMessage implements ActionInterface{
AdventureUtil.playerMessage(player, message.replace("{player}", player.getName()));
}
}
@Override
public double getChance() {
return chance;
}
}

View File

@@ -23,9 +23,11 @@ import org.bukkit.entity.Player;
public class ActionSkillXP implements ActionInterface {
private final double xp;
private final double chance;
public ActionSkillXP(double xp) {
public ActionSkillXP(double xp, double chance) {
this.xp = xp;
this.chance = chance;
}
@Override
@@ -34,4 +36,9 @@ public class ActionSkillXP implements ActionInterface {
MainConfig.skillXP.addXp(player, xp);
}
}
@Override
public double getChance() {
return chance;
}
}

View File

@@ -22,13 +22,20 @@ import org.bukkit.entity.Player;
public class ActionXP implements ActionInterface {
private final int amount;
private final double chance;
public ActionXP(int amount) {
public ActionXP(int amount, double chance) {
this.amount = amount;
this.chance = chance;
}
@Override
public void performOn(Player player) {
player.giveExp(amount);
}
@Override
public double getChance() {
return chance;
}
}

View File

@@ -7,7 +7,6 @@ lang: english
integration:
# AntiGrief
# 防熊
Residence: false
WorldGuard: false
Kingdoms: false
@@ -21,23 +20,23 @@ integration:
IridiumSkyblock: false
SuperiorSkyBlock: false
# Skill Xp
# 技能经验
# Don't forget to config skill-xp for each crop if you enabled skill xp integration
AureliumSkills: false
mcMMO: false
MMOCore: false
EcoSkills: false
JobsReborn: false
# Season
# 季节
# Synchronize season with other plugins
RealisticSeasons: false
worlds:
# This is designed for servers that using a separate folder for worlds
# The default folder is your server's root folder
# 如果你的服务器使用独立文件夹存储世界,请在此填入根目录下的文件地址
worlds-folder: ''
# Mode: whitelist/blacklist
# Requires a restart when changing mode or world list
# Because reloading world data might cause unexpected problems and lag
# Requires a restart when changing mode or editing world list for the safety of data
# 模式:白名单/黑名单
# 为了避免重载时候造成服务器卡顿,修改本栏需要重启服务器
mode: whitelist
@@ -45,7 +44,7 @@ worlds:
- world
optimization:
# Recommend enabling this to prevent large quantities of crops/itemframes lagging the server
# Recommend enabling this to prevent large quantities of crops/item frames from 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
# 推荐启用区块限制来防止玩家种植大量农作物
# 如果你使用ItemsAdder的展示框模式你需要在ItemsAdder的配置文件中设置"max-furniture-vehicles-per-chunk"到较高值,否则农作物种植后会消失
@@ -69,13 +68,13 @@ mechanics:
crops-mode: tripwire
# If enabled, crops would start growing at about 7am(at most 5 seconds inaccuracy) and finish growing in the rest of the day
# Note: All the crops can only start growing when a world's time is about 7am, so when a world is loaded and its time is 8am,
# crops would not grow in this day. You can enable time compensation make the crops grow when starting the server.
# Note: All the crops can only start growing when a world's time is around 7am, so when a world is loaded and its time is 8am,
# crops would not grow in this day. You can enable time compensation to make the crops grow when starting the server.
# 如果启用自动生长农作物将在上午7点左右完成当日生长任务安排并且在接下来的时间里完成生长
# 请注意:农作物只有在生长点前种植才能在当日生长,否则需要等待下一个生长点,你可以开启下方的生长补偿功能
auto-grow:
enable: true
# For example, the time to start growing is 1000ticks(7am),
# For example, the time to start growing is at 1000ticks(7am),
# sprinklers would finish their work in a random time between 1000~1300ticks,
# Pot would start drying in a random time between 1300~1500ticks
# and crops would grow in a random time between 1500~21500ticks
@@ -89,8 +88,8 @@ mechanics:
# If the pot is wet, crop would 100% grow a stage per day
# Otherwise they would have a lower chance to grow.
# Recommend setting it to a value higher than 0 to make sure every crop can be ripe even if
# players don't take care of them, this is good for server performance because crop data would
# be removed from data file when the crop is ripe to avoid affecting server performance in the long term
# players don't take care of them, this is good for server's performance because crop data would
# be removed from data file as soon as the crop is ripe to avoid affecting server performance in the long term
# 如果种植盆是干燥的,每天生长一个阶段的概率是多少
# 建议设置高于0的数值这样每个农作物都能得到生长最后从数据中移除
# 长远来看,这样不会造成数据堆积,对服务器性能友好
@@ -149,14 +148,14 @@ mechanics:
# If enabled, season would be automatically calculated according to game time when reloading
# 自动切换季节如果启用则setseason指令仅对当天有效
enable: true
# duration of each season
# duration of each season (Minecraft days)
# 每个季节的时长
duration: 28
greenhouse:
enable: true
# effective range
# effective range (Y axis)
range: 5
# During the crop grow progress, crops have little chance to be eaten by a crow
# During the crop growing progress, crops have a little chance to be eaten by a crow
# Place a scarecrow would protect the crops in this chunk
# 在生长过程中,农作物有小概率被乌鸦袭击,在当前区块放置稻草人可以驱赶乌鸦
crow:
@@ -167,7 +166,7 @@ mechanics:
# 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.
# A crop would go to dead stage if the sky-light level is lower than a certain value.
# 在自然光照不足时,农作物是否会死亡
dead-if-no-sky-light:
enable: true
@@ -177,7 +176,7 @@ mechanics:
# Can vanilla crops be harvested with right clicks
# 是否可以右键重复收获原版农作物
right-click-harvest: false
# Totally prevent player from planting these vanilla crops in farmland
# Prevent player from planting these vanilla crops in farmland
# 阻止玩家种植原版农作物
prevent-plant:
enable: false
@@ -187,7 +186,7 @@ mechanics:
- POTATOES
- BEETROOTS
# Convert vanilla items into CustomCrops crops
# You need to make extra CustomCrops/IA/Oraxen configs/models for these crops
# You need to make extra CustomCrops/IA/Oraxen configs & models for these crops
# This makes it possible to make vanilla crops have a better mechanic
# 将原版物品转换为customcrops插件农作物
# 你需要为此制作额外的模型和配置
@@ -275,7 +274,6 @@ actionbar:
right: '뀁뀅</font>'
season-broadcast:
enable: true
spring:
@@ -304,7 +302,7 @@ watering-can-lore:
# Wouldn't work in creative mode for safety
# 是否启用发包模式
# 安全起见,创造模式下这不会生效
enable: true
enable: false
# true: top / false: bottom
# 发包描述位于描述的顶部还是底部
top-or-bottom: true
@@ -320,6 +318,7 @@ watering-can-lore:
empty: '뀁뀄'
right: '뀁뀅</font>'
other-settings:
# 3 days = 1 hour
# Save the cache to file

View File

@@ -1,14 +1,15 @@
# Crop's namespace in ItemsAdder
namespace: customcrops
# Crop Name
# Your seeds should end with "_seeds" and stage model should end with "_stage_x"
# Crop's key name
tomato:
# Crop's max stage
max-stage: 4
quality-loots:
amount: 1~4
quality:
# Other plugin item compatibility(Can also be used in other-loots)
# MMOItems:TYPE:ID
# MythicMobs:id
1: customcrops:tomato
@@ -33,29 +34,33 @@ tomato:
chance: 0.01
harvest-actions:
# https://docs.adventure.kyori.net/minimessage/format.html
# Text format: https://docs.adventure.kyori.net/minimessage/format.html
messages:
- 'Hello, {player}! <u><click:open_url:https://www.yuque.com/docs/share/3e23f953-ccf0-4de5-bfe6-23868380c599>Click here to read the CustomCrops wiki'
# The chance of triggering this type of action, if not set, the action would be definitely triggered (commands-chance, xp-chance...)
messages-chance: 0.5
commands:
- 'say {player} harvested a tomato! lol'
xp: 10
#skill-xp: 100
# skill-xp: 100 (You need to enable any skill plugin compatibility in config.yml)
# When you harvest with a single right click, the crop would return to a certain stage
# When you harvest with a single right click, the crop would return to a certain stage. If not set, crops would be removed when harvesting
return: customcrops:tomato_stage_1
# Suitable seasons for growing
season:
- Spring
plant-requirements:
condition_1:
# Condition System:
# Read the wiki for more condition types
type: permission
# Mode: && / ||
mode: '&&'
value:
- crops.plant.tomato
# The message to be shown when player doesn't fit the requirement
# The message to be shown when not meeting the requirements
message: 'You don''t have permission to plant this seed!'
harvest-requirements:
condition_1:

View File

@@ -1,12 +1,12 @@
# Crop Name
# Your seeds should end with "_seeds" and stage model should end with "_stage_x"
# Crop's key name
tomato:
# Crop's max stage
max-stage: 4
quality-loots:
amount: 1~4
quality:
# Other plugin item compatibility(Can also be used in other-loots)
# MMOItems:TYPE:ID
# MythicMobs:id
1: tomato
@@ -31,29 +31,33 @@ tomato:
chance: 0.01
harvest-actions:
# https://docs.adventure.kyori.net/minimessage/format.html
# Text format: https://docs.adventure.kyori.net/minimessage/format.html
messages:
- 'Hello, {player}! <u><click:open_url:https://www.yuque.com/docs/share/3e23f953-ccf0-4de5-bfe6-23868380c599>Click here to read the CustomCrops wiki'
# The chance of triggering this type of action, if not set, the action would be definitely triggered (commands-chance, xp-chance...)
messages-chance: 0.5
commands:
- 'say {player} harvested a tomato! lol'
xp: 10
#skill-xp: 100
# skill-xp: 100 (You need to enable any skill plugin compatibility in config.yml)
# When you harvest with a single right click, the crop would return to a certain stage
# When you harvest with a single right click, the crop would return to a certain stage. If not set, crops would be removed when harvesting
return: tomato_stage_1
# Suitable seasons for growing
season:
- Spring
plant-requirements:
condition_1:
# Condition System:
# Read the wiki for more condition types
type: permission
# Mode: && / ||
mode: '&&'
value:
- crops.plant.tomato
# The message to be shown when player doesn't fit the requirement
# The message to be shown when not meeting the requirements
message: 'You don''t have permission to plant this seed!'
harvest-requirements:
condition_1:

View File

@@ -1,18 +1,18 @@
#Crops have a small chance to grow two stages at a time
#C rops have a small chance to grow two stages at a time
speed:
speed_1:
#Fertilizer Hologram display name
# Fertilizer Hologram display name
name: '뀌'
#The chance of this fertilizer taking effect
# The chance of this fertilizer taking effect
chance: 0.1
#How many days can this fertilizer stay in pot
# How many days can this fertilizer stay in pot
times: 14
#ItemsAdder item namespacedID
# ItemsAdder item namespacedID
item: customcrops:speed_1
#Should this fertilizer be used before planting
# Should this fertilizer be used before planting
before-plant: true
#The particle to be displayed when using fertilizer
#https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html
# The particle to be displayed when using fertilizer
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html
particle: SPELL_WITCH
speed_2:
name: '뀍'
@@ -30,7 +30,7 @@ speed:
particle: SPELL_WITCH
#Pot have a small chance to retain its water after crops grow
# Pot have a small chance to retain its water after crops grow
retaining:
retaining_1:
name: '뀉'
@@ -55,7 +55,7 @@ retaining:
particle: SPELL
#When haveresting, players have a higher chance to get high quality crops.
# When haveresting, players have a higher chance to get high quality crops.
quality:
quality_1:
name: '뀆'
@@ -83,7 +83,7 @@ quality:
particle: SCRAPE
#When haveresting, players have a higher chance to get more crops.
# When haveresting, players have a higher chance to get more crops.
quantity:
quantity_1:
name: '뀏'
@@ -111,7 +111,7 @@ quantity:
particle: TOTEM
#Crops have a higher chance to be gigantic
# Crops have a higher chance to be gigantic
gigantic:
gigantic_1:
name: '뀒'

View File

@@ -1,18 +1,18 @@
#Crops have a small chance to grow two stages at a time
# Crops have a small chance to grow two stages at a time
speed:
speed_1:
#Fertilizer Hologram display name
# Fertilizer Hologram display name
name: '뀌'
#The chance of this fertilizer taking effect
# The chance of this fertilizer taking effect
chance: 0.1
#How many days can this fertilizer stay in pot
# How many days can this fertilizer stay in pot
times: 14
#Oraxen Item id
# Oraxen Item id
item: speed_1
#Should this fertilizer be used before planting
# Should this fertilizer be used before planting
before-plant: true
#The particle to be displayed when using fertilizer
#https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html
# The particle to be displayed when using fertilizer
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html
particle: SPELL_WITCH
speed_2:
name: '뀍'
@@ -30,7 +30,7 @@ speed:
particle: SPELL_WITCH
#Pot have a small chance to retain its water after crops grow
# Pot have a small chance to retain its water after crops grow
retaining:
retaining_1:
name: '뀉'
@@ -55,7 +55,7 @@ retaining:
particle: SPELL
#When haveresting, players have a higher chance to get high quality crops.
# When haveresting, players have a higher chance to get high quality crops.
quality:
quality_1:
name: '뀆'
@@ -83,7 +83,7 @@ quality:
particle: SCRAPE
#When haveresting, players have a higher chance to get more crops.
# When haveresting, players have a higher chance to get more crops.
quantity:
quantity_1:
name: '뀏'
@@ -111,7 +111,7 @@ quantity:
particle: TOTEM
#Crops have a higher chance to be gigantic
# Crops have a higher chance to be gigantic
gigantic:
gigantic_1:
name: '뀒'

View File

@@ -1,5 +1,5 @@
#MiniMessage Format
#https://docs.adventure.kyori.net/minimessage/format.html
# Text Format
# https://docs.adventure.kyori.net/minimessage/format.html
messages:
prefix: '<gradient:#ff206c:#fdee55>[CustomCrops] </gradient>'
reload: '<white>重载成功! 耗时 <green>{time}ms'
@@ -19,7 +19,6 @@ messages:
set-season: '<white>成功切换世界 {world} 的季节为 {season}!'
before-plant: '<white>这种肥料必须在种植前使用!'
wrong-season: '<white>当前季节不适合这个农作物生长. 当前季节{season}'
no-season: '此世界没有季节'
season-disabled: '季节系统已被禁用'
auto-season-disabled: '自动季节切换已被禁用,无法计算此变量'

View File

@@ -1,5 +1,5 @@
#MiniMessage Format
#https://docs.adventure.kyori.net/minimessage/format.html
# Text Format
# https://docs.adventure.kyori.net/minimessage/format.html
messages:
prefix: '<gradient:#ff206c:#fdee55>[CustomCrops] </gradient>'
reload: '<white>Reloaded! Took <green>{time}ms'
@@ -18,7 +18,6 @@ messages:
set-season: '<white>Successfully set {world}''s season to {season}!'
before-plant: '<white>This fertilizer must be used before planting!'
wrong-season: '<white>Current season is not suitable for planting this seed. Current season: {season} Suitable seasons: {suitable}'
no-season: 'No season'
season-disabled: 'Season is disabled'
auto-season-disabled: 'Failed to count'

View File

@@ -1,5 +1,5 @@
#MiniMessage Format
#https://docs.adventure.kyori.net/minimessage/format.html
# Text Format
# https://docs.adventure.kyori.net/minimessage/format.html
messages:
prefix: '<gradient:#ff206c:#fdee55>[CustomCrops] </gradient>'
reload: '<white>¡Recargado! Tomó <green>{time}ms'
@@ -18,7 +18,6 @@ messages:
set-season: '<white>Fijado con éxito {world}''s temporada a {season}!'
before-plant: '<white>Este abono debe utilizarse antes de la siembra'
wrong-season: '<white>La temporada actual no es adecuada para plantar esta semilla'
no-season: 'Sin temporada'
season-disabled: 'La temporada está desactivada'
auto-season-disabled: 'No se ha podido contar'

View File

@@ -9,6 +9,14 @@ softdepend:
- ItemsAdder
- Oraxen
- PlaceholderAPI
- mcMMO
- AureliumSkills
- MMOCore
- EcoSkills
- RealisticSeasons
- Jobs
- IridiumSkyblock
- SuperiorSkyBlock2
- Residence
- Kingdoms
- WorldGuard
@@ -17,15 +25,7 @@ softdepend:
- Towny
- Lands
- GriefPrevention
- mcMMO
- AureliumSkills
- MMOCore
- EcoSkills
- CrashClaim
- RealisticSeasons
- Jobs
- IridiumSkyblock
- SuperiorSkyBlock2
commands:
customcrops:
usage: /customcrops <args>