use of org.cubeengine.butler.alias.Alias in project modules-extra by CubeEngine.
the class RulebookCommands method getRuleBook.
@Alias(value = { "getrules", "rules" })
@Command(desc = "gets the player the rulebook in the inventory")
public void getRuleBook(CommandSource context, @Optional String language, @Default @Named({ "player", "p" }) Player player) {
// console msg /wo player: i18n.sendTranslated(context, NEGATIVE, "The post office will give you your book!");
Locale locale;
if (!context.equals(player)) {
if (!context.hasPermission(getOtherPerm.getId())) {
i18n.send(context, NEGATIVE, "You do not have the permissions to add the rulebook to the inventory of an other player");
return;
}
}
if (this.rulebookManager.getLocales().isEmpty()) {
i18n.send(context, NEUTRAL, "It does not exist a rulebook yet");
return;
}
if (language != null) {
Language l = this.rulebookManager.getLanguage(language);
if (l == null) {
i18n.send(context, NEGATIVE, "Can't match the language");
return;
}
locale = l.getLocale();
if (!this.rulebookManager.contains(locale)) {
i18n.send(context, NEUTRAL, "The language {name} is not supported yet.", locale.getDisplayLanguage(context.getLocale()));
return;
}
} else {
locale = player.getLocale();
if (!this.rulebookManager.contains(locale)) {
locale = i18n.getDefaultLanguage().getLocale();
if (!this.rulebookManager.contains(locale)) {
locale = this.rulebookManager.getLocales().iterator().next();
}
}
}
Set<Inventory> books = this.inventoryRulebookSearching(player.getInventory(), locale);
for (Inventory book : books) {
book.clear();
}
player.getInventory().offer(this.rulebookManager.getBook(locale));
i18n.send(player, POSITIVE, "Lots of fun with your rulebook.");
if (!books.isEmpty()) {
i18n.send(player, POSITIVE, "Your old rulebook was removed");
}
}
use of org.cubeengine.butler.alias.Alias in project modules-extra by CubeEngine.
the class RulebookCommands method modify.
@Alias(value = "modifyrules")
@Command(desc = "modified the rulebook of the declared language with the book in hand")
public void modify(Player context, String language) {
ItemStack item = context.getItemInHand(MAIN_HAND).orElse(null);
if (item != null && !(item.getItem() == WRITABLE_BOOK || item.getItem() == WRITTEN_BOOK)) {
i18n.send(context, NEGATIVE, "I would try it with a book as item in hand");
return;
}
Language lang = this.rulebookManager.getLanguage(language);
if (lang == null) {
i18n.send(context, NEGATIVE, "More than one or no language is matched with {input}", language);
return;
}
Locale locale = lang.getLocale();
if (!this.rulebookManager.contains(locale)) {
i18n.send(context, NEGATIVE, "You can't modify a non-existent book.");
return;
}
try {
this.rulebookManager.removeBook(locale);
this.rulebookManager.addBook(item, locale);
i18n.send(context, POSITIVE, "The rulebook {name} was succesful modified.", locale.getDisplayLanguage(context.getLocale()));
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
}
use of org.cubeengine.butler.alias.Alias in project modules-extra by CubeEngine.
the class RulebookCommands method add.
@Alias(value = "addrules")
@Command(desc = "adds the book in hand as rulebook of the declared language")
public void add(Player context, String language) {
ItemStack item = context.getItemInHand(MAIN_HAND).orElse(null);
if (item != null && !(item.getItem() == WRITABLE_BOOK || item.getItem() == WRITTEN_BOOK)) {
i18n.send(context, NEGATIVE, "I would try it with a book as item in hand");
return;
}
Language lang = this.rulebookManager.getLanguage(language);
if (lang == null) {
i18n.send(context, NEGATIVE, "More than one or no language is matched with {input}", language);
return;
}
Locale locale = lang.getLocale();
if (this.rulebookManager.contains(locale)) {
i18n.send(context, NEUTRAL, "There is already a book in that language.");
return;
}
this.rulebookManager.addBook(item, locale);
i18n.send(context, POSITIVE, "Rulebook for the language {input} was added succesfully", lang.getLocale().getDisplayLanguage(context.getLocale()));
}
use of org.cubeengine.butler.alias.Alias in project modules-extra by CubeEngine.
the class RulebookCommands method remove.
@Alias(value = "removerules")
@Command(desc = "removes the declared language and languagefiles!")
public void remove(CommandSource context, String language) {
Language lang = this.rulebookManager.getLanguage(language);
if (lang == null) {
i18n.send(context, NEGATIVE, "More than one or no language is matched with {input}", language);
return;
}
if (!this.rulebookManager.contains(lang.getLocale())) {
i18n.send(context, POSITIVE, "The languagefile of {input} doesn't exist at the moment", lang.getLocale().getDisplayLanguage(context.getLocale()));
return;
}
try {
this.rulebookManager.removeBook(lang.getLocale());
i18n.send(context, POSITIVE, "The languagefiles of {input} was deleted", lang.getLocale().getDisplayLanguage(context.getLocale()));
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
}
use of org.cubeengine.butler.alias.Alias in project modules-extra by CubeEngine.
the class ShoutCommand method list.
@Alias(value = { "announcements" })
@Command(alias = "announcements", desc = "List all announcements")
public void list(CommandSource context) {
Collection<Announcement> list = this.module.getManager().getAllAnnouncements();
if (list.isEmpty()) {
i18n.send(context, NEGATIVE, "There are no announcements loaded!");
return;
}
i18n.send(context, POSITIVE, "Here is the list of announcements:");
for (Announcement announcement : list) {
context.sendMessage(Text.of(" - ", announcement.getName()));
}
}
Aggregations