2019-10-17 04:44:27 +02:00
|
|
|
package com.songoda.epicfarming.farming.levels;
|
2018-05-06 18:56:17 +02:00
|
|
|
|
2019-09-11 16:37:45 +02:00
|
|
|
import com.songoda.epicfarming.EpicFarming;
|
2019-10-17 04:44:27 +02:00
|
|
|
import com.songoda.epicfarming.farming.levels.modules.Module;
|
2018-05-06 18:56:17 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2018-05-06 19:51:39 +02:00
|
|
|
import java.util.List;
|
2018-05-06 18:56:17 +02:00
|
|
|
|
2019-09-11 16:37:45 +02:00
|
|
|
public class Level {
|
2018-05-06 18:56:17 +02:00
|
|
|
|
2019-10-17 04:44:27 +02:00
|
|
|
private final ArrayList<Module> registeredModules;
|
2023-06-25 14:56:37 +02:00
|
|
|
private final List<String> description = new ArrayList<>();
|
|
|
|
private final int level;
|
|
|
|
private final int costExperience;
|
|
|
|
private final int costEconomy;
|
|
|
|
private final int radius;
|
|
|
|
private final int pages;
|
|
|
|
private final double speedMultiplier;
|
|
|
|
private final boolean autoReplant;
|
2018-05-06 18:56:17 +02:00
|
|
|
|
|
|
|
|
2021-07-19 18:05:14 +02:00
|
|
|
Level(int level, int costExperience, int costEconomy, double speedMultiplier, int radius, boolean autoReplant, int pages, ArrayList<Module> registeredModules) {
|
2018-05-06 18:56:17 +02:00
|
|
|
this.level = level;
|
2021-07-19 18:05:14 +02:00
|
|
|
this.costExperience = costExperience;
|
2018-05-06 18:56:17 +02:00
|
|
|
this.costEconomy = costEconomy;
|
|
|
|
this.speedMultiplier = speedMultiplier;
|
|
|
|
this.radius = radius;
|
|
|
|
this.autoReplant = autoReplant;
|
2019-10-01 01:29:37 +02:00
|
|
|
this.pages = pages;
|
2019-10-17 04:44:27 +02:00
|
|
|
this.registeredModules = registeredModules;
|
2021-07-19 18:05:14 +02:00
|
|
|
|
2019-10-17 04:44:27 +02:00
|
|
|
buildDescription();
|
|
|
|
}
|
2018-05-06 18:56:17 +02:00
|
|
|
|
2019-10-17 04:44:27 +02:00
|
|
|
public void buildDescription() {
|
2023-06-25 14:56:37 +02:00
|
|
|
EpicFarming instance = EpicFarming.getPlugin(EpicFarming.class);
|
2018-05-06 19:51:39 +02:00
|
|
|
|
2023-06-25 14:56:37 +02:00
|
|
|
this.description.add(instance.getLocale().getMessage("interface.button.radius")
|
|
|
|
.processPlaceholder("radius", this.radius).getMessage());
|
2019-09-11 18:21:55 +02:00
|
|
|
|
2023-06-25 14:56:37 +02:00
|
|
|
this.description.add(instance.getLocale().getMessage("interface.button.speed")
|
|
|
|
.processPlaceholder("speed", this.speedMultiplier).getMessage());
|
2018-05-06 18:56:17 +02:00
|
|
|
|
|
|
|
|
2023-06-25 14:56:37 +02:00
|
|
|
if (this.autoReplant) {
|
|
|
|
this.description.add(instance.getLocale().getMessage("interface.button.autoreplant")
|
2019-10-17 04:44:27 +02:00
|
|
|
.processPlaceholder("status",
|
|
|
|
instance.getLocale().getMessage("general.interface.unlocked")
|
|
|
|
.getMessage()).getMessage());
|
2023-06-25 14:56:37 +02:00
|
|
|
}
|
2018-09-28 04:54:43 +02:00
|
|
|
|
2023-06-25 14:56:37 +02:00
|
|
|
if (this.pages > 1) {
|
|
|
|
this.description.add(instance.getLocale().getMessage("interface.button.pages")
|
|
|
|
.processPlaceholder("amount", this.pages).getMessage());
|
|
|
|
}
|
2019-10-01 01:29:37 +02:00
|
|
|
|
2023-06-25 14:56:37 +02:00
|
|
|
for (Module module : this.registeredModules) {
|
|
|
|
this.description.add(module.getDescription());
|
2019-10-17 04:44:27 +02:00
|
|
|
}
|
2018-05-06 18:56:17 +02:00
|
|
|
}
|
|
|
|
|
2018-05-06 19:51:39 +02:00
|
|
|
public List<String> getDescription() {
|
2023-06-25 14:56:37 +02:00
|
|
|
return new ArrayList<>(this.description);
|
2018-05-06 18:56:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getLevel() {
|
2023-06-25 14:56:37 +02:00
|
|
|
return this.level;
|
2018-05-06 18:56:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getRadius() {
|
2023-06-25 14:56:37 +02:00
|
|
|
return this.radius;
|
2018-05-06 18:56:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAutoReplant() {
|
2023-06-25 14:56:37 +02:00
|
|
|
return this.autoReplant;
|
2018-05-06 18:56:17 +02:00
|
|
|
}
|
|
|
|
|
2019-10-01 01:29:37 +02:00
|
|
|
public int getPages() {
|
2023-06-25 14:56:37 +02:00
|
|
|
return this.pages;
|
2019-10-01 01:29:37 +02:00
|
|
|
}
|
|
|
|
|
2018-05-06 18:56:17 +02:00
|
|
|
public double getSpeedMultiplier() {
|
2023-06-25 14:56:37 +02:00
|
|
|
return this.speedMultiplier;
|
2018-05-06 18:56:17 +02:00
|
|
|
}
|
|
|
|
|
2021-07-19 18:05:14 +02:00
|
|
|
public int getCostExperience() {
|
2023-06-25 14:56:37 +02:00
|
|
|
return this.costExperience;
|
2018-05-06 18:56:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getCostEconomy() {
|
2023-06-25 14:56:37 +02:00
|
|
|
return this.costEconomy;
|
2018-05-06 18:56:17 +02:00
|
|
|
}
|
2019-10-17 04:44:27 +02:00
|
|
|
|
|
|
|
public ArrayList<Module> getRegisteredModules() {
|
2023-06-25 14:56:37 +02:00
|
|
|
return new ArrayList<>(this.registeredModules);
|
2019-10-17 04:44:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addModule(Module module) {
|
2023-06-25 14:56:37 +02:00
|
|
|
this.registeredModules.add(module);
|
2019-10-17 04:44:27 +02:00
|
|
|
buildDescription();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Module getModule(String name) {
|
2023-06-25 14:56:37 +02:00
|
|
|
return this.registeredModules == null ? null :
|
|
|
|
this.registeredModules.stream().filter(module -> module.getName().equals(name)).findFirst().orElse(null);
|
2019-10-17 04:44:27 +02:00
|
|
|
}
|
2018-05-06 18:56:17 +02:00
|
|
|
}
|