| 1 | package sh.okx.rankup; | |
| 2 | ||
| 3 | import com.electronwill.nightconfig.toml.TomlFormat; | |
| 4 | import java.io.File; | |
| 5 | import java.io.FileNotFoundException; | |
| 6 | import java.io.FileReader; | |
| 7 | import java.util.HashMap; | |
| 8 | import java.util.List; | |
| 9 | import java.util.Map; | |
| 10 | import lombok.Getter; | |
| 11 | import org.bukkit.Bukkit; | |
| 12 | import org.bukkit.ChatColor; | |
| 13 | import org.bukkit.command.CommandSender; | |
| 14 | import org.bukkit.configuration.ConfigurationSection; | |
| 15 | import org.bukkit.configuration.file.FileConfiguration; | |
| 16 | import org.bukkit.configuration.file.YamlConfiguration; | |
| 17 | import org.bukkit.entity.Player; | |
| 18 | import org.bukkit.event.inventory.InventoryType; | |
| 19 | import org.bukkit.inventory.InventoryView; | |
| 20 | import org.bukkit.plugin.PluginDescriptionFile; | |
| 21 | import org.bukkit.plugin.PluginManager; | |
| 22 | import org.bukkit.plugin.java.JavaPlugin; | |
| 23 | import org.bukkit.plugin.java.JavaPluginLoader; | |
| 24 | import sh.okx.rankup.commands.InfoCommand; | |
| 25 | import sh.okx.rankup.commands.MaxRankupCommand; | |
| 26 | import sh.okx.rankup.commands.PrestigeCommand; | |
| 27 | import sh.okx.rankup.commands.PrestigesCommand; | |
| 28 | import sh.okx.rankup.commands.RanksCommand; | |
| 29 | import sh.okx.rankup.commands.RankupCommand; | |
| 30 | import sh.okx.rankup.economy.Economy; | |
| 31 | import sh.okx.rankup.economy.EconomyProvider; | |
| 32 | import sh.okx.rankup.economy.VaultEconomyProvider; | |
| 33 | import sh.okx.rankup.events.RankupRegisterEvent; | |
| 34 | import sh.okx.rankup.gui.Gui; | |
| 35 | import sh.okx.rankup.gui.GuiListener; | |
| 36 | import sh.okx.rankup.hook.GroupProvider; | |
| 37 | import sh.okx.rankup.hook.PermissionManager; | |
| 38 | import sh.okx.rankup.hook.VaultPermissionManager; | |
| 39 | import sh.okx.rankup.messages.Message; | |
| 40 | import sh.okx.rankup.messages.MessageBuilder; | |
| 41 | import sh.okx.rankup.messages.pebble.PebbleMessageBuilder; | |
| 42 | import sh.okx.rankup.placeholders.Placeholders; | |
| 43 | import sh.okx.rankup.prestige.Prestige; | |
| 44 | import sh.okx.rankup.prestige.Prestiges; | |
| 45 | import sh.okx.rankup.ranks.Rank; | |
| 46 | import sh.okx.rankup.ranks.RankList; | |
| 47 | import sh.okx.rankup.ranks.Rankups; | |
| 48 | import sh.okx.rankup.ranksgui.RanksGuiCommand; | |
| 49 | import sh.okx.rankup.ranksgui.RanksGuiListener; | |
| 50 | import sh.okx.rankup.requirements.Requirement; | |
| 51 | import sh.okx.rankup.requirements.RequirementRegistry; | |
| 52 | import sh.okx.rankup.requirements.requirement.AdvancementRequirement; | |
| 53 | import sh.okx.rankup.requirements.requirement.BlockBreakRequirement; | |
| 54 | import sh.okx.rankup.requirements.requirement.CraftItemRequirement; | |
| 55 | import sh.okx.rankup.requirements.requirement.GroupRequirement; | |
| 56 | import sh.okx.rankup.requirements.requirement.ItemDeductibleRequirement; | |
| 57 | import sh.okx.rankup.requirements.requirement.ItemRequirement; | |
| 58 | import sh.okx.rankup.requirements.requirement.MobKillsRequirement; | |
| 59 | import sh.okx.rankup.requirements.requirement.MoneyDeductibleRequirement; | |
| 60 | import sh.okx.rankup.requirements.requirement.MoneyRequirement; | |
| 61 | import sh.okx.rankup.requirements.requirement.PermissionRequirement; | |
| 62 | import sh.okx.rankup.requirements.requirement.PlaceholderRequirement; | |
| 63 | import sh.okx.rankup.requirements.requirement.PlayerKillsRequirement; | |
| 64 | import sh.okx.rankup.requirements.requirement.PlaytimeMinutesRequirement; | |
| 65 | import sh.okx.rankup.requirements.requirement.TotalMobKillsRequirement; | |
| 66 | import sh.okx.rankup.requirements.requirement.UseItemRequirement; | |
| 67 | import sh.okx.rankup.requirements.requirement.WorldRequirement; | |
| 68 | import sh.okx.rankup.requirements.requirement.XpLevelDeductibleRequirement; | |
| 69 | import sh.okx.rankup.requirements.requirement.XpLevelRequirement; | |
| 70 | import sh.okx.rankup.requirements.requirement.advancedachievements.AdvancedAchievementsAchievementRequirement; | |
| 71 | import sh.okx.rankup.requirements.requirement.advancedachievements.AdvancedAchievementsTotalRequirement; | |
| 72 | import sh.okx.rankup.requirements.requirement.mcmmo.McMMOPowerLevelRequirement; | |
| 73 | import sh.okx.rankup.requirements.requirement.mcmmo.McMMOSkillRequirement; | |
| 74 | import sh.okx.rankup.requirements.requirement.superbvote.SuperbVoteVotesRequirement; | |
| 75 | import sh.okx.rankup.requirements.requirement.tokenmanager.TokensDeductibleRequirement; | |
| 76 | import sh.okx.rankup.requirements.requirement.tokenmanager.TokensRequirement; | |
| 77 | import sh.okx.rankup.requirements.requirement.towny.TownyKingNumberResidentsRequirement; | |
| 78 | import sh.okx.rankup.requirements.requirement.towny.TownyKingNumberTownsRequirement; | |
| 79 | import sh.okx.rankup.requirements.requirement.towny.TownyKingRequirement; | |
| 80 | import sh.okx.rankup.requirements.requirement.towny.TownyMayorNumberResidentsRequirement; | |
| 81 | import sh.okx.rankup.requirements.requirement.towny.TownyMayorRequirement; | |
| 82 | import sh.okx.rankup.requirements.requirement.towny.TownyResidentRequirement; | |
| 83 | import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginPointsDeductibleRequirement; | |
| 84 | import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginPointsRequirement; | |
| 85 | import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginVotesRequirement; | |
| 86 | import sh.okx.rankup.serialization.RankSerialized; | |
| 87 | import sh.okx.rankup.serialization.ShadowDeserializer; | |
| 88 | import sh.okx.rankup.serialization.YamlDeserializer; | |
| 89 | import sh.okx.rankup.util.UpdateNotifier; | |
| 90 | import sh.okx.rankup.util.VersionChecker; | |
| 91 | ||
| 92 | public class RankupPlugin extends JavaPlugin { | |
| 93 | ||
| 94 | public static final int CONFIG_VERSION = 10; | |
| 95 | ||
| 96 |
1
1. getPermissions : replaced return value with null for sh/okx/rankup/RankupPlugin::getPermissions → KILLED |
@Getter |
| 97 | private GroupProvider permissions; | |
| 98 |
1
1. getEconomy : replaced return value with null for sh/okx/rankup/RankupPlugin::getEconomy → KILLED |
@Getter |
| 99 | private Economy economy; | |
| 100 | /** | |
| 101 | * The registry for listing the requirements to /rankup. | |
| 102 | */ | |
| 103 |
1
1. getRequirements : replaced return value with null for sh/okx/rankup/RankupPlugin::getRequirements → KILLED |
@Getter |
| 104 | private RequirementRegistry requirements; | |
| 105 |
1
1. getMessages : replaced return value with null for sh/okx/rankup/RankupPlugin::getMessages → KILLED |
@Getter |
| 106 | private FileConfiguration messages; | |
| 107 |
1
1. getConfig : replaced return value with null for sh/okx/rankup/RankupPlugin::getConfig → KILLED |
@Getter |
| 108 | private FileConfiguration config; | |
| 109 |
1
1. getRankups : replaced return value with null for sh/okx/rankup/RankupPlugin::getRankups → KILLED |
@Getter |
| 110 | private Rankups rankups; | |
| 111 |
1
1. getPrestiges : replaced return value with null for sh/okx/rankup/RankupPlugin::getPrestiges → KILLED |
@Getter |
| 112 | private Prestiges prestiges; | |
| 113 |
1
1. getPlaceholders : replaced return value with null for sh/okx/rankup/RankupPlugin::getPlaceholders → KILLED |
@Getter |
| 114 | private Placeholders placeholders; | |
| 115 |
1
1. getHelper : replaced return value with null for sh/okx/rankup/RankupPlugin::getHelper → KILLED |
@Getter |
| 116 | private RankupHelper helper; | |
| 117 | protected AutoRankup autoRankup = new AutoRankup(this); | |
| 118 | private String errorMessage; | |
| 119 | private PermissionManager permissionManager = new VaultPermissionManager(this); | |
| 120 | private EconomyProvider economyProvider = new VaultEconomyProvider(); | |
| 121 | ||
| 122 | public RankupPlugin() { | |
| 123 | super(); | |
| 124 | } | |
| 125 | ||
| 126 | protected RankupPlugin(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file, PermissionManager permissionManager, EconomyProvider economyProvider) { | |
| 127 | super(loader, description, dataFolder, file); | |
| 128 | this.permissionManager = permissionManager; | |
| 129 | this.economyProvider = economyProvider; | |
| 130 | } | |
| 131 | ||
| 132 | @Override | |
| 133 | public void onEnable() { | |
| 134 | UpdateNotifier notifier = new UpdateNotifier(new VersionChecker(this)); | |
| 135 | ||
| 136 |
1
1. onEnable : removed call to sh/okx/rankup/RankupPlugin::reload → KILLED |
reload(true); |
| 137 | ||
| 138 |
1
1. onEnable : negated conditional → SURVIVED |
if (System.getProperty("RANKUP_TEST") == null) { |
| 139 | Metrics metrics = new Metrics(this); | |
| 140 |
1
1. onEnable : removed call to sh/okx/rankup/Metrics::addCustomChart → NO_COVERAGE |
metrics.addCustomChart(new Metrics.SimplePie("confirmation", |
| 141 |
1
1. lambda$onEnable$0 : replaced return value with "" for sh/okx/rankup/RankupPlugin::lambda$onEnable$0 → NO_COVERAGE |
() -> config.getString("confirmation-type", "unknown"))); |
| 142 |
1
1. onEnable : removed call to sh/okx/rankup/Metrics::addCustomChart → NO_COVERAGE |
metrics.addCustomChart(new Metrics.AdvancedPie("requirements", () -> { |
| 143 | Map<String, Integer> map = new HashMap<>(); | |
| 144 |
1
1. lambda$onEnable$1 : removed call to sh/okx/rankup/RankupPlugin::addAllRequirements → NO_COVERAGE |
addAllRequirements(map, rankups); |
| 145 |
1
1. lambda$onEnable$1 : negated conditional → NO_COVERAGE |
if (prestiges != null) { |
| 146 |
1
1. lambda$onEnable$1 : removed call to sh/okx/rankup/RankupPlugin::addAllRequirements → NO_COVERAGE |
addAllRequirements(map, prestiges); |
| 147 | } | |
| 148 |
1
1. lambda$onEnable$1 : replaced return value with null for sh/okx/rankup/RankupPlugin::lambda$onEnable$1 → NO_COVERAGE |
return map; |
| 149 | })); | |
| 150 |
1
1. onEnable : removed call to sh/okx/rankup/Metrics::addCustomChart → NO_COVERAGE |
metrics.addCustomChart(new Metrics.SimplePie("prestige", |
| 151 |
2
1. lambda$onEnable$2 : negated conditional → NO_COVERAGE 2. lambda$onEnable$2 : replaced return value with "" for sh/okx/rankup/RankupPlugin::lambda$onEnable$2 → NO_COVERAGE |
() -> config.getBoolean("prestige") ? "enabled" : "disabled")); |
| 152 |
1
1. onEnable : removed call to sh/okx/rankup/Metrics::addCustomChart → NO_COVERAGE |
metrics.addCustomChart(new Metrics.SimplePie("permission-rankup", |
| 153 |
2
1. lambda$onEnable$3 : negated conditional → NO_COVERAGE 2. lambda$onEnable$3 : replaced return value with "" for sh/okx/rankup/RankupPlugin::lambda$onEnable$3 → NO_COVERAGE |
() -> config.getBoolean("permission-rankup") ? "enabled" : "disabled")); |
| 154 |
1
1. onEnable : removed call to sh/okx/rankup/Metrics::addCustomChart → NO_COVERAGE |
metrics.addCustomChart(new Metrics.SimplePie("notify-update", |
| 155 |
2
1. lambda$onEnable$4 : negated conditional → NO_COVERAGE 2. lambda$onEnable$4 : replaced return value with "" for sh/okx/rankup/RankupPlugin::lambda$onEnable$4 → NO_COVERAGE |
() -> config.getBoolean("notify-update") ? "enabled" : "disabled")); |
| 156 | } | |
| 157 | ||
| 158 |
1
1. onEnable : negated conditional → KILLED |
if (config.getBoolean("ranks")) { |
| 159 |
1
1. onEnable : negated conditional → KILLED |
if (config.getBoolean("ranks-gui")) { |
| 160 | RanksGuiListener listener = new RanksGuiListener(); | |
| 161 |
1
1. onEnable : removed call to org/bukkit/command/PluginCommand::setExecutor → KILLED |
getCommand("ranks").setExecutor(new RanksGuiCommand(this, listener)); |
| 162 |
1
1. onEnable : removed call to org/bukkit/plugin/PluginManager::registerEvents → KILLED |
getServer().getPluginManager().registerEvents(listener, this); |
| 163 | } else { | |
| 164 |
1
1. onEnable : removed call to org/bukkit/command/PluginCommand::setExecutor → KILLED |
getCommand("ranks").setExecutor(new RanksCommand(this)); |
| 165 | } | |
| 166 | } | |
| 167 |
1
1. onEnable : negated conditional → SURVIVED |
if (config.getBoolean("prestige")) { |
| 168 |
1
1. onEnable : removed call to org/bukkit/command/PluginCommand::setExecutor → SURVIVED |
getCommand("prestige").setExecutor(new PrestigeCommand(this)); |
| 169 |
1
1. onEnable : negated conditional → SURVIVED |
if (config.getBoolean("prestiges")) { |
| 170 |
1
1. onEnable : removed call to org/bukkit/command/PluginCommand::setExecutor → SURVIVED |
getCommand("prestiges").setExecutor(new PrestigesCommand(this)); |
| 171 | } | |
| 172 | } | |
| 173 |
1
1. onEnable : negated conditional → SURVIVED |
if (config.getBoolean("max-rankup.enabled")) { |
| 174 |
1
1. onEnable : removed call to org/bukkit/command/PluginCommand::setExecutor → NO_COVERAGE |
getCommand("maxrankup").setExecutor(new MaxRankupCommand(this)); |
| 175 | } | |
| 176 | ||
| 177 |
1
1. onEnable : removed call to org/bukkit/command/PluginCommand::setExecutor → SURVIVED |
getCommand("rankup").setExecutor(new RankupCommand(this)); |
| 178 |
1
1. onEnable : removed call to org/bukkit/command/PluginCommand::setExecutor → KILLED |
getCommand("rankup3").setExecutor(new InfoCommand(this, notifier)); |
| 179 |
1
1. onEnable : removed call to org/bukkit/plugin/PluginManager::registerEvents → SURVIVED |
getServer().getPluginManager().registerEvents(new GuiListener(this), this); |
| 180 |
1
1. onEnable : removed call to org/bukkit/plugin/PluginManager::registerEvents → SURVIVED |
getServer().getPluginManager().registerEvents( |
| 181 |
2
1. lambda$onEnable$5 : replaced Boolean return with False for sh/okx/rankup/RankupPlugin::lambda$onEnable$5 → SURVIVED 2. lambda$onEnable$5 : replaced Boolean return with True for sh/okx/rankup/RankupPlugin::lambda$onEnable$5 → SURVIVED |
new JoinUpdateNotifier(notifier, () -> getConfig().getBoolean("notify-update"), "rankup.notify"), this); |
| 182 | ||
| 183 | placeholders = new Placeholders(this); | |
| 184 |
1
1. onEnable : removed call to sh/okx/rankup/placeholders/Placeholders::register → KILLED |
placeholders.register(); |
| 185 | } | |
| 186 | ||
| 187 | ||
| 188 | @Override | |
| 189 | public void onDisable() { | |
| 190 |
1
1. onDisable : removed call to sh/okx/rankup/RankupPlugin::closeInventories → SURVIVED |
closeInventories(); |
| 191 |
1
1. onDisable : negated conditional → SURVIVED |
if (placeholders != null) { |
| 192 |
1
1. onDisable : removed call to sh/okx/rankup/placeholders/Placeholders::unregister → SURVIVED |
placeholders.unregister(); |
| 193 | } | |
| 194 | } | |
| 195 | ||
| 196 | public void reload(boolean init) { | |
| 197 | errorMessage = null; | |
| 198 | ||
| 199 | config = loadConfig("config.yml"); | |
| 200 | ||
| 201 |
1
1. reload : negated conditional → SURVIVED |
if (config.getBoolean("permission-rankup")) { |
| 202 | permissions = permissionManager.permissionOnlyProvider(); | |
| 203 | } else { | |
| 204 | permissions = permissionManager.findPermissionProvider(); | |
| 205 |
1
1. reload : negated conditional → KILLED |
if (permissions == null) { |
| 206 | errorMessage = "No permission plugin found"; | |
| 207 | } | |
| 208 | } | |
| 209 | ||
| 210 |
1
1. reload : removed call to sh/okx/rankup/RankupPlugin::setupEconomy → KILLED |
setupEconomy(); |
| 211 | ||
| 212 |
1
1. reload : removed call to sh/okx/rankup/RankupPlugin::closeInventories → SURVIVED |
closeInventories(); |
| 213 |
1
1. reload : removed call to sh/okx/rankup/RankupPlugin::loadConfigs → KILLED |
loadConfigs(init); |
| 214 | ||
| 215 |
2
1. reload : Replaced double multiplication with division → SURVIVED 2. reload : Replaced double multiplication with division → SURVIVED |
long time = (long) (config.getDouble("autorankup-interval") * 60 * 20); |
| 216 |
2
1. reload : changed conditional boundary → SURVIVED 2. reload : negated conditional → SURVIVED |
if (time > 0) { |
| 217 | try { | |
| 218 |
1
1. reload : negated conditional → NO_COVERAGE |
if (!autoRankup.isCancelled()) { |
| 219 |
1
1. reload : removed call to sh/okx/rankup/AutoRankup::cancel → NO_COVERAGE |
autoRankup.cancel(); |
| 220 | } | |
| 221 | } catch (IllegalStateException ignored) { | |
| 222 | } | |
| 223 | autoRankup = new AutoRankup(this); | |
| 224 | autoRankup.runTaskTimer(this, time, time); | |
| 225 | } | |
| 226 | ||
| 227 |
2
1. reload : changed conditional boundary → SURVIVED 2. reload : negated conditional → SURVIVED |
if (config.getInt("version") < CONFIG_VERSION) { |
| 228 | getLogger().severe("You are using an outdated config!"); | |
| 229 | getLogger().severe("This means that some things might not work!"); | |
| 230 | getLogger().severe("To update, please rename ALL your config files (or the folder they are in),"); | |
| 231 | getLogger().severe("and run /pru reload to generate a new config file."); | |
| 232 | getLogger().severe("If that does not work, restart your server."); | |
| 233 | getLogger().severe("You may then copy in your config values manually from the old config."); | |
| 234 | getLogger().severe("Check the changelog on the Rankup spigot page to see the changes."); | |
| 235 | getLogger().severe("https://www.spigotmc.org/resources/rankup.76964/updates"); | |
| 236 | } | |
| 237 | ||
| 238 | helper = new RankupHelper(this); | |
| 239 | } | |
| 240 | ||
| 241 | public MessageBuilder newMessageBuilder(String message) { | |
| 242 |
1
1. newMessageBuilder : replaced return value with null for sh/okx/rankup/RankupPlugin::newMessageBuilder → KILLED |
return new PebbleMessageBuilder(this, message); |
| 243 | } | |
| 244 | ||
| 245 | public boolean error() { | |
| 246 |
2
1. error : replaced boolean return with false for sh/okx/rankup/RankupPlugin::error → SURVIVED 2. error : replaced boolean return with true for sh/okx/rankup/RankupPlugin::error → KILLED |
return error(null); |
| 247 | } | |
| 248 | ||
| 249 | /** | |
| 250 | * Notify the player of an error if there is one | |
| 251 | * | |
| 252 | * @return true if there was an error and action was taken | |
| 253 | */ | |
| 254 | public boolean error(CommandSender sender) { | |
| 255 |
1
1. error : negated conditional → KILLED |
if (errorMessage == null) { |
| 256 |
1
1. error : replaced boolean return with true for sh/okx/rankup/RankupPlugin::error → KILLED |
return false; |
| 257 | } | |
| 258 | ||
| 259 |
1
1. error : negated conditional → NO_COVERAGE |
if (sender instanceof Player) { |
| 260 |
1
1. error : removed call to org/bukkit/command/CommandSender::sendMessage → NO_COVERAGE |
sender.sendMessage( |
| 261 | ChatColor.RED + "Could not load Rankup, check console for more information."); | |
| 262 | } else { | |
| 263 | getLogger().severe("Failed to load Rankup"); | |
| 264 | } | |
| 265 | for (String line : errorMessage.split("\n")) { | |
| 266 | getLogger().severe(line); | |
| 267 | } | |
| 268 | getLogger().severe("More information can be found in the console log at startup"); | |
| 269 |
1
1. error : replaced boolean return with false for sh/okx/rankup/RankupPlugin::error → NO_COVERAGE |
return true; |
| 270 | } | |
| 271 | ||
| 272 | private void addAllRequirements(Map<String, Integer> map, RankList<? extends Rank> ranks) { | |
| 273 | for (Rank rank : ranks.getTree()) { | |
| 274 | for (Requirement requirement : rank.getRequirements().getRequirements(null)) { | |
| 275 | String name = requirement.getName(); | |
| 276 |
1
1. addAllRequirements : Replaced integer addition with subtraction → NO_COVERAGE |
map.put(name, map.getOrDefault(name, 0) + 1); |
| 277 | } | |
| 278 | } | |
| 279 | } | |
| 280 | ||
| 281 | /** | |
| 282 | * Closes all rankup inventories on disable so players cannot grab items from the inventory on a | |
| 283 | * plugin reload. | |
| 284 | */ | |
| 285 | private void closeInventories() { | |
| 286 | for (Player player : Bukkit.getOnlinePlayers()) { | |
| 287 | InventoryView view = player.getOpenInventory(); | |
| 288 |
1
1. closeInventories : negated conditional → KILLED |
if (view.getType() == InventoryType.CHEST |
| 289 |
1
1. closeInventories : negated conditional → SURVIVED |
&& view.getTopInventory().getHolder() instanceof Gui) { |
| 290 |
1
1. closeInventories : removed call to org/bukkit/entity/Player::closeInventory → NO_COVERAGE |
player.closeInventory(); |
| 291 | } | |
| 292 | } | |
| 293 | } | |
| 294 | ||
| 295 | private void loadConfigs(boolean init) { | |
| 296 |
1
1. loadConfigs : removed call to sh/okx/rankup/RankupPlugin::saveLocales → KILLED |
saveLocales(); |
| 297 | ||
| 298 | String locale = config.getString("locale", "en"); | |
| 299 | File localeFile = new File(new File(getDataFolder(), "locale"), locale + ".yml"); | |
| 300 | messages = YamlConfiguration.loadConfiguration(localeFile); | |
| 301 | ||
| 302 |
1
1. loadConfigs : negated conditional → SURVIVED |
if (init) { |
| 303 | Bukkit.getScheduler().runTask(this, () -> { | |
| 304 |
1
1. lambda$loadConfigs$6 : removed call to sh/okx/rankup/RankupPlugin::refreshRanks → KILLED |
refreshRanks(); |
| 305 | error(); | |
| 306 | }); | |
| 307 | } else { | |
| 308 |
1
1. loadConfigs : removed call to sh/okx/rankup/RankupPlugin::refreshRanks → NO_COVERAGE |
refreshRanks(); |
| 309 | } | |
| 310 | } | |
| 311 | ||
| 312 | public void refreshRanks() { | |
| 313 | try { | |
| 314 |
1
1. refreshRanks : removed call to sh/okx/rankup/RankupPlugin::registerRequirements → KILLED |
registerRequirements(); |
| 315 |
1
1. refreshRanks : removed call to org/bukkit/plugin/PluginManager::callEvent → SURVIVED |
Bukkit.getPluginManager().callEvent(new RankupRegisterEvent(this)); |
| 316 | ||
| 317 |
1
1. refreshRanks : negated conditional → KILLED |
if (config.getBoolean("prestige")) { |
| 318 | prestiges = new Prestiges(this, loadConfig("prestiges.yml")); | |
| 319 | // prestiges.getOrderedList(); | |
| 320 | } else { | |
| 321 | prestiges = null; | |
| 322 | } | |
| 323 | ||
| 324 | rankups = new Rankups(this, loadRankupConfig("rankups")); | |
| 325 | // check rankups are not in an infinite loop | |
| 326 | // rankups.getOrderedList(); | |
| 327 | ||
| 328 | ||
| 329 | ||
| 330 | } catch (Exception e) { | |
| 331 | this.errorMessage = e.getClass().getName() + ": " + e.getMessage(); | |
| 332 |
1
1. refreshRanks : removed call to java/lang/Exception::printStackTrace → NO_COVERAGE |
e.printStackTrace(); |
| 333 | } | |
| 334 | } | |
| 335 | ||
| 336 | private void saveLocales() { | |
| 337 |
1
1. saveLocales : removed call to sh/okx/rankup/RankupPlugin::saveLocale → KILLED |
saveLocale("en"); |
| 338 |
1
1. saveLocales : removed call to sh/okx/rankup/RankupPlugin::saveLocale → SURVIVED |
saveLocale("pt_br"); |
| 339 |
1
1. saveLocales : removed call to sh/okx/rankup/RankupPlugin::saveLocale → SURVIVED |
saveLocale("ru"); |
| 340 |
1
1. saveLocales : removed call to sh/okx/rankup/RankupPlugin::saveLocale → SURVIVED |
saveLocale("zh_cn"); |
| 341 |
1
1. saveLocales : removed call to sh/okx/rankup/RankupPlugin::saveLocale → SURVIVED |
saveLocale("fr"); |
| 342 |
1
1. saveLocales : removed call to sh/okx/rankup/RankupPlugin::saveLocale → SURVIVED |
saveLocale("it"); |
| 343 |
1
1. saveLocales : removed call to sh/okx/rankup/RankupPlugin::saveLocale → SURVIVED |
saveLocale("es"); |
| 344 |
1
1. saveLocales : removed call to sh/okx/rankup/RankupPlugin::saveLocale → SURVIVED |
saveLocale("nl"); |
| 345 | } | |
| 346 | ||
| 347 | private void saveLocale(String locale) { | |
| 348 | String name = "locale/" + locale + ".yml"; | |
| 349 | File file = new File(getDataFolder(), name); | |
| 350 |
1
1. saveLocale : negated conditional → KILLED |
if (!file.exists()) { |
| 351 |
1
1. saveLocale : removed call to sh/okx/rankup/RankupPlugin::saveResource → KILLED |
saveResource(name, false); |
| 352 | } | |
| 353 | } | |
| 354 | ||
| 355 | private List<RankSerialized> loadRankupConfig(String name) { | |
| 356 | File ymlFile = new File(getDataFolder(), name + ".yml"); | |
| 357 | File tomlFile = new File(getDataFolder(), name + ".toml"); | |
| 358 |
1
1. loadRankupConfig : negated conditional → KILLED |
if (tomlFile.exists()) { |
| 359 | try { | |
| 360 |
1
1. loadRankupConfig : replaced return value with Collections.emptyList for sh/okx/rankup/RankupPlugin::loadRankupConfig → KILLED |
return ShadowDeserializer.deserialize(TomlFormat.instance().createParser().parse(new FileReader(tomlFile))); |
| 361 | } catch (FileNotFoundException ignored) { | |
| 362 | } | |
| 363 | } | |
| 364 |
1
1. loadRankupConfig : negated conditional → KILLED |
if (!ymlFile.exists()) { |
| 365 |
1
1. loadRankupConfig : removed call to sh/okx/rankup/RankupPlugin::saveResource → KILLED |
saveResource(ymlFile.getName(), false); |
| 366 | } | |
| 367 |
1
1. loadRankupConfig : replaced return value with Collections.emptyList for sh/okx/rankup/RankupPlugin::loadRankupConfig → KILLED |
return YamlDeserializer.deserialize(YamlConfiguration.loadConfiguration(ymlFile)); |
| 368 | } | |
| 369 | ||
| 370 | private FileConfiguration loadConfig(String name) { | |
| 371 | File file = new File(getDataFolder(), name); | |
| 372 |
1
1. loadConfig : negated conditional → KILLED |
if (!file.exists()) { |
| 373 |
1
1. loadConfig : removed call to sh/okx/rankup/RankupPlugin::saveResource → KILLED |
saveResource(name, false); |
| 374 | } | |
| 375 |
1
1. loadConfig : replaced return value with null for sh/okx/rankup/RankupPlugin::loadConfig → KILLED |
return YamlConfiguration.loadConfiguration(file); |
| 376 | } | |
| 377 | ||
| 378 | private void registerRequirements() { | |
| 379 | requirements = new RequirementRegistry(); | |
| 380 |
1
1. registerRequirements : removed call to sh/okx/rankup/requirements/RequirementRegistry::addRequirements → KILLED |
requirements.addRequirements( |
| 381 | new XpLevelRequirement(this, "xp-levelh"), | |
| 382 | new XpLevelDeductibleRequirement(this, "xp-level"), | |
| 383 | new PlaytimeMinutesRequirement(this), | |
| 384 | new AdvancementRequirement(this), | |
| 385 | new GroupRequirement(this), | |
| 386 | new PermissionRequirement(this), | |
| 387 | new PlaceholderRequirement(this), | |
| 388 | new WorldRequirement(this), | |
| 389 | new BlockBreakRequirement(this), | |
| 390 | new PlayerKillsRequirement(this), | |
| 391 | new MobKillsRequirement(this), | |
| 392 | new ItemRequirement(this, "itemh"), | |
| 393 | new ItemDeductibleRequirement(this, "item"), | |
| 394 | new UseItemRequirement(this), | |
| 395 | new TotalMobKillsRequirement(this), | |
| 396 | new CraftItemRequirement(this)); | |
| 397 |
1
1. registerRequirements : negated conditional → KILLED |
if (economy != null) { |
| 398 |
1
1. registerRequirements : removed call to sh/okx/rankup/requirements/RequirementRegistry::addRequirements → KILLED |
requirements.addRequirements( |
| 399 | new MoneyRequirement(this, "moneyh"), | |
| 400 | new MoneyDeductibleRequirement(this, "money")); | |
| 401 | } | |
| 402 | ||
| 403 | PluginManager pluginManager = Bukkit.getPluginManager(); | |
| 404 |
1
1. registerRequirements : negated conditional → SURVIVED |
if (pluginManager.isPluginEnabled("mcMMO")) { |
| 405 |
1
1. registerRequirements : removed call to sh/okx/rankup/requirements/RequirementRegistry::addRequirements → NO_COVERAGE |
requirements.addRequirements( |
| 406 | new McMMOSkillRequirement(this), | |
| 407 | new McMMOPowerLevelRequirement(this)); | |
| 408 | } | |
| 409 |
1
1. registerRequirements : negated conditional → SURVIVED |
if (pluginManager.isPluginEnabled("AdvancedAchievements")) { |
| 410 |
1
1. registerRequirements : removed call to sh/okx/rankup/requirements/RequirementRegistry::addRequirements → NO_COVERAGE |
requirements.addRequirements( |
| 411 | new AdvancedAchievementsAchievementRequirement(this), | |
| 412 | new AdvancedAchievementsTotalRequirement(this)); | |
| 413 | } | |
| 414 |
1
1. registerRequirements : negated conditional → SURVIVED |
if (pluginManager.isPluginEnabled("VotingPlugin")) { |
| 415 |
1
1. registerRequirements : removed call to sh/okx/rankup/requirements/RequirementRegistry::addRequirements → NO_COVERAGE |
requirements.addRequirements( |
| 416 | new VotingPluginVotesRequirement(this), | |
| 417 | new VotingPluginPointsRequirement(this, "votingplugin-pointsh"), | |
| 418 | new VotingPluginPointsDeductibleRequirement(this, "votingplugin-points")); | |
| 419 | } | |
| 420 |
1
1. registerRequirements : negated conditional → SURVIVED |
if (Bukkit.getPluginManager().isPluginEnabled("Towny")) { |
| 421 |
1
1. registerRequirements : removed call to sh/okx/rankup/requirements/RequirementRegistry::addRequirements → NO_COVERAGE |
requirements.addRequirements( |
| 422 | new TownyResidentRequirement(this), | |
| 423 | new TownyMayorRequirement(this), | |
| 424 | new TownyMayorNumberResidentsRequirement(this), | |
| 425 | new TownyKingRequirement(this), | |
| 426 | new TownyKingNumberResidentsRequirement(this), | |
| 427 | new TownyKingNumberTownsRequirement(this)); | |
| 428 | } | |
| 429 |
1
1. registerRequirements : negated conditional → KILLED |
if (Bukkit.getPluginManager().isPluginEnabled("TokenManager")) { |
| 430 |
1
1. registerRequirements : removed call to sh/okx/rankup/requirements/RequirementRegistry::addRequirements → NO_COVERAGE |
requirements.addRequirements( |
| 431 | new TokensRequirement(this, "tokenmanager-tokensh"), | |
| 432 | new TokensDeductibleRequirement(this, "tokenmanager-tokens")); | |
| 433 | } | |
| 434 |
1
1. registerRequirements : negated conditional → SURVIVED |
if (Bukkit.getPluginManager().isPluginEnabled("SuperbVote")) { |
| 435 |
1
1. registerRequirements : removed call to sh/okx/rankup/requirements/RequirementRegistry::addRequirements → NO_COVERAGE |
requirements.addRequirements(new SuperbVoteVotesRequirement(this)); |
| 436 | } | |
| 437 | } | |
| 438 | private void setupEconomy() { | |
| 439 | economy = economyProvider.getEconomy(); | |
| 440 | } | |
| 441 | ||
| 442 | public ConfigurationSection getSection(Rank rank, String path) { | |
| 443 | ConfigurationSection rankSection = rank.getSection(); | |
| 444 |
2
1. getSection : negated conditional → KILLED 2. getSection : negated conditional → KILLED |
if (rankSection == null || !rankSection.isConfigurationSection(path)) { |
| 445 |
1
1. getSection : replaced return value with null for sh/okx/rankup/RankupPlugin::getSection → NO_COVERAGE |
return this.messages.getConfigurationSection(path); |
| 446 | } | |
| 447 |
1
1. getSection : replaced return value with null for sh/okx/rankup/RankupPlugin::getSection → KILLED |
return rankSection.getConfigurationSection(path); |
| 448 | } | |
| 449 | ||
| 450 | public MessageBuilder getMessage(Rank rank, Message message) { | |
| 451 | ConfigurationSection messages = rank.getSection(); | |
| 452 |
2
1. getMessage : negated conditional → KILLED 2. getMessage : negated conditional → KILLED |
if (messages == null || !messages.isSet(message.getName())) { |
| 453 | messages = this.messages; | |
| 454 | } | |
| 455 |
1
1. getMessage : replaced return value with null for sh/okx/rankup/RankupPlugin::getMessage → KILLED |
return newMessageBuilder(messages.getString(message.getName())); |
| 456 | } | |
| 457 | ||
| 458 | public MessageBuilder getMessage(Message message) { | |
| 459 |
1
1. getMessage : replaced return value with null for sh/okx/rankup/RankupPlugin::getMessage → KILLED |
return newMessageBuilder(messages.getString(message.getName())); |
| 460 | } | |
| 461 | ||
| 462 | public MessageBuilder getMessage(CommandSender player, Message message, Rank oldRank, Rank rank) { | |
| 463 | Rank actualOldRank; | |
| 464 |
2
1. getMessage : negated conditional → SURVIVED 2. getMessage : negated conditional → NO_COVERAGE |
if (oldRank instanceof Prestige && oldRank.getRank() == null) { |
| 465 | actualOldRank = rankups.getByName(((Prestige) oldRank).getFrom()).getRank(); | |
| 466 | } else { | |
| 467 | actualOldRank = oldRank; | |
| 468 | } | |
| 469 | ||
| 470 |
1
1. getMessage : replaced return value with null for sh/okx/rankup/RankupPlugin::getMessage → KILLED |
return getMessage(oldRank, message) |
| 471 | .replacePlayer(player) | |
| 472 | .replaceRank(rank) | |
| 473 | .replaceOldRank(actualOldRank); | |
| 474 | } | |
| 475 | ||
| 476 | public void sendHeaderFooter(CommandSender sender, Rank rank, Message type) { | |
| 477 | MessageBuilder builder; | |
| 478 |
1
1. sendHeaderFooter : negated conditional → SURVIVED |
if (rank == null) { |
| 479 | builder = getMessage(type) | |
| 480 | .failIfEmpty() | |
| 481 | .replacePlayer(sender); | |
| 482 | } else { | |
| 483 | builder = getMessage(rank, type) | |
| 484 | .failIfEmpty() | |
| 485 | .replacePlayer(sender) | |
| 486 | .replaceRank(rank); | |
| 487 | } | |
| 488 |
1
1. sendHeaderFooter : removed call to sh/okx/rankup/messages/MessageBuilder::send → SURVIVED |
builder.send(sender); |
| 489 | } | |
| 490 | } | |
Mutations | ||
| 96 |
1.1 |
|
| 98 |
1.1 |
|
| 103 |
1.1 |
|
| 105 |
1.1 |
|
| 107 |
1.1 |
|
| 109 |
1.1 |
|
| 111 |
1.1 |
|
| 113 |
1.1 |
|
| 115 |
1.1 |
|
| 136 |
1.1 |
|
| 138 |
1.1 |
|
| 140 |
1.1 |
|
| 141 |
1.1 |
|
| 142 |
1.1 |
|
| 144 |
1.1 |
|
| 145 |
1.1 |
|
| 146 |
1.1 |
|
| 148 |
1.1 |
|
| 150 |
1.1 |
|
| 151 |
1.1 2.2 |
|
| 152 |
1.1 |
|
| 153 |
1.1 2.2 |
|
| 154 |
1.1 |
|
| 155 |
1.1 2.2 |
|
| 158 |
1.1 |
|
| 159 |
1.1 |
|
| 161 |
1.1 |
|
| 162 |
1.1 |
|
| 164 |
1.1 |
|
| 167 |
1.1 |
|
| 168 |
1.1 |
|
| 169 |
1.1 |
|
| 170 |
1.1 |
|
| 173 |
1.1 |
|
| 174 |
1.1 |
|
| 177 |
1.1 |
|
| 178 |
1.1 |
|
| 179 |
1.1 |
|
| 180 |
1.1 |
|
| 181 |
1.1 2.2 |
|
| 184 |
1.1 |
|
| 190 |
1.1 |
|
| 191 |
1.1 |
|
| 192 |
1.1 |
|
| 201 |
1.1 |
|
| 205 |
1.1 |
|
| 210 |
1.1 |
|
| 212 |
1.1 |
|
| 213 |
1.1 |
|
| 215 |
1.1 2.2 |
|
| 216 |
1.1 2.2 |
|
| 218 |
1.1 |
|
| 219 |
1.1 |
|
| 227 |
1.1 2.2 |
|
| 242 |
1.1 |
|
| 246 |
1.1 2.2 |
|
| 255 |
1.1 |
|
| 256 |
1.1 |
|
| 259 |
1.1 |
|
| 260 |
1.1 |
|
| 269 |
1.1 |
|
| 276 |
1.1 |
|
| 288 |
1.1 |
|
| 289 |
1.1 |
|
| 290 |
1.1 |
|
| 296 |
1.1 |
|
| 302 |
1.1 |
|
| 304 |
1.1 |
|
| 308 |
1.1 |
|
| 314 |
1.1 |
|
| 315 |
1.1 |
|
| 317 |
1.1 |
|
| 332 |
1.1 |
|
| 337 |
1.1 |
|
| 338 |
1.1 |
|
| 339 |
1.1 |
|
| 340 |
1.1 |
|
| 341 |
1.1 |
|
| 342 |
1.1 |
|
| 343 |
1.1 |
|
| 344 |
1.1 |
|
| 350 |
1.1 |
|
| 351 |
1.1 |
|
| 358 |
1.1 |
|
| 360 |
1.1 |
|
| 364 |
1.1 |
|
| 365 |
1.1 |
|
| 367 |
1.1 |
|
| 372 |
1.1 |
|
| 373 |
1.1 |
|
| 375 |
1.1 |
|
| 380 |
1.1 |
|
| 397 |
1.1 |
|
| 398 |
1.1 |
|
| 404 |
1.1 |
|
| 405 |
1.1 |
|
| 409 |
1.1 |
|
| 410 |
1.1 |
|
| 414 |
1.1 |
|
| 415 |
1.1 |
|
| 420 |
1.1 |
|
| 421 |
1.1 |
|
| 429 |
1.1 |
|
| 430 |
1.1 |
|
| 434 |
1.1 |
|
| 435 |
1.1 |
|
| 444 |
1.1 2.2 |
|
| 445 |
1.1 |
|
| 447 |
1.1 |
|
| 452 |
1.1 2.2 |
|
| 455 |
1.1 |
|
| 459 |
1.1 |
|
| 464 |
1.1 2.2 |
|
| 470 |
1.1 |
|
| 478 |
1.1 |
|
| 488 |
1.1 |