1 | package sh.okx.rankup.commands; | |
2 | ||
3 | import java.util.ArrayList; | |
4 | import java.util.Collections; | |
5 | import java.util.HashSet; | |
6 | import java.util.List; | |
7 | import java.util.Set; | |
8 | import org.bukkit.Bukkit; | |
9 | import org.bukkit.ChatColor; | |
10 | import org.bukkit.Statistic; | |
11 | import org.bukkit.command.Command; | |
12 | import org.bukkit.command.CommandSender; | |
13 | import org.bukkit.command.TabExecutor; | |
14 | import org.bukkit.entity.Player; | |
15 | import org.bukkit.plugin.PluginDescriptionFile; | |
16 | import org.bukkit.util.StringUtil; | |
17 | import org.jetbrains.annotations.NotNull; | |
18 | import org.jetbrains.annotations.Nullable; | |
19 | import sh.okx.rankup.RankupPlugin; | |
20 | import sh.okx.rankup.prestige.Prestige; | |
21 | import sh.okx.rankup.prestige.Prestiges; | |
22 | import sh.okx.rankup.ranks.Rank; | |
23 | import sh.okx.rankup.ranks.RankElement; | |
24 | import sh.okx.rankup.ranks.Rankups; | |
25 | import sh.okx.rankup.util.UpdateNotifier; | |
26 | ||
27 | public class InfoCommand implements TabExecutor { | |
28 | private final RankupPlugin plugin; | |
29 | ||
30 | private final UpdateNotifier notifier; | |
31 | ||
32 | public InfoCommand(RankupPlugin plugin, UpdateNotifier notifier) { | |
33 | this.plugin = plugin; | |
34 | this.notifier = notifier; | |
35 | } | |
36 | ||
37 | @Override | |
38 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | |
39 |
2
1. onCommand : changed conditional boundary → SURVIVED 2. onCommand : negated conditional → KILLED |
if (args.length > 0) { |
40 |
2
1. onCommand : negated conditional → SURVIVED 2. onCommand : negated conditional → NO_COVERAGE |
if (args[0].equalsIgnoreCase("reload") && sender.hasPermission("rankup.reload")) { |
41 |
1
1. onCommand : removed call to sh/okx/rankup/RankupPlugin::reload → NO_COVERAGE |
plugin.reload(false); |
42 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (!plugin.error(sender)) { |
43 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "Rankup " + ChatColor.YELLOW + "Reloaded configuration files."); |
44 | } | |
45 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
46 |
2
1. onCommand : negated conditional → KILLED 2. onCommand : negated conditional → KILLED |
} else if (args[0].equalsIgnoreCase("forcerankup") && sender.hasPermission("rankup.force")) { |
47 |
2
1. onCommand : changed conditional boundary → KILLED 2. onCommand : negated conditional → KILLED |
if (args.length < 2) { |
48 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "Usage: /" + label + " forcerankup <player>"); |
49 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
50 | } | |
51 | ||
52 | Player player = Bukkit.getPlayer(args[1]); | |
53 |
1
1. onCommand : negated conditional → KILLED |
if (player == null) { |
54 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "Player not found."); |
55 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
56 | } | |
57 | ||
58 | Rankups rankups = plugin.getRankups(); | |
59 | RankElement<Rank> rankElement = rankups.getByPlayer(player); | |
60 |
1
1. onCommand : negated conditional → KILLED |
if (rankElement == null) { |
61 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "That player is not in any rankup groups."); |
62 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
63 |
1
1. onCommand : negated conditional → KILLED |
} else if (!rankElement.hasNext()) { |
64 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "That player is at the last rank."); |
65 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
66 | } | |
67 | ||
68 | Rank rank = rankElement.getRank(); | |
69 | ||
70 |
1
1. onCommand : removed call to sh/okx/rankup/RankupHelper::doRankup → KILLED |
plugin.getHelper().doRankup(player, rankElement); |
71 |
1
1. onCommand : removed call to sh/okx/rankup/RankupHelper::sendRankupMessages → SURVIVED |
plugin.getHelper().sendRankupMessages(player, rankElement); |
72 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → SURVIVED |
sender.sendMessage(ChatColor.GREEN + "Successfully forced " |
73 | + ChatColor.GOLD + player.getName() | |
74 | + ChatColor.GREEN + " to rankup from " + ChatColor.GOLD + rank.getRank() | |
75 | + ChatColor.GREEN + " to " + ChatColor.GOLD + rank.getNext()); | |
76 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → SURVIVED |
return true; |
77 |
2
1. onCommand : negated conditional → SURVIVED 2. onCommand : negated conditional → NO_COVERAGE |
} else if (args[0].equalsIgnoreCase("forceprestige") && sender.hasPermission("rankup.force")) { |
78 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (plugin.getPrestiges() == null) { |
79 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.RED + "Prestige is disabled."); |
80 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
81 | } | |
82 | ||
83 |
2
1. onCommand : changed conditional boundary → NO_COVERAGE 2. onCommand : negated conditional → NO_COVERAGE |
if (args.length < 2) { |
84 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "Usage: /" + label + " forceprestige <player>"); |
85 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
86 | } | |
87 | ||
88 | Player player = Bukkit.getPlayer(args[1]); | |
89 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (player == null) { |
90 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "Player not found."); |
91 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
92 | } | |
93 | ||
94 | Prestiges prestiges = plugin.getPrestiges(); | |
95 | RankElement<Prestige> rankElement = prestiges.getByPlayer(player); | |
96 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (!rankElement.hasNext()) { |
97 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "That player is at the last prestige."); |
98 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
99 | } | |
100 | ||
101 | Prestige prestige = rankElement.getRank(); | |
102 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (prestige == null) { |
103 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "That player is not in any prestige groups."); |
104 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
105 | } | |
106 | ||
107 |
1
1. onCommand : removed call to sh/okx/rankup/RankupHelper::doPrestige → NO_COVERAGE |
plugin.getHelper().doPrestige(player, rankElement); |
108 |
1
1. onCommand : removed call to sh/okx/rankup/RankupHelper::sendPrestigeMessages → NO_COVERAGE |
plugin.getHelper().sendPrestigeMessages(player, rankElement); |
109 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GREEN + "Successfully forced " |
110 | + ChatColor.GOLD + player.getName() | |
111 | + ChatColor.GREEN + " to prestige " | |
112 | + ChatColor.GOLD + prestige.getRank() | |
113 | + ChatColor.GREEN + " from " + ChatColor.GOLD + prestige.getFrom() | |
114 | + ChatColor.GREEN + " to " + ChatColor.GOLD + prestige.getTo()); | |
115 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
116 |
2
1. onCommand : negated conditional → SURVIVED 2. onCommand : negated conditional → NO_COVERAGE |
} else if(args[0].equalsIgnoreCase("rankdown") && sender.hasPermission("rankup.force")) { |
117 |
2
1. onCommand : changed conditional boundary → NO_COVERAGE 2. onCommand : negated conditional → NO_COVERAGE |
if (args.length < 2) { |
118 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "Usage: /" + label + " rankdown <player>"); |
119 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
120 | } | |
121 | ||
122 | Player player = Bukkit.getPlayer(args[1]); | |
123 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (player == null) { |
124 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "Player not found."); |
125 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
126 | } | |
127 | ||
128 | RankElement<Rank> currentRankElement = plugin.getRankups().getByPlayer(player); | |
129 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (currentRankElement == null) { |
130 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "That player is not in any rankup groups."); |
131 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
132 | } | |
133 | Rank currentRank = currentRankElement.getRank(); | |
134 | ||
135 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (currentRankElement.isRootNode()) { |
136 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "That player is in the first rank and cannot be ranked down."); |
137 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
138 | } | |
139 | ||
140 | RankElement<Rank> prevRankElement = plugin.getRankups().getTree().getFirst(); | |
141 |
2
1. onCommand : negated conditional → NO_COVERAGE 2. onCommand : negated conditional → NO_COVERAGE |
while(prevRankElement.hasNext() && !prevRankElement.getNext().getRank().equals(currentRank)) { |
142 | prevRankElement = prevRankElement.getNext(); | |
143 | } | |
144 | ||
145 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (!prevRankElement.hasNext()) { |
146 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.YELLOW + "Could not match previous rank."); |
147 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
148 | } | |
149 | Rank prevRank = prevRankElement.getRank(); | |
150 | ||
151 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (prevRankElement.getRank() != null) { |
152 |
1
1. onCommand : removed call to sh/okx/rankup/hook/GroupProvider::removeGroup → NO_COVERAGE |
plugin.getPermissions().removeGroup(player.getUniqueId(), currentRank.getRank()); |
153 | } | |
154 |
1
1. onCommand : removed call to sh/okx/rankup/hook/GroupProvider::addGroup → NO_COVERAGE |
plugin.getPermissions().addGroup(player.getUniqueId(), prevRank.getRank()); |
155 | ||
156 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GREEN + "Successfully forced " |
157 | + ChatColor.GOLD + player.getName() | |
158 | + ChatColor.GREEN + " to rank down from " + ChatColor.GOLD + currentRank.getRank() | |
159 | + ChatColor.GREEN + " to " + ChatColor.GOLD + prevRank.getRank()); | |
160 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
161 |
2
1. onCommand : negated conditional → KILLED 2. onCommand : negated conditional → KILLED |
} else if (args[0].equalsIgnoreCase("placeholders") && sender.hasPermission("rankup.admin")) { |
162 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → KILLED |
sender.sendMessage("--- Rankup placeholders ---"); |
163 |
3
1. onCommand : negated conditional → NO_COVERAGE 2. onCommand : changed conditional boundary → KILLED 3. onCommand : negated conditional → KILLED |
if (args.length > 1 && args[1].equalsIgnoreCase("status")) { |
164 | for (Rank rank : plugin.getRankups().getTree()) { | |
165 | String placeholder = "status_" + rank.getRank(); | |
166 |
2
1. onCommand : negated conditional → NO_COVERAGE 2. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(placeholder + ": " + plugin.getPlaceholders().getExpansion().placeholder(sender instanceof Player ? (Player) sender : null, placeholder)); |
167 | } | |
168 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
169 | } | |
170 | ||
171 | String[] placeholders = new String[] { | |
172 | "prestige_money_formatted", | |
173 | "prestige_percent_left_formatted", | |
174 | "prestige_percent_done_formatted", | |
175 | "money_formatted", | |
176 | "money_left_formatted", | |
177 | "percent_left_formatted", | |
178 | "percent_done_formatted", | |
179 | "current_prestige", | |
180 | "next_prestige", | |
181 | "current_rank", | |
182 | "next_rank", | |
183 | }; | |
184 | for (String placeholder : placeholders) { | |
185 | String result; | |
186 | try { | |
187 |
1
1. onCommand : negated conditional → SURVIVED |
result = plugin.getPlaceholders().getExpansion().placeholder(sender instanceof Player ? (Player) sender : null, placeholder); |
188 | } catch (Exception e) { | |
189 | result = e.getClass().getSimpleName() + ", " + e.getMessage(); | |
190 | } | |
191 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → SURVIVED |
sender.sendMessage(placeholder + ": " + result); |
192 | } | |
193 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → SURVIVED |
return true; |
194 |
2
1. onCommand : negated conditional → SURVIVED 2. onCommand : negated conditional → NO_COVERAGE |
} else if (args[0].equalsIgnoreCase("tree") && sender.hasPermission("rankup.admin")) { |
195 | RankElement<Rank> element = plugin.getRankups().getTree().getFirst(); | |
196 |
1
1. onCommand : negated conditional → NO_COVERAGE |
while (element.hasNext()) { |
197 | Rank rank = element.getRank(); | |
198 | RankElement<Rank> next = element.getNext(); | |
199 | Rank nextRank = next.getRank(); | |
200 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(rank.getRank() + " (" + rank.getNext() + ") -> " + nextRank.getRank() + " (" + nextRank.getNext() + ")"); |
201 | element = next; | |
202 | } | |
203 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
204 |
3
1. onCommand : negated conditional → KILLED 2. onCommand : negated conditional → KILLED 3. onCommand : negated conditional → KILLED |
} else if (args[0].equalsIgnoreCase("playtime") && (sender.hasPermission("rankup.playtime.get") || sender.hasPermission("rankup.playtime"))) { |
205 | Statistic playOneTick; | |
206 | try { | |
207 | playOneTick = Statistic.valueOf("PLAY_ONE_MINUTE"); | |
208 | } catch (IllegalArgumentException e) { | |
209 | // statistic was changed in 1.13. | |
210 | playOneTick = Statistic.valueOf("PLAY_ONE_TICK"); | |
211 | } | |
212 | ||
213 |
2
1. onCommand : changed conditional boundary → SURVIVED 2. onCommand : negated conditional → KILLED |
if (args.length > 1) { |
214 |
2
1. onCommand : negated conditional → KILLED 2. onCommand : negated conditional → KILLED |
if (args[1].equalsIgnoreCase("get") && sender.hasPermission("rankup.playtime.get")) { |
215 | Player player; | |
216 |
2
1. onCommand : changed conditional boundary → SURVIVED 2. onCommand : negated conditional → SURVIVED |
if (args.length > 2) { |
217 | // pru playtime get Okx | |
218 | player = Bukkit.getPlayer(args[2]); | |
219 |
1
1. onCommand : negated conditional → KILLED |
if (player == null) { |
220 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GRAY + "Player not found"); |
221 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
222 | } | |
223 | } else { | |
224 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (sender instanceof Player) { |
225 | player = (Player) sender; | |
226 | } else { | |
227 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GREEN + "/" + label + " " + args[0] + " get [player] " + ChatColor.YELLOW |
228 | + " Get amount of minutes played"); | |
229 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
230 | } | |
231 | } | |
232 | ||
233 | int ticks = player.getStatistic(playOneTick); | |
234 |
2
1. onCommand : Replaced double division with multiplication → KILLED 2. onCommand : Replaced double division with multiplication → KILLED |
long minutes = (long) (ticks / 20D / 60); |
235 | ||
236 | String who; | |
237 |
1
1. onCommand : negated conditional → KILLED |
if (player == sender) { |
238 | who = "You have"; | |
239 | } else { | |
240 | who = player.getName() + " has"; | |
241 | } | |
242 |
1
1. onCommand : removed call to org/bukkit/entity/Player::sendMessage → KILLED |
player.sendMessage(ChatColor.LIGHT_PURPLE + who + " played for " + minutes + " minutes."); |
243 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → SURVIVED |
return true; |
244 |
2
1. onCommand : negated conditional → KILLED 2. onCommand : negated conditional → KILLED |
} else if (args[1].equalsIgnoreCase("set") && sender.hasPermission("rankup.playtime")) { |
245 |
2
1. onCommand : changed conditional boundary → KILLED 2. onCommand : negated conditional → KILLED |
if (args.length < 4) { |
246 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GREEN + "/" + label + " " + args[0] + " set <player> <minutes>" + ChatColor.YELLOW + " Update the playtime statistic for a player"); |
247 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
248 | } | |
249 | ||
250 | Player player = Bukkit.getPlayer(args[2]); | |
251 |
1
1. onCommand : negated conditional → KILLED |
if (player == null) { |
252 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GRAY + "Player not found"); |
253 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
254 | } | |
255 | ||
256 | int minutes; | |
257 | try { | |
258 | minutes = Integer.parseInt(args[3]); | |
259 | } catch (NumberFormatException e) { | |
260 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GRAY + "Invalid number: " + args[3]); |
261 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
262 | } | |
263 | ||
264 |
3
1. onCommand : Replaced integer multiplication with division → KILLED 2. onCommand : Replaced integer multiplication with division → KILLED 3. onCommand : removed call to org/bukkit/entity/Player::setStatistic → KILLED |
player.setStatistic(playOneTick, minutes * 20 * 60); |
265 |
1
1. onCommand : removed call to org/bukkit/entity/Player::sendMessage → SURVIVED |
player.sendMessage(ChatColor.LIGHT_PURPLE + "Updated playtime for " + player.getName() + " to " + minutes + " minutes"); |
266 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → SURVIVED |
return true; |
267 |
2
1. onCommand : negated conditional → KILLED 2. onCommand : negated conditional → KILLED |
} else if (args[1].equalsIgnoreCase("add") && sender.hasPermission("rankup.playtime")) { |
268 |
2
1. onCommand : changed conditional boundary → KILLED 2. onCommand : negated conditional → KILLED |
if (args.length < 4) { |
269 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GREEN + "/" + label + " " + args[0] + " add <player> <minutes>" + ChatColor.YELLOW + " Increase the playtime statistic for a player"); |
270 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
271 | } | |
272 | ||
273 | Player player = Bukkit.getPlayer(args[2]); | |
274 |
1
1. onCommand : negated conditional → KILLED |
if (player == null) { |
275 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GRAY + "Player not found"); |
276 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
277 | } | |
278 | ||
279 | int minutes; | |
280 | try { | |
281 | minutes = Integer.parseInt(args[3]); | |
282 | } catch (NumberFormatException e) { | |
283 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GRAY + "Invalid number: " + args[3]); |
284 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
285 | } | |
286 | ||
287 |
2
1. onCommand : Replaced integer division with multiplication → SURVIVED 2. onCommand : Replaced integer division with multiplication → SURVIVED |
int oldMinutes = player.getStatistic(playOneTick) / 20 / 60; |
288 |
2
1. onCommand : changed conditional boundary → SURVIVED 2. onCommand : negated conditional → KILLED |
if (minutes > 0) { |
289 |
3
1. onCommand : Replaced integer multiplication with division → KILLED 2. onCommand : Replaced integer multiplication with division → KILLED 3. onCommand : removed call to org/bukkit/entity/Player::incrementStatistic → KILLED |
player.incrementStatistic(playOneTick, minutes * 20 * 60); |
290 |
2
1. onCommand : changed conditional boundary → NO_COVERAGE 2. onCommand : negated conditional → NO_COVERAGE |
} else if (minutes < 0) { |
291 |
3
1. onCommand : changed conditional boundary → NO_COVERAGE 2. onCommand : Replaced integer addition with subtraction → NO_COVERAGE 3. onCommand : negated conditional → NO_COVERAGE |
if (oldMinutes + minutes < 0) { |
292 |
1
1. onCommand : removed call to org/bukkit/entity/Player::sendMessage → NO_COVERAGE |
player.sendMessage(ChatColor.GRAY + "Playtime cannot be negative"); |
293 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
294 | } | |
295 |
4
1. onCommand : removed negation → NO_COVERAGE 2. onCommand : Replaced integer multiplication with division → NO_COVERAGE 3. onCommand : Replaced integer multiplication with division → NO_COVERAGE 4. onCommand : removed call to org/bukkit/entity/Player::decrementStatistic → NO_COVERAGE |
player.decrementStatistic(playOneTick, -minutes * 20 * 60); |
296 | } | |
297 |
1
1. onCommand : Replaced integer addition with subtraction → SURVIVED |
int newMinutes = oldMinutes + minutes; |
298 |
3
1. onCommand : changed conditional boundary → SURVIVED 2. onCommand : negated conditional → SURVIVED 3. onCommand : removed call to org/bukkit/entity/Player::sendMessage → SURVIVED |
player.sendMessage(ChatColor.LIGHT_PURPLE + "Increased playtime for " + player.getName() + " to " + oldMinutes + (minutes >= 0 ? "+" : "") + minutes + "=" + newMinutes + " minutes"); |
299 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → SURVIVED |
return true; |
300 | } | |
301 | } | |
302 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (sender.hasPermission("rankup.playtime.get")) { |
303 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage( |
304 | ChatColor.GREEN + "/" + label + " " + args[0] + " get [player] " + ChatColor.YELLOW | |
305 | + " Get amount of minutes played"); | |
306 | } | |
307 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (sender.hasPermission("rankup.playtime")) { |
308 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage( |
309 | ChatColor.GREEN + "/" + label + " " + args[0] + " set <player> <minutes>" | |
310 | + ChatColor.YELLOW + " Update the playtime statistic for a player"); | |
311 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage( |
312 | ChatColor.GREEN + "/" + label + " " + args[0] + " add <player> <minutes>" | |
313 | + ChatColor.YELLOW + " Increase the playtime statistic for a player"); | |
314 | } | |
315 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
316 | } | |
317 | } | |
318 | ||
319 | PluginDescriptionFile description = plugin.getDescription(); | |
320 | String version = description.getVersion(); | |
321 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage( |
322 | ChatColor.GREEN + "" + ChatColor.BOLD + description.getName() + " " + version + | |
323 | ChatColor.YELLOW + " by " + ChatColor.BLUE + ChatColor.BOLD + String.join(", ", description.getAuthors())); | |
324 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (sender.hasPermission("rankup.reload")) { |
325 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GREEN + "/" + label + " reload " + ChatColor.YELLOW + "Reloads configuration files."); |
326 | } | |
327 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (sender.hasPermission("rankup.force")) { |
328 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GREEN + "/" + label + " forcerankup <player> " + ChatColor.YELLOW + "Force a player to rankup, bypassing requirements."); |
329 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (plugin.getPrestiges() != null) { |
330 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage( |
331 | ChatColor.GREEN + "/" + label + " forceprestige <player> " + ChatColor.YELLOW | |
332 | + "Force a player to prestige, bypassing requirements."); | |
333 | } | |
334 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GREEN + "/" + label + " rankdown <player> " + ChatColor.YELLOW + "Force a player to move down one rank."); |
335 | } | |
336 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (sender.hasPermission("rankup.playtime")) { |
337 |
1
1. onCommand : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage(ChatColor.GREEN + "/" + label + " playtime " + ChatColor.YELLOW + "View your playtime"); |
338 | } | |
339 | ||
340 |
1
1. onCommand : negated conditional → NO_COVERAGE |
if (sender.hasPermission("rankup.checkversion")) { |
341 |
1
1. onCommand : removed call to sh/okx/rankup/util/UpdateNotifier::notify → NO_COVERAGE |
notifier.notify(sender, false); |
342 | } | |
343 | ||
344 |
1
1. onCommand : replaced boolean return with false for sh/okx/rankup/commands/InfoCommand::onCommand → NO_COVERAGE |
return true; |
345 | } | |
346 | ||
347 | @Override | |
348 | public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) { | |
349 |
1
1. onTabComplete : negated conditional → NO_COVERAGE |
if (args.length == 1) { |
350 | List<String> list = new ArrayList<>(); | |
351 |
1
1. onTabComplete : negated conditional → NO_COVERAGE |
if (sender.hasPermission("rankup.reload")) { |
352 | list.add("reload"); | |
353 | } | |
354 |
1
1. onTabComplete : negated conditional → NO_COVERAGE |
if (sender.hasPermission("rankup.force")) { |
355 | list.add("forcerankup"); | |
356 | list.add("forceprestige"); | |
357 | list.add("rankdown"); | |
358 | } | |
359 |
2
1. onTabComplete : negated conditional → NO_COVERAGE 2. onTabComplete : negated conditional → NO_COVERAGE |
if (sender.hasPermission("rankup.playtime.get") || sender.hasPermission("rankup.playtime")) { |
360 | list.add("playtime"); | |
361 | } | |
362 |
1
1. onTabComplete : replaced return value with Collections.emptyList for sh/okx/rankup/commands/InfoCommand::onTabComplete → NO_COVERAGE |
return StringUtil.copyPartialMatches(args[0], list, new ArrayList<>()); |
363 |
1
1. onTabComplete : negated conditional → NO_COVERAGE |
} else if (args.length == 2) { |
364 |
2
1. onTabComplete : negated conditional → NO_COVERAGE 2. onTabComplete : negated conditional → NO_COVERAGE |
if (args[0].equalsIgnoreCase("forcerankup") && sender.hasPermission("rankup.force")) { |
365 |
1
1. onTabComplete : replaced return value with Collections.emptyList for sh/okx/rankup/commands/InfoCommand::onTabComplete → NO_COVERAGE |
return StringUtil.copyPartialMatches(args[1], players(), new ArrayList<>()); |
366 |
3
1. onTabComplete : negated conditional → NO_COVERAGE 2. onTabComplete : negated conditional → NO_COVERAGE 3. onTabComplete : negated conditional → NO_COVERAGE |
} else if (args[0].equalsIgnoreCase("forceprestige") && sender.hasPermission("rankup.force") && plugin.getPrestiges() != null) { |
367 |
1
1. onTabComplete : replaced return value with Collections.emptyList for sh/okx/rankup/commands/InfoCommand::onTabComplete → NO_COVERAGE |
return StringUtil.copyPartialMatches(args[1], players(), new ArrayList<>()); |
368 |
2
1. onTabComplete : negated conditional → NO_COVERAGE 2. onTabComplete : negated conditional → NO_COVERAGE |
} else if (args[0].equalsIgnoreCase("rankdown") && sender.hasPermission("rankup.force")) { |
369 |
1
1. onTabComplete : replaced return value with Collections.emptyList for sh/okx/rankup/commands/InfoCommand::onTabComplete → NO_COVERAGE |
return StringUtil.copyPartialMatches(args[1], players(), new ArrayList<>()); |
370 |
1
1. onTabComplete : negated conditional → NO_COVERAGE |
} else if (args[0].equalsIgnoreCase("playtime")) { |
371 | List<String> options = new ArrayList<>(); | |
372 |
1
1. onTabComplete : negated conditional → NO_COVERAGE |
if (sender.hasPermission("rankup.playtime.get")) { |
373 | options.add("get"); | |
374 | } | |
375 |
1
1. onTabComplete : negated conditional → NO_COVERAGE |
if (sender.hasPermission("rankup.playtime")) { |
376 | options.add("set"); | |
377 | options.add("add"); | |
378 | } | |
379 |
1
1. onTabComplete : replaced return value with Collections.emptyList for sh/okx/rankup/commands/InfoCommand::onTabComplete → NO_COVERAGE |
return StringUtil.copyPartialMatches(args[1], options, new ArrayList<>()); |
380 | } | |
381 | } | |
382 | return Collections.emptyList(); | |
383 | } | |
384 | ||
385 | private Iterable<String> players() { | |
386 | Set<String> players = new HashSet<>(); | |
387 | for (Player player : Bukkit.getOnlinePlayers()) { | |
388 | players.add(player.getName()); | |
389 | } | |
390 |
1
1. players : replaced return value with null for sh/okx/rankup/commands/InfoCommand::players → NO_COVERAGE |
return players; |
391 | } | |
392 | } | |
Mutations | ||
39 |
1.1 2.2 |
|
40 |
1.1 2.2 |
|
41 |
1.1 |
|
42 |
1.1 |
|
43 |
1.1 |
|
45 |
1.1 |
|
46 |
1.1 2.2 |
|
47 |
1.1 2.2 |
|
48 |
1.1 |
|
49 |
1.1 |
|
53 |
1.1 |
|
54 |
1.1 |
|
55 |
1.1 |
|
60 |
1.1 |
|
61 |
1.1 |
|
62 |
1.1 |
|
63 |
1.1 |
|
64 |
1.1 |
|
65 |
1.1 |
|
70 |
1.1 |
|
71 |
1.1 |
|
72 |
1.1 |
|
76 |
1.1 |
|
77 |
1.1 2.2 |
|
78 |
1.1 |
|
79 |
1.1 |
|
80 |
1.1 |
|
83 |
1.1 2.2 |
|
84 |
1.1 |
|
85 |
1.1 |
|
89 |
1.1 |
|
90 |
1.1 |
|
91 |
1.1 |
|
96 |
1.1 |
|
97 |
1.1 |
|
98 |
1.1 |
|
102 |
1.1 |
|
103 |
1.1 |
|
104 |
1.1 |
|
107 |
1.1 |
|
108 |
1.1 |
|
109 |
1.1 |
|
115 |
1.1 |
|
116 |
1.1 2.2 |
|
117 |
1.1 2.2 |
|
118 |
1.1 |
|
119 |
1.1 |
|
123 |
1.1 |
|
124 |
1.1 |
|
125 |
1.1 |
|
129 |
1.1 |
|
130 |
1.1 |
|
131 |
1.1 |
|
135 |
1.1 |
|
136 |
1.1 |
|
137 |
1.1 |
|
141 |
1.1 2.2 |
|
145 |
1.1 |
|
146 |
1.1 |
|
147 |
1.1 |
|
151 |
1.1 |
|
152 |
1.1 |
|
154 |
1.1 |
|
156 |
1.1 |
|
160 |
1.1 |
|
161 |
1.1 2.2 |
|
162 |
1.1 |
|
163 |
1.1 2.2 3.3 |
|
166 |
1.1 2.2 |
|
168 |
1.1 |
|
187 |
1.1 |
|
191 |
1.1 |
|
193 |
1.1 |
|
194 |
1.1 2.2 |
|
196 |
1.1 |
|
200 |
1.1 |
|
203 |
1.1 |
|
204 |
1.1 2.2 3.3 |
|
213 |
1.1 2.2 |
|
214 |
1.1 2.2 |
|
216 |
1.1 2.2 |
|
219 |
1.1 |
|
220 |
1.1 |
|
221 |
1.1 |
|
224 |
1.1 |
|
227 |
1.1 |
|
229 |
1.1 |
|
234 |
1.1 2.2 |
|
237 |
1.1 |
|
242 |
1.1 |
|
243 |
1.1 |
|
244 |
1.1 2.2 |
|
245 |
1.1 2.2 |
|
246 |
1.1 |
|
247 |
1.1 |
|
251 |
1.1 |
|
252 |
1.1 |
|
253 |
1.1 |
|
260 |
1.1 |
|
261 |
1.1 |
|
264 |
1.1 2.2 3.3 |
|
265 |
1.1 |
|
266 |
1.1 |
|
267 |
1.1 2.2 |
|
268 |
1.1 2.2 |
|
269 |
1.1 |
|
270 |
1.1 |
|
274 |
1.1 |
|
275 |
1.1 |
|
276 |
1.1 |
|
283 |
1.1 |
|
284 |
1.1 |
|
287 |
1.1 2.2 |
|
288 |
1.1 2.2 |
|
289 |
1.1 2.2 3.3 |
|
290 |
1.1 2.2 |
|
291 |
1.1 2.2 3.3 |
|
292 |
1.1 |
|
293 |
1.1 |
|
295 |
1.1 2.2 3.3 4.4 |
|
297 |
1.1 |
|
298 |
1.1 2.2 3.3 |
|
299 |
1.1 |
|
302 |
1.1 |
|
303 |
1.1 |
|
307 |
1.1 |
|
308 |
1.1 |
|
311 |
1.1 |
|
315 |
1.1 |
|
321 |
1.1 |
|
324 |
1.1 |
|
325 |
1.1 |
|
327 |
1.1 |
|
328 |
1.1 |
|
329 |
1.1 |
|
330 |
1.1 |
|
334 |
1.1 |
|
336 |
1.1 |
|
337 |
1.1 |
|
340 |
1.1 |
|
341 |
1.1 |
|
344 |
1.1 |
|
349 |
1.1 |
|
351 |
1.1 |
|
354 |
1.1 |
|
359 |
1.1 2.2 |
|
362 |
1.1 |
|
363 |
1.1 |
|
364 |
1.1 2.2 |
|
365 |
1.1 |
|
366 |
1.1 2.2 3.3 |
|
367 |
1.1 |
|
368 |
1.1 2.2 |
|
369 |
1.1 |
|
370 |
1.1 |
|
372 |
1.1 |
|
375 |
1.1 |
|
379 |
1.1 |
|
390 |
1.1 |