| 1 | package sh.okx.rankup.commands; | |
| 2 | ||
| 3 | import lombok.RequiredArgsConstructor; | |
| 4 | import org.bukkit.ChatColor; | |
| 5 | import org.bukkit.command.Command; | |
| 6 | import org.bukkit.command.CommandExecutor; | |
| 7 | import org.bukkit.command.CommandSender; | |
| 8 | import org.bukkit.configuration.file.FileConfiguration; | |
| 9 | import org.bukkit.entity.Player; | |
| 10 | import sh.okx.rankup.RankupPlugin; | |
| 11 | import sh.okx.rankup.gui.Gui; | |
| 12 | import sh.okx.rankup.messages.Message; | |
| 13 | import sh.okx.rankup.prestige.Prestige; | |
| 14 | import sh.okx.rankup.prestige.Prestiges; | |
| 15 | import sh.okx.rankup.ranks.Rank; | |
| 16 | import sh.okx.rankup.ranks.RankElement; | |
| 17 | ||
| 18 | import java.util.Map; | |
| 19 | import java.util.WeakHashMap; | |
| 20 | ||
| 21 | @RequiredArgsConstructor | |
| 22 | public class PrestigeCommand implements CommandExecutor { | |
| 23 | private final Map<Player, Long> confirming = new WeakHashMap<>(); | |
| 24 | private final RankupPlugin plugin; | |
| 25 | ||
| 26 | @Override | |
| 27 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | |
| 28 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (plugin.error(sender)) { |
| 29 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/PrestigeCommand::onCommand → NO_COVERAGE |
return true; |
| 30 | } | |
| 31 | ||
| 32 | // check if player | |
| 33 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (!(sender instanceof Player)) { |
| 34 |
1
1. onCommand : replaced boolean return with true for sh/okx/rankup/commands/PrestigeCommand::onCommand → NO_COVERAGE |
return false; |
| 35 | } | |
| 36 | Player player = (Player) sender; | |
| 37 | ||
| 38 | Prestiges prestiges = plugin.getPrestiges(); | |
| 39 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (!plugin.getHelper().checkPrestige(player)) { |
| 40 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/PrestigeCommand::onCommand → NO_COVERAGE |
return true; |
| 41 | } | |
| 42 | RankElement<Prestige> rankElement = prestiges.getByPlayer(player); | |
| 43 | Prestige prestige = rankElement.getRank(); | |
| 44 | ||
| 45 | FileConfiguration config = plugin.getConfig(); | |
| 46 | String confirmationType = config.getString("confirmation-type").toLowerCase(); | |
| 47 |
2
1. onCommand : negated conditional → NO_COVERAGE 2. onCommand : negated conditional → NO_COVERAGE |
if (confirmationType.equals("text") && confirming.containsKey(player)) { |
| 48 |
1
1. onCommand : Replaced long subtraction with addition → NO_COVERAGE |
long time = System.currentTimeMillis() - confirming.remove(player); |
| 49 |
3
1. onCommand : changed conditional boundary → NO_COVERAGE 2. onCommand : Replaced integer multiplication with division → NO_COVERAGE 3. onCommand : negated conditional → NO_COVERAGE |
if (time < config.getInt("text.timeout") * 1000) { |
| 50 |
1
1. onCommand : removed call to sh/okx/rankup/RankupHelper::prestige → NO_COVERAGE |
plugin.getHelper().prestige(player); |
| 51 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/PrestigeCommand::onCommand → NO_COVERAGE |
return true; |
| 52 | } | |
| 53 | } | |
| 54 | ||
| 55 | switch (confirmationType) { | |
| 56 | case "text": | |
| 57 | confirming.put(player, System.currentTimeMillis()); | |
| 58 | Prestige next = rankElement.getNext().getRank(); | |
| 59 |
1
1. onCommand : negated conditional → NO_COVERAGE |
Rank nextRank = next == null ? prestiges.getTree().last().getRank() : next; |
| 60 | ||
| 61 | plugin.getMessage(prestige, Message.PRESTIGE_CONFIRMATION) | |
| 62 | .replacePlayer(player) | |
| 63 | .replaceOldRank(prestige) | |
| 64 | .replaceRank(nextRank) | |
| 65 |
1
1. onCommand : removed call to sh/okx/rankup/messages/MessageBuilder::send → NO_COVERAGE |
.send(player); |
| 66 | break; | |
| 67 | case "gui": | |
| 68 | Gui gui = Gui.of(player, prestige, rankElement.getNext().getRank(), plugin, false); | |
| 69 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (gui == null) { |
| 70 |
1
1. onCommand : removed call to org/bukkit/entity/Player::sendMessage → NO_COVERAGE |
player.sendMessage(ChatColor.RED + "GUI is not available. Check console for more information."); |
| 71 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/PrestigeCommand::onCommand → NO_COVERAGE |
return true; |
| 72 | } | |
| 73 |
1
1. onCommand : removed call to sh/okx/rankup/gui/Gui::open → NO_COVERAGE |
gui.open(player); |
| 74 | break; | |
| 75 | case "none": | |
| 76 |
1
1. onCommand : removed call to sh/okx/rankup/RankupHelper::prestige → NO_COVERAGE |
plugin.getHelper().prestige(player); |
| 77 | break; | |
| 78 | default: | |
| 79 | throw new IllegalArgumentException("Invalid confirmation type " + confirmationType); | |
| 80 | } | |
| 81 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/PrestigeCommand::onCommand → NO_COVERAGE |
return true; |
| 82 | } | |
| 83 | } | |
Mutations | ||
| 28 |
1.1 |
|
| 29 |
1.1 |
|
| 33 |
1.1 |
|
| 34 |
1.1 |
|
| 39 |
1.1 |
|
| 40 |
1.1 |
|
| 47 |
1.1 2.2 |
|
| 48 |
1.1 |
|
| 49 |
1.1 2.2 3.3 |
|
| 50 |
1.1 |
|
| 51 |
1.1 |
|
| 59 |
1.1 |
|
| 65 |
1.1 |
|
| 69 |
1.1 |
|
| 70 |
1.1 |
|
| 71 |
1.1 |
|
| 73 |
1.1 |
|
| 76 |
1.1 |
|
| 81 |
1.1 |