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>
<artifactId>themepark</artifactId>
<version>1.2.6</version>
<version>1.2.7</version>
<repositories>
<repository>

View file

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

View file

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