3 months ago
2

Easy payements

It is so much easy to pay money, but why not make it easier?
Why dont we instead of paying 100k, by typing /pay ... 100000 , why not make it /pay ... 100k?
for 1milion, why not make it /pay ... 1m ?
This will be so much easier to do payements, and it wont take a minute to add to the server codes.
It is a really easy java script code, Im a programmer , so here is the code, just add it to the server:
long amount = Long.parseLong(input.toLowerCase().replace("k", "000").replace("m", "000000"));
String input = args[1]; // example: "10m"
long amount = Long.parseLong(input.toLowerCase()
.replace("k", "000")
.replace("m", "000000"));
If your using kotlin,

Since you have a similiar code, similiar to:
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class PayCommand implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

if (!(sender instanceof Player)) {
sender.sendMessage("Only players can use this command.");
return true;
}

Player player = (Player) sender;

if (args.length != 2) {
player.sendMessage("§cUsage: /pay <player> <amount>");
return true;
}

Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
player.sendMessage("§cThat player is not online.");
return true;
}
catch (NumberFormatException e) {
player.sendMessage("§cInvalid amount.");
return true;
}

if (amount <= 0) {
player.sendMessage("§cAmount must be positive.");
return true;
}
You can just add the code I sent above for java, it will become something like:
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class PayCommand implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

if (!(sender instanceof Player)) {
sender.sendMessage("Only players can use this command.");
return true;
}

Player player = (Player) sender;

if (args.length != 2) {
player.sendMessage("§cUsage: /pay <player> <amount>");
return true;
}

Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
player.sendMessage("§cThat player is not online.");
return true;
}

String input = args[1].toLowerCase();

long amount;
try {
amount = Long.parseLong(
input.replace("k", "000")
.replace("m", "000000")
);
} catch (NumberFormatException e) {
player.sendMessage("§cInvalid amount.");
return true;
}

if (amount <= 0) {
player.sendMessage("§cAmount must be positive.");
return true;
}

player.sendMessage("§aYou paid §e" + target.getName() + " §a$" + amount);
target.sendMessage("§aYou received §e$" + amount + " §afrom §e" + player.getName());

return true;
}
}
Posted in Commands for GLOBAL, status replied, Upvotes: 2, Downvotes: 0