45 lines
1.3 KiB
Java
45 lines
1.3 KiB
Java
package net.knarcraft.timeismoney.command;
|
|
|
|
import net.knarcraft.timeismoney.config.Configuration;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandExecutor;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
/**
|
|
* A command for overriding payments for specific groups
|
|
*/
|
|
public class SetGroupPaymentCommand implements CommandExecutor {
|
|
|
|
private final Configuration configuration;
|
|
|
|
/**
|
|
* Instantiates a new set group payment command
|
|
*
|
|
* @param configuration <p>The configuration to use</p>
|
|
*/
|
|
public SetGroupPaymentCommand(@NotNull Configuration configuration) {
|
|
this.configuration = configuration;
|
|
}
|
|
|
|
@Override
|
|
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
|
|
@NotNull String[] arguments) {
|
|
if (arguments.length < 2) {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
String group = arguments[0];
|
|
Double payout = Double.parseDouble(arguments[1]);
|
|
configuration.setGroupPayout(group, payout);
|
|
configuration.save();
|
|
return true;
|
|
} catch (NumberFormatException exception) {
|
|
commandSender.sendMessage("Payout must be a number");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|