From 3cb522b0aa1a191bddb2d0ae27834dff8cee8d17 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 8 Jan 2021 17:14:47 +0100 Subject: [PATCH 1/2] Fixing of SchemName --- .../schematicsystem/ExternalUpDownload.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/ExternalUpDownload.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/ExternalUpDownload.java index b1be11f..bf2fd18 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/ExternalUpDownload.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/ExternalUpDownload.java @@ -18,6 +18,7 @@ */ package de.steamwar.schematicsystem; +import de.steamwar.schematicsystem.commands.SchematicCommand; import de.steamwar.sql.Schematic; import de.steamwar.sql.SchematicType; import org.apache.http.HttpResponse; @@ -95,9 +96,10 @@ public class ExternalUpDownload { for (int i = 0; i < schemName.length - 1; i++) { if(!name.toString().equals("")) name.append("."); - name.append(schemName[i].replace("/", "-")); + name.append(replaceString(schemName[i])); } - Schematic testSchem = Schematic.getSchemFromDB(name.toString(), player.getUniqueId()); + String schematicName = name.substring(0, 60); + Schematic testSchem = Schematic.getSchemFromDB(schematicName, player.getUniqueId()); List schemData = new ArrayList<>(); while (zipInputStream.available() == 1) { schemData.add((byte) zipInputStream.read()); @@ -109,15 +111,16 @@ public class ExternalUpDownload { if(testSchem != null) { int i = 1; while (true) { - if(Schematic.getSchemFromDB(name.toString() + "-" + i, player.getUniqueId()) == null) { - name = new StringBuilder(name.toString() + "-" + i); + if(Schematic.getSchemFromDB(schematicName + "-" + i, player.getUniqueId()) == null) { + schematicName = schematicName + "-" + i; break; } i++; } } - Schematic.createSchem(name.toString(), player.getUniqueId(), "", SchematicType.Normal); - Schematic schem = Schematic.getSchemFromDB(name.toString(), player.getUniqueId()); + + Schematic.createSchem(schematicName, player.getUniqueId(), "", SchematicType.Normal); + Schematic schem = Schematic.getSchemFromDB(schematicName, player.getUniqueId()); schem.saveFromBytes(bytes, schemName[schemName.length - 1].equals("schem")); zipInputStream.closeEntry(); player.sendMessage(SchematicSystem.PREFIX + "§6Die Schematic §e" + schematic.getName() + " §6wurde von WarGearWorld.net als §e" + name.toString() + " §6heruntergeladen!"); @@ -132,4 +135,8 @@ public class ExternalUpDownload { httpclient.getConnectionManager().shutdown(); } } + + private static String replaceString(String str) { + return str.replace("/", "-").replace("\\", "-").replace("<", "~").replace(">", "~").replace("^", "*").replace("°", "*").replace("'", "*").replace("\\", ":"); + } } From 4cca741e296d5ce8d793b35f6d5ebe4019b2d1ca Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 8 Jan 2021 17:34:21 +0100 Subject: [PATCH 2/2] Fixing of SchemName --- .../src/de/steamwar/schematicsystem/ExternalUpDownload.java | 1 - 1 file changed, 1 deletion(-) diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/ExternalUpDownload.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/ExternalUpDownload.java index bf2fd18..fe6a0b2 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/ExternalUpDownload.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/ExternalUpDownload.java @@ -18,7 +18,6 @@ */ package de.steamwar.schematicsystem; -import de.steamwar.schematicsystem.commands.SchematicCommand; import de.steamwar.sql.Schematic; import de.steamwar.sql.SchematicType; import org.apache.http.HttpResponse;