13
0

Merge pull request 'Fixing of SchemName' (#82) from schem-download into master

Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2021-01-08 17:44:31 +01:00
Commit dfb45178f8

Datei anzeigen

@ -95,9 +95,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 +110,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 +134,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("\\", ":");
}
} }