use of org.cubeengine.butler.parametric.Command 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.parametric.Command 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.parametric.Command 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.parametric.Command in project modules-extra by CubeEngine.
the class IgnoreCommands method unignore.
@Command(desc = "Stops ignoring all messages from a player")
@Restricted(value = Player.class, msg = "Congratulations! You are now looking at this text!")
public void unignore(Player context, List<User> players) {
List<String> added = new ArrayList<>();
for (User user : players) {
if (!this.removeIgnore(context, user)) {
i18n.send(context, NEGATIVE, "You haven't ignored {user}!", user);
} else {
added.add(user.getName());
}
}
if (added.isEmpty()) {
return;
}
i18n.send(context, POSITIVE, "You removed {user#list} from your ignore list!", StringUtils.implode(ChatFormat.WHITE + ", " + ChatFormat.DARK_GREEN, added));
}
use of org.cubeengine.butler.parametric.Command in project modules-extra by CubeEngine.
the class EditModeCommand method stock.
@Command(desc = "Changes whether the sign has stock")
public void stock(Player context) {
MarketSignData data = manager.getCurrentData(context);
if (data == null) {
i18n.send(context, NEGATIVE, "No active sign!");
return;
}
if (!data.isAdminOwner()) {
i18n.send(context, NEGATIVE, "Player signs cannot have no stock!");
return;
}
if (data.getStock() == null) {
data.setStock(0);
} else {
data.setStock(null);
}
Location<World> loc = manager.updateData(data, context);
manager.executeShowInfo(data, context, loc);
}
Aggregations