mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-11 23:00:36 +01:00
Added locale downloading
This commit is contained in:
parent
6aea1a1e3d
commit
9bdc97143f
@ -18,7 +18,7 @@ public class CommandEcoEnchants extends PluginCommand {
|
||||
.addSubcommand(new CommandReload(plugin))
|
||||
.addSubcommand(new CommandGiverandombook(plugin))
|
||||
.addSubcommand(new CommandRandomenchant(plugin))
|
||||
.addSubcommand(new CommandExportLocale(plugin));
|
||||
.addSubcommand(new CommandLocale(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.willfp.ecoenchants.command;
|
||||
|
||||
import com.willfp.eco.core.command.CommandHandler;
|
||||
import com.willfp.eco.core.command.impl.Subcommand;
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CommandLocale extends Subcommand {
|
||||
/**
|
||||
* Instantiate a new /ecoenchants locale command handler.
|
||||
*
|
||||
* @param plugin The plugin for the commands to listen for.
|
||||
*/
|
||||
public CommandLocale(@NotNull final EcoEnchantsPlugin plugin) {
|
||||
super(plugin, "locale", "ecoenchants.command.locale", false);
|
||||
|
||||
this.addSubcommand(new CommandLocaleExport(plugin))
|
||||
.addSubcommand(new CommandLocaleDownload(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandHandler getHandler() {
|
||||
return (sender, args) -> {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-locale-subcommand"));
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
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 org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
public class CommandLocaleDownload extends Subcommand {
|
||||
/**
|
||||
* Instantiate a new /ecoenchants locale download command handler.
|
||||
*
|
||||
* @param plugin The plugin for the commands to listen for.
|
||||
*/
|
||||
public CommandLocaleDownload(@NotNull final EcoEnchantsPlugin plugin) {
|
||||
super(plugin, "download", "ecoenchants.command.locale.download", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandHandler getHandler() {
|
||||
return (sender, args) -> {
|
||||
if (args.size() == 0) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-locale"));
|
||||
}
|
||||
|
||||
Paste paste = Paste.getFromHastebin(args.get(0));
|
||||
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(new StringReader(paste.getContents()));
|
||||
|
||||
for (String key : configuration.getKeys(true)) {
|
||||
this.getPlugin().getLangYml().set(key, configuration.get(key));
|
||||
}
|
||||
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("downloaded-locale"));
|
||||
};
|
||||
}
|
||||
}
|
@ -11,14 +11,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
public class CommandExportLocale extends Subcommand {
|
||||
public class CommandLocaleExport extends Subcommand {
|
||||
/**
|
||||
* Instantiate a new /ecoenchants debug command handler.
|
||||
* Instantiate a new /ecoenchants locale export 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);
|
||||
public CommandLocaleExport(@NotNull final EcoEnchantsPlugin plugin) {
|
||||
super(plugin, "export", "ecoenchants.command.locale.export", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -34,8 +34,7 @@ public class CommandExportLocale extends Subcommand {
|
||||
|
||||
sender.sendMessage(
|
||||
this.getPlugin().getLangYml().getMessage("link-to-locale").replace(
|
||||
"%url%",
|
||||
"https://hastebin.com/raw/" + paste.getHastebinToken()
|
||||
"%token%", paste.getHastebinToken()
|
||||
)
|
||||
);
|
||||
};
|
@ -26,7 +26,10 @@ 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%"
|
||||
link-to-locale: "The locale has been successfully exported! Your token is: %token%"
|
||||
downloaded-locale: "Locale downloaded! Reload config to enact changes."
|
||||
invalid-locale: "&cYou must supply a valid locale! Check the wiki for more information."
|
||||
specify-locale-subcommand: "&cYou must specify whether to export or download a locale!"
|
||||
|
||||
no-targets: "&cCannot be applied"
|
||||
no-conflicts: "&cNo conflicts"
|
||||
|
@ -58,8 +58,15 @@ permissions:
|
||||
ecoenchants.command.randomenchant: true
|
||||
ecoenchants.command.randomenchant.bypasshardcap: true
|
||||
ecoenchants.command.giverandombook: true
|
||||
ecoenchants.command.exportlocale: true
|
||||
ecoenchants.command.locale.*: true
|
||||
ecoenchants.command.ecoenchants: true
|
||||
ecoenchants.command.locale.*:
|
||||
description: Allows managing locale features
|
||||
default: op
|
||||
children:
|
||||
ecoenchants.command.locale.download: true
|
||||
ecoenchants.command.locale.export: true
|
||||
ecoenchants.command.locale: true
|
||||
ecoenchants.fromtable.*:
|
||||
description: Allows getting all enchantments from an enchanting table
|
||||
default: true
|
||||
@ -88,8 +95,14 @@ 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.
|
||||
ecoenchants.command.locale:
|
||||
description: Allows the use of /ecoenchants locale to manage locale i18n
|
||||
default: op
|
||||
ecoenchants.command.locale.download:
|
||||
description: Allows the use of /ecoenchants locale download to download locales
|
||||
default: op
|
||||
ecoenchants.command.locale.export:
|
||||
description: Allows the use of /ecoenchants locale export to export locales
|
||||
default: op
|
||||
ecoenchants.command.ecoenchants:
|
||||
description: Allows the use of /ecoenchants
|
||||
|
Loading…
Reference in New Issue
Block a user