Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.athos.endiumfight;
- import org.spongepowered.api.data.DataTransactionResult;
- import org.spongepowered.api.entity.player.Player;
- import org.spongepowered.api.text.Texts;
- import org.spongepowered.api.util.command.CommandException;
- import org.spongepowered.api.util.command.CommandResult;
- import org.spongepowered.api.util.command.CommandSource;
- import org.spongepowered.api.util.command.args.CommandContext;
- import org.spongepowered.api.util.command.spec.CommandExecutor;
- public class HealCommand implements CommandExecutor {
- public CommandResult execute(CommandSource commandSource, CommandContext commandContext) throws CommandException {
- if (!(commandSource instanceof Player) && !commandContext.hasAny("target")) {
- commandSource.sendMessage(Texts.of("§8(§cParaFight§8) &6Pas d'utilisateur spécifié."));
- return CommandResult.builder().successCount(0).build();
- }
- Player target;
- if (commandContext.hasAny("target")) {
- target = commandContext.<Player>getOne("target").get();
- }
- else {
- target = (Player) commandSource;
- }
- DataTransactionResult res = target.offer(target.getHealthData().setHealth(target.getHealthData().getMaxHealth()));
- if (res.getRejectedData().isPresent()) {
- commandSource.sendMessage(Texts.of("(§cParaFight§8) &6Données de heal rejetées."));
- return CommandResult.builder().successCount(0).build();
- }
- target.sendMessage(Texts.of("(§cParaFight§8) &6Vous avez été heal par " + commandSource.getName()));
- commandSource.sendMessage(Texts.of("(§cParaFight§8) &6Vous avez heal " + target.getName()));
- return CommandResult.success();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement