Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set set = getLoadedSettings().entrySet();
- Iterator iterator = set.iterator();
- while (iterator.hasNext()) {
- final Map.Entry entry = (Map.Entry) iterator.next();
- final ModValue value = (ModValue) entry.getValue();
- if (value.getName().equalsIgnoreCase("N/A")
- || value.getName().replace(getName() + " ", "")
- .equalsIgnoreCase("N/A")
- || value.getName().contains("N/A"))
- continue;
- if (value.getValue() instanceof Boolean)
- getClient().getCommands().registerCommand(
- new Command(getName().replace(" ", "")
- .toLowerCase(), "."
- + getName().replace(" ", "").toLowerCase()
- + " <"
- + value.getName()
- .replace(getName() + " ", "")
- .replace(" ", "").toLowerCase()
- + ">", "Toggles the state for the "
- + value.getName() + ".") {
- @Override
- public void onCommand(final String message,
- final String... args) {
- if (args[0].equalsIgnoreCase(value
- .getName()
- .replace(getName() + " ", "")
- .replace(" ", "")))
- registerSetting(
- (Integer) entry.getKey(),
- (Object) !(Boolean) getSetting((Integer) entry
- .getKey()),
- value.getName().replace(
- getName() + " ", ""),
- 0.0D, true, true, true);
- getClient()
- .getPlayer()
- .addMessage(
- Colours.GREY
- + value.getName()
- + " has been set to "
- + Colours.PINK
- + getSetting((Integer) entry
- .getKey())
- + ".");
- }
- });
- if (value.getValue() instanceof Integer
- || value.getValue() instanceof Double
- || value.getValue() instanceof Long
- || value.getValue() instanceof Float)
- getClient().getCommands().registerCommand(
- new Command(getName().replace(" ", "")
- .toLowerCase(), "."
- + getName().replace(" ", "").toLowerCase()
- + " <"
- + value.getName()
- .replace(getName() + " ", "")
- .replace(" ", "").toLowerCase()
- + "> <value>", "Sets the value for the "
- + value.getName() + ".") {
- @Override
- public void onCommand(final String message,
- final String... args) {
- if (args[0].equalsIgnoreCase(value
- .getName()
- .replace(getName() + " ", "")
- .replace(" ", "").toLowerCase()))
- if (StringTools.isNumber(args[1])) {
- if (checkValues(
- Float.parseFloat(args[1]),
- 0.0F, value.getMax())) {
- setAmtInOptions(args[1]);
- getClient()
- .getPlayer()
- .addMessage(
- Colours.GREY
- + value.getName()
- + " has been set to "
- + Colours.PINK
- + args[1]
- + ".");
- } else
- getClient()
- .getPlayer()
- .addMessage(
- Colours.GREY
- + "Value is either to low or to high.");
- } else
- getClient()
- .getPlayer()
- .addMessage(
- Colours.GREY
- + "Please enter a number.");
- }
- public void setAmtInOptions(final Object obj) {
- try {
- if (getSetting((Integer) entry.getKey()) instanceof Double)
- registerSetting(
- (Integer) entry.getKey(),
- Double.parseDouble((String) obj),
- value.getName()
- .replace(
- getName()
- + " ",
- ""), value
- .getMax(), true,
- true, true);
- else if (getSetting((Integer) entry
- .getKey()) instanceof Float)
- registerSetting(
- (Integer) entry.getKey(),
- Float.parseFloat((String) obj),
- value.getName()
- .replace(
- getName()
- + " ",
- ""), value
- .getMax(), true,
- true, true);
- else if (getSetting((Integer) entry
- .getKey()) instanceof Integer)
- registerSetting(
- (Integer) entry.getKey(),
- Integer.parseInt((String) obj),
- value.getName()
- .replace(
- getName()
- + " ",
- ""), value
- .getMax(), true,
- true, true);
- else if (getSetting((Integer) entry
- .getKey()) instanceof Long)
- registerSetting(
- (Integer) entry.getKey(),
- Long.parseLong((String) obj),
- value.getName()
- .replace(
- getName()
- + " ",
- ""), value
- .getMax(), true,
- true, true);
- } catch (Exception e) {
- e.printStackTrace();
- return;
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement