3
0
Fork 0

Fixed a problem with the Menu

This commit is contained in:
BuildTools 2019-08-28 17:50:17 +02:00
parent d4244e813d
commit 332945095e
3 changed files with 37 additions and 10 deletions

View file

@ -11,7 +11,7 @@
<groupId>me.paradoxpixel</groupId> <groupId>me.paradoxpixel</groupId>
<artifactId>themepark</artifactId> <artifactId>themepark</artifactId>
<version>1.2.6</version> <version>1.2.7</version>
<repositories> <repositories>
<repository> <repository>

View file

@ -71,16 +71,17 @@ public class AttractionMenu {
return; return;
HashMap<String, Region> regions = API.getRegions(); HashMap<String, Region> regions = API.getRegions();
HashMap<String, Integer> size = new HashMap<>();
for(String id : section.getKeys(false)) { for(String id : section.getKeys(false)) {
if(API.getRegions().size() >= 6) { if(size.size() >= 6) {
config.getConfig().set("regions." + id, null); config.getConfig().set("regions." + id, null);
config.save();
continue; continue;
} }
String name = config.getConfig().getString("region." + id + ".name"); String name = config.getConfig().getString("region." + id + ".name");
List<String> lore = config.getConfig().getStringList("region." + id + ".lore"); List<String> lore = config.getConfig().getStringList("region." + id + ".lore");
size.put(id.toLowerCase(), 0);
regions.remove(id); regions.remove(id);
if(API.isRegion(id)) { if(API.isRegion(id)) {
API.getRegion(id).setName(name); API.getRegion(id).setName(name);
@ -90,8 +91,17 @@ public class AttractionMenu {
Region region = new Region(id, name, lore); Region region = new Region(id, name, lore);
API.addRegion(region); API.addRegion(region);
if(!id.toLowerCase().equals(id)) {
config.getConfig().set("region." + id, null);
id = id.toLowerCase();
config.getConfig().set("region." + id + ".name", name);
config.getConfig().set("region." + id + ".lore", lore);
}
} }
config.save();
for(String string : regions.keySet()) for(String string : regions.keySet())
API.removeRegion(string); API.removeRegion(string);
@ -108,18 +118,28 @@ public class AttractionMenu {
HashMap<String, Attraction> attractions = API.getAttractions(); HashMap<String, Attraction> attractions = API.getAttractions();
for(String id : section.getKeys(false)) { for(String id : section.getKeys(false)) {
String region_id = config.getConfig().getString("attraction." + id + ".region_id"); String region_id = config.getConfig().getString("attraction." + id + ".region_id");
if(!region_id.toLowerCase().equals(region_id)) {
region_id = region_id.toLowerCase();
config.getConfig().set("attraction." + id + ".region_id", region_id);
}
if(!API.isRegion(region_id)) if(!API.isRegion(region_id))
continue; continue;
if(API.isRegionFull(region_id)) if(size.get(region_id.toLowerCase()) >= 8)
continue; continue;
String name = config.getConfig().getString("attraction." + id + ".name"); String name = config.getConfig().getString("attraction." + id + ".name");
Location location = LocationUtils.toLocation(config.getConfig().getString("attraction." + id + ".location")); Location location = LocationUtils.toLocation(config.getConfig().getString("attraction." + id + ".location"));
Type type = Type.getType(config.getConfig().getString("attraction." + id + ".type")); Type type = Type.getType(config.getConfig().getString("attraction." + id + ".type"));
Status status = Status.getStatus(config.getConfig().getString("attraction." + id + ".status")); Status status = Status.getStatus(config.getConfig().getString("attraction." + id + ".status"));
if(!type.containsStatus(status)) {
status = type.getDefault();
config.getConfig().set("attraction." + id + ".status", type.getDefault().toString());
}
attractions.remove(id); attractions.remove(id.toLowerCase());
size.put(region_id.toLowerCase(), size.get(region_id.toLowerCase()) + 1);
if(API.isAttraction(id)) { if(API.isAttraction(id)) {
Attraction attraction = API.getAttraction(id); Attraction attraction = API.getAttraction(id);
attraction.setName(name); attraction.setName(name);
@ -127,17 +147,24 @@ public class AttractionMenu {
attraction.setLocation(location); attraction.setLocation(location);
attraction.setType(type); attraction.setType(type);
attraction.setStatus(status, null); attraction.setStatus(status, null);
if(!type.containsStatus(status)) {
config.getConfig().set("attraction." + id + ".status", type.getDefault().toString());
config.save();
}
continue; continue;
} }
Attraction attraction = new Attraction(id, name, region_id, location, type, status); Attraction attraction = new Attraction(id, name, region_id, location, type, status);
API.addAttraction(attraction); API.addAttraction(attraction);
if(!id.toLowerCase().equals(id)) {
config.getConfig().set("attraction." + id, null);
id = id.toLowerCase();
config.getConfig().set("attraction." + id + ".name", name);
config.getConfig().set("attraction." + id + ".location", LocationUtils.toString(location));
config.getConfig().set("attraction." + id + ".type", type.toString());
config.getConfig().set("attraction." + id + ".status", status.toString());
}
} }
config.save();
for(String string : attractions.keySet()) for(String string : attractions.keySet())
API.removeAttraction(string); API.removeAttraction(string);
} }

View file

@ -1,5 +1,5 @@
name: ThemePark name: ThemePark
version: 1.2.6 version: 1.2.7
main: me.paradoxpixel.themepark.ThemeParkPlugin main: me.paradoxpixel.themepark.ThemeParkPlugin
author: ParadoxPixel author: ParadoxPixel
softdepend: [PlaceholderAPI] softdepend: [PlaceholderAPI]