mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-27 10:59:20 +00:00
2.1.0
This commit is contained in:
@@ -92,9 +92,6 @@ public final class CustomCrops extends JavaPlugin {
|
||||
|
||||
ConfigUtil.reloadConfigs();
|
||||
|
||||
if (MainConfig.cropMode) AdventureUtil.consoleMessage("[CustomCrops] Crop Mode: Tripwire");
|
||||
else AdventureUtil.consoleMessage("[CustomCrops] Crop Mode: ItemFrame");
|
||||
|
||||
PluginCommand pluginCommand = new PluginCommand();
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("customcrops")).setExecutor(pluginCommand);
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("customcrops")).setTabCompleter(pluginCommand);
|
||||
|
||||
@@ -60,7 +60,7 @@ public class SetSeasonCommand extends AbstractSubCommand {
|
||||
ccSeason = CCSeason.valueOf(args.get(1).toUpperCase());
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
AdventureUtil.sendMessage(sender, MessageConfig.prefix + MessageConfig.seasonNotExists);
|
||||
AdventureUtil.sendMessage(sender, MessageConfig.prefix + MessageConfig.seasonNotExists.replace("{season}", args.get(1)));
|
||||
return true;
|
||||
}
|
||||
SeasonUtils.setSeason(world, ccSeason);
|
||||
|
||||
@@ -80,6 +80,7 @@ public class CropConfig {
|
||||
|
||||
for (String key : config.getKeys(false)) {
|
||||
if (key.equals("namespace")) continue;
|
||||
|
||||
int max_stage;
|
||||
if (config.contains(key + ".max-stage")) {
|
||||
max_stage = config.getInt(key + ".max-stage");
|
||||
@@ -91,115 +92,116 @@ public class CropConfig {
|
||||
}
|
||||
|
||||
CCCrop crop = new CCCrop(key, max_stage);
|
||||
for (String option : config.getConfigurationSection(key).getKeys(false)) {
|
||||
if (option.equals("quality-loots")) {
|
||||
String amount = config.getString(key + ".quality-loots.amount", "1~2");
|
||||
QualityLoot qualityLoot = new QualityLoot(
|
||||
Integer.parseInt(amount.split("~")[0]),
|
||||
Integer.parseInt(amount.split("~")[1]),
|
||||
config.getString(key + ".quality-loots.quality.1"),
|
||||
config.getString(key + ".quality-loots.quality.2"),
|
||||
config.getString(key + ".quality-loots.quality.3")
|
||||
);
|
||||
crop.setQualityLoot(qualityLoot);
|
||||
}
|
||||
if (option.equals("other-loots")) {
|
||||
List<OtherLoot> otherLoots = new ArrayList<>();
|
||||
for (String loot : Objects.requireNonNull(config.getConfigurationSection(key + ".other-loots")).getKeys(false)) {
|
||||
OtherLoot otherLoot = new OtherLoot(
|
||||
config.getInt(key + ".other-loots." + loot + ".min_amount", 1),
|
||||
config.getInt(key + ".other-loots." + loot + ".max_amount", 1),
|
||||
config.getString(key + ".other-loots." + loot + ".item"),
|
||||
config.getDouble(key + ".other-loots." + loot + ".chance", 1d)
|
||||
for (String option : Objects.requireNonNull(config.getConfigurationSection(key)).getKeys(false)) {
|
||||
switch (option) {
|
||||
case "quality-loots" -> {
|
||||
String amount = config.getString(key + ".quality-loots.amount", "1~2");
|
||||
QualityLoot qualityLoot = new QualityLoot(
|
||||
Integer.parseInt(amount.split("~")[0]),
|
||||
Integer.parseInt(amount.split("~")[1]),
|
||||
config.getString(key + ".quality-loots.quality.1"),
|
||||
config.getString(key + ".quality-loots.quality.2"),
|
||||
config.getString(key + ".quality-loots.quality.3")
|
||||
);
|
||||
otherLoots.add(otherLoot);
|
||||
crop.setQualityLoot(qualityLoot);
|
||||
}
|
||||
crop.setOtherLoots(otherLoots.toArray(new OtherLoot[0]));
|
||||
}
|
||||
if (option.equals("harvest-actions")) {
|
||||
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 "harvest-actions" -> {
|
||||
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])));
|
||||
}
|
||||
}
|
||||
crop.setActions(actions.toArray(new ActionInterface[0]));
|
||||
}
|
||||
crop.setActions(actions.toArray(new ActionInterface[0]));
|
||||
}
|
||||
if (option.equals("season")) {
|
||||
List<String> seasonList = config.getStringList(key + ".season");
|
||||
CCSeason[] seasons = new CCSeason[seasonList.size()];
|
||||
for (int i = 0; i < seasonList.size(); i++) {
|
||||
seasons[i] = CCSeason.valueOf(seasonList.get(i).toUpperCase());
|
||||
}
|
||||
crop.setSeasons(seasons);
|
||||
}
|
||||
if (option.equals("gigantic-crop")) {
|
||||
boolean isBlock = true;
|
||||
String blockID = config.getString(key + ".gigantic-crop.block");
|
||||
if (blockID == null) {
|
||||
blockID = config.getString(key + ".gigantic-crop.furniture");
|
||||
isBlock = false;
|
||||
}
|
||||
GiganticCrop giganticCrop = new GiganticCrop(
|
||||
config.getDouble(key + ".gigantic-crop.chance"),
|
||||
isBlock,
|
||||
blockID
|
||||
);
|
||||
crop.setGiganticCrop(giganticCrop);
|
||||
}
|
||||
if (option.equals("return")) {
|
||||
crop.setReturnStage(config.getString(key + ".return"));
|
||||
}
|
||||
crop.setCanRotate(config.getBoolean(key + ".rotation", true));
|
||||
if (option.equals("requirements")) {
|
||||
List<RequirementInterface> requirementList = new ArrayList<>();
|
||||
for (String requirement : Objects.requireNonNull(config.getConfigurationSection(key + ".requirements")).getKeys(false)) {
|
||||
String type = config.getString(key + ".requirements." + requirement + ".type");
|
||||
if (type == null) continue;
|
||||
switch (type) {
|
||||
case "time" -> requirementList.add(new RequirementTime(
|
||||
config.getStringList(key + ".requirements." + requirement + ".value").toArray(new String[0]),
|
||||
Objects.equals(config.getString(key + ".requirements." + requirement + ".mode"), "&&"),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "weather" -> requirementList.add(new RequirementWeather(
|
||||
config.getStringList(key + ".requirements." + requirement + ".value").toArray(new String[0]),
|
||||
Objects.equals(config.getString(key + ".requirements." + requirement + ".mode"), "&&"),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "yPos" -> requirementList.add(new RequirementYPos(
|
||||
config.getStringList(key + ".requirements." + requirement + ".value").toArray(new String[0]),
|
||||
Objects.equals(config.getString(key + ".requirements." + requirement + ".mode"), "&&"),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "biome" -> requirementList.add(new RequirementBiome(
|
||||
config.getStringList(key + ".requirements." + requirement + ".value").toArray(new String[0]),
|
||||
Objects.equals(config.getString(key + ".requirements." + requirement + ".mode"), "&&"),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "world" -> requirementList.add(new RequirementWorld(
|
||||
config.getStringList(key + ".requirements." + requirement + ".value").toArray(new String[0]),
|
||||
Objects.equals(config.getString(key + ".requirements." + requirement + ".mode"), "&&"),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "permission" -> requirementList.add(new RequirementPermission(
|
||||
config.getStringList(key + ".requirements." + requirement + ".value").toArray(new String[0]),
|
||||
Objects.equals(config.getString(key + ".requirements." + requirement + ".mode"), "&&"),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "papi-condition" -> requirementList.add(new CustomPapi(
|
||||
Objects.requireNonNull(config.getConfigurationSection(key + ".requirements." + requirement + ".value")).getValues(false),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "other-loots" -> {
|
||||
List<OtherLoot> otherLoots = new ArrayList<>();
|
||||
for (String loot : Objects.requireNonNull(config.getConfigurationSection(key + ".other-loots")).getKeys(false)) {
|
||||
OtherLoot otherLoot = new OtherLoot(
|
||||
config.getInt(key + ".other-loots." + loot + ".min_amount", 1),
|
||||
config.getInt(key + ".other-loots." + loot + ".max_amount", 1),
|
||||
config.getString(key + ".other-loots." + loot + ".item"),
|
||||
config.getDouble(key + ".other-loots." + loot + ".chance", 1d)
|
||||
);
|
||||
otherLoots.add(otherLoot);
|
||||
}
|
||||
crop.setOtherLoots(otherLoots.toArray(new OtherLoot[0]));
|
||||
}
|
||||
case "season" -> {
|
||||
List<String> seasonList = config.getStringList(key + ".season");
|
||||
CCSeason[] seasons = new CCSeason[seasonList.size()];
|
||||
for (int i = 0; i < seasonList.size(); i++) {
|
||||
seasons[i] = CCSeason.valueOf(seasonList.get(i).toUpperCase());
|
||||
}
|
||||
crop.setSeasons(seasons);
|
||||
}
|
||||
case "gigantic-crop" -> {
|
||||
boolean isBlock = true;
|
||||
String blockID = config.getString(key + ".gigantic-crop.block");
|
||||
if (blockID == null) {
|
||||
blockID = config.getString(key + ".gigantic-crop.furniture");
|
||||
isBlock = false;
|
||||
}
|
||||
GiganticCrop giganticCrop = new GiganticCrop(
|
||||
config.getDouble(key + ".gigantic-crop.chance"),
|
||||
isBlock,
|
||||
blockID
|
||||
);
|
||||
crop.setGiganticCrop(giganticCrop);
|
||||
}
|
||||
case "return" -> {
|
||||
crop.setReturnStage(config.getString(key + ".return"));
|
||||
}
|
||||
case "requirements" -> {
|
||||
List<RequirementInterface> requirementList = new ArrayList<>();
|
||||
for (String requirement : Objects.requireNonNull(config.getConfigurationSection(key + ".requirements")).getKeys(false)) {
|
||||
String type = config.getString(key + ".requirements." + requirement + ".type");
|
||||
if (type == null) continue;
|
||||
switch (type) {
|
||||
case "time" -> requirementList.add(new RequirementTime(
|
||||
config.getStringList(key + ".requirements." + requirement + ".value").toArray(new String[0]),
|
||||
Objects.equals(config.getString(key + ".requirements." + requirement + ".mode"), "&&"),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "weather" -> requirementList.add(new RequirementWeather(
|
||||
config.getStringList(key + ".requirements." + requirement + ".value").toArray(new String[0]),
|
||||
Objects.equals(config.getString(key + ".requirements." + requirement + ".mode"), "&&"),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "yPos" -> requirementList.add(new RequirementYPos(
|
||||
config.getStringList(key + ".requirements." + requirement + ".value").toArray(new String[0]),
|
||||
Objects.equals(config.getString(key + ".requirements." + requirement + ".mode"), "&&"),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "biome" -> requirementList.add(new RequirementBiome(
|
||||
config.getStringList(key + ".requirements." + requirement + ".value").toArray(new String[0]),
|
||||
Objects.equals(config.getString(key + ".requirements." + requirement + ".mode"), "&&"),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "world" -> requirementList.add(new RequirementWorld(
|
||||
config.getStringList(key + ".requirements." + requirement + ".value").toArray(new String[0]),
|
||||
Objects.equals(config.getString(key + ".requirements." + requirement + ".mode"), "&&"),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "permission" -> requirementList.add(new RequirementPermission(
|
||||
config.getStringList(key + ".requirements." + requirement + ".value").toArray(new String[0]),
|
||||
Objects.equals(config.getString(key + ".requirements." + requirement + ".mode"), "&&"),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
case "papi-condition" -> requirementList.add(new CustomPapi(
|
||||
Objects.requireNonNull(config.getConfigurationSection(key + ".requirements." + requirement + ".value")).getValues(false),
|
||||
config.getString(key + ".requirements." + requirement + ".message")
|
||||
));
|
||||
}
|
||||
}
|
||||
crop.setRequirements(requirementList.toArray(new RequirementInterface[0]));
|
||||
}
|
||||
crop.setRequirements(requirementList.toArray(new RequirementInterface[0]));
|
||||
}
|
||||
}
|
||||
|
||||
crop.setCanRotate(config.getBoolean(key + ".rotation", true));
|
||||
CROPS.put(key, crop);
|
||||
}
|
||||
AdventureUtil.consoleMessage("[CustomCrops] Loaded <green>" + CROPS.size() + "<gray> crops");
|
||||
|
||||
@@ -155,6 +155,9 @@ public class MainConfig {
|
||||
wireAmount = config.getInt("optimization.limitation.tripwire-amount", 64);
|
||||
frameAmount = config.getInt("optimization.limitation.itemframe-amount", 64);
|
||||
|
||||
if (MainConfig.cropMode) AdventureUtil.consoleMessage("[CustomCrops] Crop Mode: Tripwire");
|
||||
else AdventureUtil.consoleMessage("[CustomCrops] Crop Mode: ItemFrame");
|
||||
|
||||
autoGrow = config.getBoolean("mechanics.auto-grow.enable", true);
|
||||
enableCompensation = config.getBoolean("mechanics.auto-grow.time-compensation", true);
|
||||
timeToGrow = config.getInt("mechanics.auto-grow.crops-grow-time", 20000);
|
||||
|
||||
@@ -504,6 +504,8 @@ public class CropManager extends Function {
|
||||
Crop crop = CropConfig.CROPS.get(growingCrop.getType());
|
||||
if (crop == null) return true;
|
||||
|
||||
if (!location.getChunk().isEntitiesLoaded()) return false;
|
||||
|
||||
Location potLoc = location.clone().subtract(0,1,0);
|
||||
Fertilizer fertilizer = getFertilizer(potLoc);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
|
||||
public class ContainerListener extends PacketAdapter {
|
||||
|
||||
private CropManager cropManager;
|
||||
private final CropManager cropManager;
|
||||
|
||||
public ContainerListener(CropManager cropManager) {
|
||||
super(CustomCrops.plugin, ListenerPriority.HIGHEST, PacketType.Play.Server.WINDOW_ITEMS);
|
||||
|
||||
@@ -53,10 +53,6 @@ public class Sprinkler {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only needed in config
|
||||
* @return twoD
|
||||
*/
|
||||
@Nullable
|
||||
public String getTwoD() {
|
||||
return twoD;
|
||||
@@ -66,10 +62,6 @@ public class Sprinkler {
|
||||
this.twoD = twoD;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only needed in config
|
||||
* @return threeD
|
||||
*/
|
||||
@Nullable
|
||||
public String getThreeD() {
|
||||
return threeD;
|
||||
|
||||
Reference in New Issue
Block a user