Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ep_04.ep_04;
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- public class CommandsClass implements CommandExecutor {
- @Override
- public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
- if(command.getName().equalsIgnoreCase("healme")) {
- if (commandSender instanceof Player) {
- Player player = (Player) commandSender;
- if (args.length < 1) {
- player.sendMessage(ChatColor.RED + "Please include how much you want to be healed by.");
- return true;
- }
- else if (args.length == 1) {
- try {
- double phealth = player.getHealth();
- double addhealth = Double.parseDouble(args[0]);
- if (phealth < 20) {
- player.setHealth(phealth + addhealth);
- player.sendMessage(ChatColor.GRAY + "You has been healed for " + ChatColor.GREEN + addhealth + " health");
- return true;
- }
- else {
- player.sendMessage(ChatColor.YELLOW + "if you rake some damage ..... I heal you.");
- return true;
- }
- }
- catch (NumberFormatException e) {
- player.sendMessage(ChatColor.RED + "Place input a real number!");
- return true;
- }
- }
- }
- else {
- commandSender.sendMessage(ChatColor.RED + "Only players can execute this command.");
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement