mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2025-01-04 07:28:17 +01:00
save brushes globally
This commit is contained in:
parent
2e84248cbc
commit
5d7f0b1418
@ -56,17 +56,24 @@ public class BrushOptionsCommands extends MethodCommands {
|
|||||||
@Command(
|
@Command(
|
||||||
aliases = {"/savebrush"},
|
aliases = {"/savebrush"},
|
||||||
usage = "[name]",
|
usage = "[name]",
|
||||||
desc = "Save your current brush",
|
desc = "Save your current brush\n" +
|
||||||
|
"prefix with ../ to save globally",
|
||||||
min = 1
|
min = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.save")
|
@CommandPermissions("worldedit.brush.save")
|
||||||
public void saveBrush(Player player, LocalSession session, String name) throws WorldEditException, IOException {
|
public void saveBrush(Player player, LocalSession session, String name) throws WorldEditException, IOException {
|
||||||
BrushTool tool = session.getBrushTool(player);
|
BrushTool tool = session.getBrushTool(player);
|
||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
|
boolean root = name.startsWith("../");
|
||||||
name = FileSystems.getDefault().getPath(name).getFileName().toString();
|
name = FileSystems.getDefault().getPath(name).getFileName().toString();
|
||||||
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
|
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
|
||||||
name = name.endsWith(".jsgz") ? name : name + ".jsgz";
|
name = name.endsWith(".jsgz") ? name : name + ".jsgz";
|
||||||
File file = new File(folder, player.getUniqueId() + File.separator + name);
|
File file;
|
||||||
|
if (root && player.hasPermission("worldedit.brush.save.other")) {
|
||||||
|
file = new File(folder, name);
|
||||||
|
} else {
|
||||||
|
file = new File(folder, player.getUniqueId() + File.separator + name);
|
||||||
|
}
|
||||||
File parent = file.getParentFile();
|
File parent = file.getParentFile();
|
||||||
if (!parent.exists()) {
|
if (!parent.exists()) {
|
||||||
parent.mkdirs();
|
parent.mkdirs();
|
||||||
|
Loading…
Reference in New Issue
Block a user