Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/java/network/warzone/scaffold/Scaffold.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public final class Scaffold extends JavaPlugin implements TabCompleter {

private static Scaffold instance;
public static Scaffold instance;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is not needed as the getter method below is already public

public static Scaffold get() {
return instance;
}
Expand All @@ -32,6 +32,8 @@ public void onEnable() {
//TODO Disabled large number warning for now but add back later with some changes
//getServer().getPluginManager().registerEvents(new ScaffoldListener(), this);

this.saveDefaultConfig();

this.commands = new CommandsManager<CommandSender>() {
@Override
public boolean hasPermission(CommandSender sender, String perm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.bukkit.*;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;

Expand All @@ -28,6 +30,7 @@
import java.util.concurrent.ThreadLocalRandom;

public class ScaffoldCommands {
static FileConfiguration config = Scaffold.get().getConfig();

@CommandPermissions("scaffold.command.lock")
@Command(aliases = "lock", desc = "Lock a world at this time.", min = 1, max = 1, usage = "<world>")
Expand Down Expand Up @@ -205,8 +208,8 @@ public static void close(CommandContext cmd, CommandSender sender) {

@CommandPermissions("scaffold.command.export")
@Command(aliases = "export", desc = "Export a world.", min = 0, max = 1, usage = "<world>")
public static void upload(CommandContext cmd, CommandSender sender) {
if (!sender.hasPermission("scaffold.command.upload")) {
public static void export(CommandContext cmd, CommandSender sender) {
if (!sender.hasPermission("scaffold.command.export")) {
sender.sendMessage(ChatColor.RED + "You do not have permission.");
return;
}
Expand Down Expand Up @@ -238,7 +241,7 @@ public static void upload(CommandContext cmd, CommandSender sender) {

sender.sendMessage(ChatColor.YELLOW + "Uploading world...");
try {
HttpResponse<String> response = Unirest.post("https://transfer.sh/").header("Max-Downloads", "1").header("Max-Days", "3").field("upload-file", zip).asString();
HttpResponse<String> response = Unirest.post("https://transfer.sh/").header("Max-Downloads", config.getString("export.maxdownloads")).header("Max-Days", config.getString("export.maxdays")).field("upload-file", zip).asString();
String link = response.getBody();
zip.delete();
sender.sendMessage(ChatColor.GOLD + "Upload complete: " + link);
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export:
# Maximum amount of downloads before link is dead.
maxdownloads: 1
# Maximum amount of days before link is dead.
maxdays: 3