mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-26 15:45:12 +01:00
Added /ecoenchants exportlocale
This commit is contained in:
parent
354441655d
commit
b7c606d29c
@ -17,7 +17,8 @@ public class CommandEcoEnchants extends PluginCommand {
|
||||
this.addSubcommand(new CommandDebug(plugin))
|
||||
.addSubcommand(new CommandReload(plugin))
|
||||
.addSubcommand(new CommandGiverandombook(plugin))
|
||||
.addSubcommand(new CommandRandomenchant(plugin));
|
||||
.addSubcommand(new CommandRandomenchant(plugin))
|
||||
.addSubcommand(new CommandExportLocale(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,43 @@
|
||||
package com.willfp.ecoenchants.command;
|
||||
|
||||
import com.willfp.eco.core.command.CommandHandler;
|
||||
import com.willfp.eco.core.command.impl.Subcommand;
|
||||
import com.willfp.eco.core.web.Paste;
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
public class CommandExportLocale extends Subcommand {
|
||||
/**
|
||||
* Instantiate a new /ecoenchants debug command handler.
|
||||
*
|
||||
* @param plugin The plugin for the commands to listen for.
|
||||
*/
|
||||
public CommandExportLocale(@NotNull final EcoEnchantsPlugin plugin) {
|
||||
super(plugin, "exportlocale", "ecoenchants.command.exportlocale", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandHandler getHandler() {
|
||||
return (sender, args) -> {
|
||||
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(new StringReader(this.getPlugin().getLangYml().toPlaintext()));
|
||||
for (EcoEnchant enchant : EcoEnchants.values()) {
|
||||
configuration.set("enchantments." + enchant.getKey().getKey() + ".name", enchant.getDisplayName());
|
||||
configuration.set("enchantments." + enchant.getKey().getKey() + ".description", enchant.getDescription());
|
||||
}
|
||||
|
||||
Paste paste = new Paste(configuration.saveToString());
|
||||
|
||||
sender.sendMessage(
|
||||
this.getPlugin().getLangYml().getMessage("link-to-locale").replace(
|
||||
"%url%",
|
||||
"https://hastebin.com/raw/" + paste.getHastebinToken()
|
||||
)
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@ messages:
|
||||
invalid-player: "&cInvalid Player!"
|
||||
requires-player: "&cRequires a Player!"
|
||||
must-hold-item-other: "&cPlayer is not holding an enchantable item!"
|
||||
link-to-locale: "The locale has been successfully exported! Get it here: %url%"
|
||||
|
||||
no-targets: "&cCannot be applied"
|
||||
no-conflicts: "&cNo conflicts"
|
||||
|
@ -58,6 +58,7 @@ permissions:
|
||||
ecoenchants.command.randomenchant: true
|
||||
ecoenchants.command.randomenchant.bypasshardcap: true
|
||||
ecoenchants.command.giverandombook: true
|
||||
ecoenchants.command.exportlocale: true
|
||||
ecoenchants.command.ecoenchants: true
|
||||
ecoenchants.fromtable.*:
|
||||
description: Allows getting all enchantments from an enchanting table
|
||||
@ -87,6 +88,9 @@ permissions:
|
||||
ecoenchants.command.randomenchant.bypasshardcap:
|
||||
description: Allows /ecoenchants randomenchant bypassing the anvil hard cap
|
||||
default: op
|
||||
ecoenchants.command.exportlocale:
|
||||
description: Allows the use of /ecoenchants exportlocale to export all language config to hastebin.
|
||||
default: op
|
||||
ecoenchants.command.ecoenchants:
|
||||
description: Allows the use of /ecoenchants
|
||||
default: true
|
||||
|
Loading…
Reference in New Issue
Block a user