Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. package fr.athos.endiumfight;
  2.  
  3. import org.spongepowered.api.data.DataTransactionResult;
  4. import org.spongepowered.api.entity.player.Player;
  5. import org.spongepowered.api.text.Texts;
  6. import org.spongepowered.api.util.command.CommandException;
  7. import org.spongepowered.api.util.command.CommandResult;
  8. import org.spongepowered.api.util.command.CommandSource;
  9. import org.spongepowered.api.util.command.args.CommandContext;
  10. import org.spongepowered.api.util.command.spec.CommandExecutor;
  11.  
  12. public class HealCommand implements CommandExecutor {
  13.  
  14. public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
  15. if (!(commandSource instanceof Player) && !commandContext.hasAny("target")) {
  16. commandSource.sendMessage(Texts.of("§8(§cParaFight§8) &6Pas d'utilisateur spécifié."));
  17. return CommandResult.builder().successCount(0).build();
  18. }
  19.  
  20. Player target;
  21.  
  22. if (commandContext.hasAny("target")) {
  23. target = commandContext.<Player>getOne("target").get();
  24. }
  25.  
  26. else {
  27. target = (Player) commandSource;
  28. }
  29.  
  30. DataTransactionResult res = target.offer(target.getHealthData().setHealth(target.getHealthData().getMaxHealth()));
  31.  
  32. if (res.getRejectedData().isPresent()) {
  33. commandSource.sendMessage(Texts.of("(§cParaFight§8) &6Données de heal rejetées."));
  34. return CommandResult.builder().successCount(0).build();
  35. }
  36.  
  37. target.sendMessage(Texts.of("(§cParaFight§8) &6Vous avez été heal par " + commandSource.getName()));
  38. commandSource.sendMessage(Texts.of("(§cParaFight§8) &6Vous avez heal " + target.getName()));
  39.  
  40. return CommandResult.success();
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement