mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-29 12:37:37 +01:00
Schems save in the respective addon data folders
This commit is contained in:
parent
284839c6a4
commit
265f05529b
@ -127,9 +127,10 @@ commands:
|
||||
parameters: "<load><copy><paste><pos1><pos2><save>"
|
||||
description: "manipulate schems"
|
||||
copy-first: "&cCopy a schem first!"
|
||||
file-exists: "&cFile already exists, overwrite?"
|
||||
no-such-file: "&cNo such file!"
|
||||
could-not-load: "&cCould not load that file!"
|
||||
could-not-save: "&Hmm, something went wrong saving that file: [message]"
|
||||
could-not-save: "&cHmm, something went wrong saving that file: [message]"
|
||||
set-pos1: "&aPosition 1 set at [vector]"
|
||||
set-pos2: "&aPosition 2 set at [vector]"
|
||||
set-different-pos: "&cSet a different location - this pos is already set!"
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.tastybento.bskyblock.commands.admin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -37,7 +38,10 @@ public class AdminSchemCommand extends CompositeCommand {
|
||||
showHelp(this, user);
|
||||
return false;
|
||||
}
|
||||
Clipboard cb = clipboards.getOrDefault(user.getUniqueId(), new Clipboard(getPlugin(), getPlugin().getDataFolder()));
|
||||
File schemFolder = new File(getIWM().getDataFolder(getWorld()), "schems");
|
||||
getPlugin().log("DEBUG: schemFolder = " + schemFolder.getAbsolutePath());
|
||||
getPlugin().log(getIWM().getAddon(getWorld()).map(a -> "Addon = " + a.toString() + " data folder = " + a.getDataFolder().getAbsolutePath()).orElse("Not addon"));
|
||||
Clipboard cb = clipboards.getOrDefault(user.getUniqueId(), new Clipboard(getPlugin(), schemFolder));
|
||||
|
||||
if (args.get(0).equalsIgnoreCase("paste")) {
|
||||
if (cb.isFull()) {
|
||||
@ -92,7 +96,15 @@ public class AdminSchemCommand extends CompositeCommand {
|
||||
if (args.get(0).equalsIgnoreCase("save")) {
|
||||
if (cb.isFull()) {
|
||||
if (args.size() == 2) {
|
||||
return cb.save(user, args.get(1));
|
||||
// Check if file exists
|
||||
File newFile = new File(schemFolder, args.get(1) + ".schem");
|
||||
if (newFile.exists()) {
|
||||
user.sendMessage("commands.admin.schem.file-exists");
|
||||
this.askConfirmation(user, () -> cb.save(user, args.get(1)));
|
||||
return false;
|
||||
} else {
|
||||
return cb.save(user, args.get(1));
|
||||
}
|
||||
} else {
|
||||
showHelp(this, user);
|
||||
return false;
|
||||
|
@ -658,11 +658,11 @@ public class Clipboard {
|
||||
/**
|
||||
* Save the clipboard to a file
|
||||
* @param user - user who is copying
|
||||
* @param string - filename
|
||||
* @param newFile - filename
|
||||
* @return - true if successful, false if error
|
||||
*/
|
||||
public boolean save(User user, String string) {
|
||||
File file = new File(schemFolder, string);
|
||||
public boolean save(User user, String newFile) {
|
||||
File file = new File(schemFolder, newFile);
|
||||
try {
|
||||
getBlockConfig().save(file);
|
||||
} catch (IOException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user