Add weeks time indicators, clean other indicators

The old Dutch time indicators have been removed from the lists, this
might cause problems for people if they regenerate their config but
don't add these tags again.

Added console warnings at startup to indicate incorrect duration
strings.

Fixes #32
This commit is contained in:
Thijs Wiefferink 2015-10-03 21:12:38 +02:00
parent d26fa99b95
commit 7fc5a5af81
2 changed files with 15 additions and 0 deletions

View File

@ -692,6 +692,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
identifiers.addAll(this.getConfig().getStringList("minutes"));
identifiers.addAll(this.getConfig().getStringList("hours"));
identifiers.addAll(this.getConfig().getStringList("days"));
identifiers.addAll(this.getConfig().getStringList("weeks"));
identifiers.addAll(this.getConfig().getStringList("months"));
identifiers.addAll(this.getConfig().getStringList("years"));
if(!identifiers.contains(suffix)) {
@ -723,6 +724,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
ArrayList<String> minutes = new ArrayList<String>(this.getConfig().getStringList("minutes"));
ArrayList<String> hours = new ArrayList<String>(this.getConfig().getStringList("hours"));
ArrayList<String> days = new ArrayList<String>(this.getConfig().getStringList("days"));
ArrayList<String> weeks = new ArrayList<String>(this.getConfig().getStringList("weeks"));
ArrayList<String> months = new ArrayList<String>(this.getConfig().getStringList("months"));
ArrayList<String> years = new ArrayList<String>(this.getConfig().getStringList("years"));
@ -740,6 +742,8 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
calendar.add(Calendar.HOUR, durationInt);
} else if(days.contains(durationString)) {
calendar.add(Calendar.DAY_OF_MONTH, durationInt);
} else if(weeks.contains(durationString)) {
calendar.add(Calendar.DAY_OF_MONTH, durationInt*7);
} else if(months.contains(durationString)) {
calendar.add(Calendar.MONTH, durationInt);
} else if(years.contains(durationString)) {

View File

@ -1022,6 +1022,7 @@ public class FileManager {
public void run() {
List<GeneralRegion> noWorld = new ArrayList<GeneralRegion>();
List<GeneralRegion> noRegion = new ArrayList<GeneralRegion>();
List<GeneralRegion> incorrectDuration = new ArrayList<GeneralRegion>();
for(GeneralRegion region : AreaShop.getInstance().getFileManager().getRegions()) {
// Add broken regions to a list
if(region != null) {
@ -1031,6 +1032,9 @@ public class FileManager {
if(region.getRegion() == null) {
noRegion.add(region);
}
if(region.isRentRegion() && !plugin.checkTimeFormat(((RentRegion)region).getDurationString())) {
incorrectDuration.add(region);
}
}
}
// All files are loaded, print possible problems to the console
@ -1062,6 +1066,13 @@ public class FileManager {
if(noWorldRegions) {
plugin.getLogger().warning("Remove these regions from AreaShop with '/as del' or load the world(s) on the server again.");
}
if(!incorrectDuration.isEmpty()) {
List<String> incorrectDurationNames = new ArrayList<String>();
for(GeneralRegion region : incorrectDuration) {
incorrectDurationNames.add(region.getName());
}
plugin.getLogger().warning("The following regions have an incorrect time format as duration: "+Utils.createCommaSeparatedList(incorrectDurationNames));
}
}
}.runTask(plugin);
}