Standalone Schematic Node Impl #171
@ -18,12 +18,9 @@ public class WorldEditWrapper {
|
||||
InputStream getPlayerClipboard(Player player, boolean schemFormat);
|
||||
void setPlayerClipboard(Player player, InputStream is, boolean schemFormat);
|
||||
Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException;
|
||||
default File getWorldEditSchematicFolder() {
|
||||
return WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getWorkingDirectoryFile(WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getConfiguration().saveDir);
|
||||
}
|
||||
}
|
||||
|
||||
static WorldEditPlugin getWorldEditPlugin() {
|
||||
public static WorldEditPlugin getWorldEditPlugin() {
|
||||
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ public class StandaloneProvider implements Provider {
|
||||
}
|
||||
|
||||
private int nodeId = 1;
|
||||
private final File schematicDir = WorldEditWrapper.impl.getWorldEditSchematicFolder();
|
||||
private final File schematicDir = WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getWorkingDirectoryFile(WorldEditWrapper.getWorldEditPlugin().getWorldEdit().getConfiguration().saveDir);
|
||||
private final Map<Integer, SchematicNode> nodeById = new HashMap<>();
|
||||
private final Map<Integer, List<SchematicNode>> nodesByParent = new HashMap<>();
|
||||
private final Map<Integer, Path> nodesToPath = new HashMap<>();
|
||||
Chaoscaot markierte diese Unterhaltung als gelöst
|
||||
@ -215,7 +215,7 @@ public class StandaloneProvider implements Provider {
|
||||
SchematicNode node = new SchematicNode(
|
||||
nodeId++,
|
||||
0,
|
||||
file.getName().substring(file.getName().lastIndexOf(".")),
|
||||
file.isDirectory()?file.getName():file.getName().substring(file.getName().lastIndexOf(".")),
|
||||
null,
|
||||
"",
|
||||
"normal",
|
||||
@ -237,7 +237,35 @@ public class StandaloneProvider implements Provider {
|
||||
|
||||
@Override
|
||||
public void createSchematicNode(int owner, String name, Integer parent, String type, String item) {
|
||||
boolean isDir = type == null;
|
||||
Path p = null;
|
||||
try {
|
||||
if(isDir) {
|
||||
p = Files.createDirectory(new File(nodesToPath.get(parent == null?-1:parent).toFile(), name).toPath());
|
||||
} else {
|
||||
p = Files.createFile(new File(nodesToPath.get(parent == null?-1:parent).toFile(), name + ".schem").toPath());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
|
||||
File file = p.toFile();
|
||||
int id = nodeId++;
|
||||
nodesToPath.put(id, p);
|
||||
SchematicNode node = new SchematicNode(
|
||||
nodeId++,
|
||||
0,
|
||||
file.isDirectory()?file.getName():file.getName().substring(file.getName().lastIndexOf(".")),
|
||||
null,
|
||||
"",
|
||||
"normal",
|
||||
file.isDirectory(),
|
||||
0,
|
||||
Timestamp.from(Instant.now()),
|
||||
file.getName().endsWith(".schem")
|
||||
);
|
||||
nodeById.put(id, node);
|
||||
nodesByParent.get(parent == null?-1:parent).add(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -352,6 +380,10 @@ public class StandaloneProvider implements Provider {
|
||||
while((nReadBytes = blob.read(bucket, 0, bucket.length)) !=-1){
|
||||
stream.write(bucket, 0, nReadBytes);
|
||||
}
|
||||
|
||||
if(newFormat != node.getSchemFormat()) {
|
||||
nodesToPath.get(node.getId()).toFile().renameTo(new File(nodesToPath.get(node.getId()).toFile().getParentFile(), node.getName() + "." + (newFormat?".schem":"schematic")));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
WTF? Fehlt da nicht ein static? Oder funktioniert das auch für normale Konstruktoren?
Das funktioniert auch so.