mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 01:49:49 -05:00
SAAAAAAAND!
Former-commit-id: 3fbc15d28e0de1d61682248bcea42fdb066e263d
This commit is contained in:
1 parent
0267baefef
commit
a487f23bf3
3 files changed
+88
-2
No files matched your search
@@ -260,6 +260,13 @@ public class CommandManager implements TabCompleter, CommandExecutor {
|
||||
.permission("quickshop.recovery")
|
||||
.executor(new SubCommand_Recovery())
|
||||
.build());
|
||||
registerCmd(
|
||||
CommandContainer.builder()
|
||||
.prefix("export")
|
||||
.hidden(true)
|
||||
.permission("quickshop.export")
|
||||
.executor(new SubCommand_Export())
|
||||
.build());
|
||||
}
|
||||
|
||||
private void registerCmd(CommandContainer container) {
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* This file is a part of project QuickShop, the name is SubCommand_Amount.java
|
||||
* Copyright (C) Ghost_chu <https://github.com/Ghost-chu>
|
||||
* Copyright (C) Bukkit Commons Studio and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.maxgamer.quickshop.Command.SubCommands;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.util.List;
|
||||
import lombok.SneakyThrows;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.Command.CommandProcesser;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
public class SubCommand_Export implements CommandProcesser {
|
||||
|
||||
private final QuickShop plugin = QuickShop.instance;
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public synchronized void onCommand(
|
||||
@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
if (!(sender instanceof ConsoleCommandSender)) {
|
||||
return;
|
||||
}
|
||||
File file = new File(plugin.getDataFolder(), "export.txt");
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
file.createNewFile();
|
||||
} else {
|
||||
file.createNewFile();
|
||||
}
|
||||
|
||||
new BukkitRunnable() {
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void run() {
|
||||
StringBuilder finalReport = new StringBuilder();
|
||||
plugin
|
||||
.getShopLoader()
|
||||
.getShopsInDatabase()
|
||||
.forEach((shop -> finalReport.append("\t").append(shop).append("\n")));
|
||||
BufferedWriter outputStream = new BufferedWriter(new FileWriter(file, false));
|
||||
outputStream.write(finalReport.toString());
|
||||
outputStream.close();
|
||||
sender.sendMessage("Done.");
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> onTabComplete(
|
||||
@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] cmdArg) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -89,7 +89,7 @@ permissions:
|
||||
description: Switch to or from developer mode
|
||||
default: op
|
||||
quickshop.export:
|
||||
description: Allows exporting the database to mysql or sqlite
|
||||
description: Allows exporting the database to a plain file
|
||||
default: op
|
||||
quickshop.alerts:
|
||||
description: Alert the player when someone tries to cheat with the display item
|
||||
@@ -123,4 +123,4 @@ permissions:
|
||||
default: op
|
||||
quickshop.recovery:
|
||||
description: Permission to use /qs recovery, WARNING DO NOT EXECUTE THIS COMMAND IF YOU DID NOT KNOW WHAT WILL HAPPEND
|
||||
default: false
|
||||
default: false
|
||||
Reference in new issue
Block a user