Make structureutil compatible with older versions

This commit is contained in:
Denyk 2020-03-22 20:31:49 +01:00 committed by Brianna
parent 0513ce9ac2
commit d1d0a3dc24
3 changed files with 6 additions and 2 deletions

View File

@ -185,6 +185,7 @@ public class StructureCommand extends SubCommand {
"Command.Island.Admin.Structure.Save.Saved.Successful.Message")
.replace("%name", args[1]));
soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
return;
} catch (Exception e) {
messageManager.sendMessage(player, configLoad
.getString("Command.Island.Admin.Structure.Save.Saved.Failed.Message"));
@ -198,6 +199,7 @@ public class StructureCommand extends SubCommand {
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
} else if (args[0].equalsIgnoreCase("convert")) {
if (args.length == 2) {
File structureFile = new File(new File(skyblock.getDataFolder().toString() + "/structures"), args[1]);

View File

@ -155,7 +155,6 @@ public class IslandManager {
FileConfiguration configLoad_world = config_world.getFileConfiguration();
FileConfiguration configLoad_config = config_config.getFileConfiguration();
int x = (int) configLoad_world.get("World." + world.name() + ".nextAvailableLocation.island_number");
System.out.println("Ile n°" + x);
double r = Math.floor((Math.sqrt(x + 1) - 1) / 2) + 1;
double p = (8 * r * (r -1)) / 2;
double en = r * 2;

View File

@ -35,6 +35,7 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.regex.Pattern;
public final class StructureUtil {
@ -112,7 +113,9 @@ public final class StructureUtil {
fileInputStream.close();
Storage storage;
if (!org.bukkit.craftbukkit.libs.org.apache.commons.codec.binary.Base64.isBase64(content)) {
Pattern pattern = Pattern.compile("^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$");
if (!pattern.matcher(new String(content)).find()) {
try {
storage = new Gson().fromJson(Compression.decompress(content), Storage.class);
} catch (JsonSyntaxException e) {