13
0

Fixing of SchemName #82

Manuell gemergt
Lixfel hat 2 Commits von schem-download nach master 2021-01-08 17:44:32 +01:00 zusammengeführt
Nur Änderungen aus Commit 3cb522b0aa werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -18,6 +18,7 @@
*/ */
package de.steamwar.schematicsystem; package de.steamwar.schematicsystem;
import de.steamwar.schematicsystem.commands.SchematicCommand;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicType; import de.steamwar.sql.SchematicType;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
@ -95,9 +96,10 @@ public class ExternalUpDownload {
for (int i = 0; i < schemName.length - 1; i++) { for (int i = 0; i < schemName.length - 1; i++) {
if(!name.toString().equals("")) if(!name.toString().equals(""))
name.append("."); 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<Byte> schemData = new ArrayList<>(); List<Byte> schemData = new ArrayList<>();
while (zipInputStream.available() == 1) { while (zipInputStream.available() == 1) {
schemData.add((byte) zipInputStream.read()); schemData.add((byte) zipInputStream.read());
@ -109,15 +111,16 @@ public class ExternalUpDownload {
if(testSchem != null) { if(testSchem != null) {
int i = 1; int i = 1;
while (true) { while (true) {
if(Schematic.getSchemFromDB(name.toString() + "-" + i, player.getUniqueId()) == null) { if(Schematic.getSchemFromDB(schematicName + "-" + i, player.getUniqueId()) == null) {
name = new StringBuilder(name.toString() + "-" + i); schematicName = schematicName + "-" + i;
break; break;
} }
i++; 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")); schem.saveFromBytes(bytes, schemName[schemName.length - 1].equals("schem"));
zipInputStream.closeEntry(); zipInputStream.closeEntry();
player.sendMessage(SchematicSystem.PREFIX + "§6Die Schematic §e" + schematic.getName() + " §6wurde von WarGearWorld.net als §e" + name.toString() + " §6heruntergeladen!"); 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(); httpclient.getConnectionManager().shutdown();
} }
} }
private static String replaceString(String str) {
return str.replace("/", "-").replace("\\", "-").replace("<", "~").replace(">", "~").replace("^", "*").replace("°", "*").replace("'", "*").replace("\\", ":");
}
} }