EpicFarming/src/main/java/com/songoda/epicfarming/farming/levels/Level.java

108 lines
3.2 KiB
Java
Raw Normal View History

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