@Override public CommandResult process(CommandSource sender, String arguments) throws CommandException { String[] args = arguments.split(" "); if (!PermissionsUtils.has(sender, "core.heal")) { sender.sendMessage( Text.builder("You do not have permissions!").color(TextColors.RED).build()); return CommandResult.success(); } if (args.length > 1) { sender.sendMessage(Text.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/heal [player]")); return CommandResult.success(); } if (arguments.equalsIgnoreCase("")) { if (sender instanceof Player == false) { sender.sendMessage( Text.builder("Cannot be run by the console!").color(TextColors.RED).build()); return CommandResult.success(); } Player p = (Player) sender; double max = p.get(Keys.MAX_HEALTH).get(); p.offer(Keys.HEALTH, max); sender.sendMessage(Text.of(TextColors.YELLOW, "You ", TextColors.GRAY, "have been healed.")); } else if (args.length == 1) { if (!PermissionsUtils.has(sender, "core.heal-others")) { sender.sendMessage( Text.builder("You do not have permissions to heal other players!") .color(TextColors.RED) .build()); return CommandResult.success(); } Player p = ServerUtils.getPlayer(args[0]); if (p == null) { sender.sendMessage(Text.builder("Player not found!").color(TextColors.RED).build()); return CommandResult.success(); } double max = p.get(Keys.MAX_HEALTH).get(); p.offer(Keys.HEALTH, max); sender.sendMessage( Text.of(TextColors.YELLOW, p.getName(), TextColors.GRAY, " has been healed.")); p.sendMessage( Text.of( TextColors.GRAY, "You have been healed by ", TextColors.YELLOW, sender.getName())); } return CommandResult.success(); }
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { Optional<Player> p = ctx.<Player>getOne("player"); if (src instanceof Player) { Player player = (Player) src; if (player.hasPermission("heal.others") && p.isPresent()) { Player recipient = p.get(); recipient.offer(Keys.HEALTH, player.get(Keys.MAX_HEALTH).get()); recipient.sendMessage( Texts.of( TextColors.GREEN, "Success: ", TextColors.YELLOW, "You've been healed by " + player.getName())); src.sendMessage( Texts.of( TextColors.GREEN, "Success: ", TextColors.YELLOW, "You've healed " + recipient.getName())); } else if (p.isPresent()) { player.sendMessage( Texts.of( TextColors.DARK_RED, "Error! ", TextColors.RED, "You do not have permission to heal other players!")); } else { player.offer(Keys.HEALTH, player.get(Keys.MAX_HEALTH).get()); src.sendMessage( Texts.of(TextColors.GREEN, "Success: ", TextColors.YELLOW, "You've been healed.")); } } else if (src instanceof ConsoleSource) { src.sendMessage( Texts.of( TextColors.DARK_RED, "Error! ", TextColors.RED, "Must be an in-game player to use /heal!")); } else if (src instanceof CommandBlockSource) { src.sendMessage( Texts.of( TextColors.DARK_RED, "Error! ", TextColors.RED, "Must be an in-game player to use /heal!")); } return CommandResult.success(); }
@Override public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { int expLevel = ctx.<Integer>getOne("exp").get(); Player player = ctx.<Player>getOne("target").get(); player.offer(Keys.TOTAL_EXPERIENCE, player.get(Keys.TOTAL_EXPERIENCE).get() - expLevel); src.sendMessage( Text.of( TextColors.GREEN, "Success! ", TextColors.YELLOW, "Took " + expLevel + " experience from " + player.getName() + ".")); return CommandResult.success(); }
@Listener public void onStart(MinigameStartedEvent event) { if (event.getMinigame().equals(this)) { for (Player player : players()) { player.sendMessage( Text.of( TextColors.BLUE, "[UltimateGames]: ", TextColors.GREEN, "Deathmatch starting...")); } for (Player player : this.teamA) { player.offer(Keys.GAME_MODE, GameModes.SURVIVAL); player.setScoreboard(scoreboard); this.teamAScoreboardTeam.addMember(player.getTeamRepresentation()); if (this.arena.getTeamALoadout() != null) UltimateGames.game .getCommandManager() .process( Sponge.getServer().getConsole(), "kit " + this.arena.getTeamALoadout() + " " + player.getName()); if (player .getWorld() .getUniqueId() .equals(this.arena.getTeamASpawn().getLocation().getExtent().getUniqueId())) { player.setLocation(this.arena.getTeamASpawn().getLocation()); } else { player.transferToWorld( this.arena.getTeamASpawn().getLocation().getExtent().getUniqueId(), this.arena.getTeamASpawn().getLocation().getPosition()); } player.sendMessage( Text.of(TextColors.BLUE, "[UltimateGames]: ", TextColors.GOLD, "May the games begin!")); } for (Player player : this.teamB) { player.offer(Keys.GAME_MODE, GameModes.SURVIVAL); player.setScoreboard(scoreboard); this.teamBScoreboardTeam.addMember(player.getTeamRepresentation()); if (this.arena.getTeamBLoadout() != null) UltimateGames.game .getCommandManager() .process( Sponge.getServer().getConsole(), "kit " + this.arena.getTeamBLoadout() + " " + player.getName()); if (player .getWorld() .getUniqueId() .equals(this.arena.getTeamBSpawn().getLocation().getExtent().getUniqueId())) { player.setLocation(this.arena.getTeamBSpawn().getLocation()); } else { player.transferToWorld( this.arena.getTeamBSpawn().getLocation().getExtent().getUniqueId(), this.arena.getTeamBSpawn().getLocation().getPosition()); } player.sendMessage( Text.of(TextColors.BLUE, "[UltimateGames]: ", TextColors.GOLD, "May the games begin!")); } Scheduler scheduler = UltimateGames.game.getScheduler(); Task.Builder taskBuilder = scheduler.createTaskBuilder(); taskBuilder .execute( () -> { try { Ember.unregister(this.arena); } catch (Exception e) { System.out.println( "[UltimateGames]: Error when ending deathmatch in arena " + arena.getName()); } }) .delay(this.arena.getLength(), TimeUnit.MINUTES) .name("UltimateGames - End Deathmatch") .submit( UltimateGames.game .getPluginManager() .getPlugin("io.github.hsyyid.ultimategames") .get() .getInstance() .get()); } }