From 1d1736481c878793cb0fada2a92abe6d5676d569 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 13 Jul 2020 10:19:04 -0700 Subject: [PATCH 01/15] Dev mode --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 616ddb9f3..cea247bd0 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.133 + 2.1.134-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO From ded7fd5bdf509922bebb5f0819da2f9834b3601f Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 13 Jul 2020 10:53:36 -0700 Subject: [PATCH 02/15] Potion NPE fix --- Changelog.txt | 3 +++ src/main/java/com/gmail/nossr50/listeners/EntityListener.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index 57abaea1c..1a88cc01b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.1.134 + Fixed a NPE that could happen with thrown potions + Version 2.1.133 A fix for an 'array out of bounds' error related to players clicking outside the inventory windows has been fixed French locale has been updated (thanks Elikill58) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 5b79227ba..7a6ff5bc0 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -1061,6 +1061,9 @@ public class EntityListener implements Listener { if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) return; + if(event.getPotion().getItem().getItemMeta() == null) + return; + for (PotionEffect effect : ((PotionMeta) event.getPotion().getItem().getItemMeta()).getCustomEffects()) { if (!effect.getType().equals(PotionEffectType.SATURATION)) { return; From 428c093ae4b212881bcf284348be2370ee29b626 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 13 Jul 2020 11:18:16 -0700 Subject: [PATCH 03/15] UUID updater changes + locale fixes Co-authored-by: t00thpick1 --- Changelog.txt | 3 + .../gmail/nossr50/config/HiddenConfig.java | 18 -- .../database/FlatfileDatabaseManager.java | 2 +- .../nossr50/database/SQLDatabaseManager.java | 4 +- .../database/UUIDUpdateAsyncTask.java | 171 ++++++++++-------- src/main/resources/hidden.yml | 10 +- .../resources/locale/locale_hu_HU.properties | 1 - .../resources/locale/locale_ja_JP.properties | 26 +-- .../resources/locale/locale_ru.properties | 1 - 9 files changed, 119 insertions(+), 117 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 1a88cc01b..57c2f7967 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,8 @@ Version 2.1.134 Fixed a NPE that could happen with thrown potions + Fixed a locale mistake in locale hu_HU + Fixed a locale mistake in locale ru + Changed the UUID updater task to not catastrophically fail when requests failed Version 2.1.133 A fix for an 'array out of bounds' error related to players clicking outside the inventory windows has been fixed diff --git a/src/main/java/com/gmail/nossr50/config/HiddenConfig.java b/src/main/java/com/gmail/nossr50/config/HiddenConfig.java index edf89885d..58e6d8816 100644 --- a/src/main/java/com/gmail/nossr50/config/HiddenConfig.java +++ b/src/main/java/com/gmail/nossr50/config/HiddenConfig.java @@ -12,9 +12,6 @@ public class HiddenConfig { private boolean chunkletsEnabled; private int conversionRate; private boolean useEnchantmentBuffs; - private int uuidConvertAmount; - private int mojangRateLimit; - private long mojangLimitPeriod; public HiddenConfig(String fileName) { this.fileName = fileName; @@ -36,9 +33,6 @@ public class HiddenConfig { chunkletsEnabled = config.getBoolean("Options.Chunklets", true); conversionRate = config.getInt("Options.ConversionRate", 1); useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true); - uuidConvertAmount = config.getInt("Options.UUIDConvertAmount", 5); - mojangRateLimit = config.getInt("Options.MojangRateLimit", 50000); - mojangLimitPeriod = config.getLong("Options.MojangLimitPeriod", 600000); } } @@ -53,16 +47,4 @@ public class HiddenConfig { public boolean useEnchantmentBuffs() { return useEnchantmentBuffs; } - - public int getUUIDConvertAmount() { - return uuidConvertAmount; - } - - public int getMojangRateLimit() { - return mojangRateLimit; - } - - public long getMojangLimitPeriod() { - return mojangLimitPeriod; - } } diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index c9e305a14..a634fbf6b 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java @@ -34,7 +34,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { updateLeaderboards(); if (mcMMO.getUpgradeManager().shouldUpgrade(UpgradeType.ADD_UUIDS)) { - new UUIDUpdateAsyncTask(mcMMO.p, getStoredUsers()).runTaskAsynchronously(mcMMO.p); + new UUIDUpdateAsyncTask(mcMMO.p, getStoredUsers()).start(); } } diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index 8fdff41d8..e7637edb8 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -1338,7 +1338,9 @@ public final class SQLDatabaseManager implements DatabaseManager { } if (!names.isEmpty()) { - new UUIDUpdateAsyncTask(mcMMO.p, names).run(); + UUIDUpdateAsyncTask updateTask = new UUIDUpdateAsyncTask(mcMMO.p, names); + updateTask.start(); + updateTask.waitUntilFinished(); } } finally { massUpdateLock.unlock(); diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java index ee5e182fa..7a3901834 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java @@ -1,105 +1,130 @@ package com.gmail.nossr50.runnables.database; -import com.gmail.nossr50.config.HiddenConfig; -import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.datatypes.database.UpgradeType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.uuid.UUIDFetcher; -import org.bukkit.scheduler.BukkitRunnable; +import com.google.common.collect.ImmutableList; +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.logging.Level; -public class UUIDUpdateAsyncTask extends BukkitRunnable { - private mcMMO plugin; - private static final int MAX_LOOKUP = Math.max(HiddenConfig.getInstance().getUUIDConvertAmount(), 100); - private static final int RATE_LIMIT = HiddenConfig.getInstance().getMojangRateLimit(); - private static final long LIMIT_PERIOD = HiddenConfig.getInstance().getMojangLimitPeriod(); - private static final int BATCH_SIZE = MAX_LOOKUP * 3; +public class UUIDUpdateAsyncTask implements Runnable { + private static final Gson GSON = new Gson(); + private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft"; - private List userNames; - private int size; - private int checkedUsers; - private long startMillis; + private static final int HARD_LIMIT_PERIOD = 600; // Mojang rate limit period is 600 seconds, wait that long if they reject us + private static final int RETRY_PERIOD = 60; // Wait 60 seconds on connection failure + private static final int DELAY_PERIOD = 100; // Wait 100 seconds between each batch + + private static final int BATCH_SIZE = 100; // 100 at a time + + private final Object awaiter = new Object(); + private final mcMMO plugin; + private final ImmutableList userNames; + private int position = 0; public UUIDUpdateAsyncTask(mcMMO plugin, List userNames) { this.plugin = plugin; - this.userNames = userNames; - - this.checkedUsers = 0; - this.startMillis = System.currentTimeMillis(); + this.userNames = ImmutableList.copyOf(userNames); } @Override public void run() { - size = userNames.size(); + // First iteration + if (position == 0) + plugin.getLogger().info("Starting to check and update UUIDs, total amount of users: " + userNames.size()); - plugin.getLogger().info("Starting to check and update UUIDs, total amount of users: " + size); + List batch = userNames.subList(position, Math.min(userNames.size(), position + BATCH_SIZE)); - List userNamesSection; - Map fetchedUUIDs = new HashMap(); + Map fetchedUUIDs = new HashMap<>(); + HttpURLConnection connection; + try { + connection = (HttpURLConnection) new URL(PROFILE_URL).openConnection(); + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setUseCaches(false); + connection.setDoInput(true); + connection.setDoOutput(true); - while (size != 0) { - if (checkedUsers + 100 > RATE_LIMIT) { - try { - Thread.sleep(LIMIT_PERIOD); - } catch (InterruptedException e) { - e.printStackTrace(); + String body = GSON.toJson(batch.toArray(new String[0])); + + try (OutputStream output = connection.getOutputStream()) { + output.write(body.getBytes()); + output.flush(); + } + switch (connection.getResponseCode()) { + case HttpURLConnection.HTTP_OK: + break; // All is good + case HttpURLConnection.HTTP_BAD_REQUEST: + case HttpURLConnection.HTTP_FORBIDDEN: + // Rejected, probably rate limit, just wait it out + this.runTaskLaterAsynchronously(plugin, Misc.TICK_CONVERSION_FACTOR * HARD_LIMIT_PERIOD); return; + default: + // Unknown failure + this.runTaskLaterAsynchronously(plugin, Misc.TICK_CONVERSION_FACTOR * RETRY_PERIOD); + return; + } + + try (InputStream input = connection.getInputStream(); + InputStreamReader reader = new InputStreamReader(input)) { + for (JsonObject jsonProfile : GSON.fromJson(reader, JsonObject[].class)) { + UUID id = toUUID(jsonProfile.get("id").getAsString()); + String name = jsonProfile.get("name").getAsString(); + fetchedUUIDs.put(name, id); } - startMillis = System.currentTimeMillis(); - checkedUsers = 0; - } - if (size > MAX_LOOKUP) { - userNamesSection = userNames.subList(size - MAX_LOOKUP, size); - size -= MAX_LOOKUP; - } - else { - userNamesSection = userNames.subList(0, size); - size = 0; - } - - try { - fetchedUUIDs.putAll(new UUIDFetcher(userNamesSection).call()); - } - catch (Exception e) { - // Handle 429 - if(e.getMessage() != null) - { - if (e.getMessage().contains("429")) { - size += userNamesSection.size(); - try { - Thread.sleep(LIMIT_PERIOD); - } catch (InterruptedException ex) { - e.printStackTrace(); - return; - } - continue; - } - } - - plugin.getLogger().log(Level.SEVERE, "Unable to fetch UUIDs!", e); - return; - } - - checkedUsers += userNamesSection.size(); - userNamesSection.clear(); - size = userNames.size(); - - Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis); - if (fetchedUUIDs.size() >= BATCH_SIZE) { - mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs); - fetchedUUIDs = new HashMap(); } + } catch (IOException e) { + // failure + plugin.getLogger().log(Level.SEVERE, "Unable to contact mojang API!", e); + this.runTaskLaterAsynchronously(plugin, Misc.TICK_CONVERSION_FACTOR * RETRY_PERIOD); + return; } - if (fetchedUUIDs.size() == 0 || mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs)) { + if (fetchedUUIDs.size() != 0) + mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs); + + position += batch.size(); + plugin.getLogger().info(String.format("Conversion progress: %d/%d users", position, userNames.size())); + + if (position == userNames.size()) + { mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS); - plugin.getLogger().info("UUID upgrade completed!"); + awaiter.notify(); + } + else + this.runTaskLaterAsynchronously(plugin, Misc.TICK_CONVERSION_FACTOR * DELAY_PERIOD); // Schedule next batch + } + + // Bukkit runnables don't let themselves reschedule themselves, so we are a pseudo bukkit runnable. + private void runTaskLaterAsynchronously(mcMMO plugin, int delay) { + plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, this, delay); + } + + public void start() { + plugin.getServer().getScheduler().runTaskAsynchronously(plugin, this); + } + + private static UUID toUUID(String id) { + return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32)); + } + + public void waitUntilFinished() { + try { + awaiter.wait(); + } catch (InterruptedException e) { + // I guess we don't care in this event } } } diff --git a/src/main/resources/hidden.yml b/src/main/resources/hidden.yml index c79be996c..a6f89e025 100644 --- a/src/main/resources/hidden.yml +++ b/src/main/resources/hidden.yml @@ -8,12 +8,4 @@ Options: # Square root of the number of chunks to convert per tick. ConversionRate: 1 # true to use enchantment buffs for Super Breaker & Giga Drill Breaker, false to use potion buffs - EnchantmentBuffs: true - - # Amount of users to convert every interval - UUIDConvertAmount: 100 - # Amount of users to be converted at a time before waiting MojangLimitPeriod milliseconds to begin again - # This setting is for large servers to avoid being temp banned from mojang api - MojangRateLimit: 300 - # Amount of time to wait after hitting the MojangRateLimit in UUID conversion - MojangLimitPeriod: 6000 + EnchantmentBuffs: true \ No newline at end of file diff --git a/src/main/resources/locale/locale_hu_HU.properties b/src/main/resources/locale/locale_hu_HU.properties index fb3fdce37..a037be8ca 100644 --- a/src/main/resources/locale/locale_hu_HU.properties +++ b/src/main/resources/locale/locale_hu_HU.properties @@ -979,7 +979,6 @@ Skills.Child=[[GOLD]](ALK\u00C9PESS\u00C9G) Skills.Disarmed=[[DARK_RED]]Lefegyvereztek! Skills.Header=-----[] [[GREEN]]{0}[[RED]] []----- Skills.NeedMore=[[DARK_RED]]T\u00F6bb[[GRAY]]{0}-ra/re van sz\u00FCks\u00E9ged -Skills.NeedMore=[[DARK_RED]]T\u00F6bb[[GRAY]]{0}{1}-ra/re van sz\u00FCks\u00E9ged Skills.Parents= ANYAK\u00C9PESS\u00C9G Skills.Stats={0}[[GREEN]]{1}[[DARK_AQUA]] XP([[GRAY]]{2}[[DARK_AQUA]]/[[GRAY]]{3}[[DARK_AQUA]]) Skills.ChildStats={0}[[GREEN]]{1} diff --git a/src/main/resources/locale/locale_ja_JP.properties b/src/main/resources/locale/locale_ja_JP.properties index efaa25b8f..0990ad327 100644 --- a/src/main/resources/locale/locale_ja_JP.properties +++ b/src/main/resources/locale/locale_ja_JP.properties @@ -829,9 +829,9 @@ Commands.xplock.locked=[[GOLD]]\u3042\u306a\u305f\u306eXP\u30d0\u30fc\u306f\u73f Commands.xplock.unlocked=[[GOLD]]\u3042\u306a\u305f\u306eXP\u30d0\u30fc\u306f\u73fe\u5728[[GREEN]]\u30ed\u30c3\u30af\u89e3\u9664[[GOLD]]\u3055\u308c\u3066\u3044\u307e\u3059\uff01 Commands.xprate.modified=[[RED]]XP\u30ec\u30fc\u30c8\u306f{0}\u306b\u5909\u66f4\u3055\u308c\u307e\u3057\u305f Commands.xprate.over=[[RED]]mcMMO XP\u30ec\u30fc\u30c8\u30a4\u30d9\u30f3\u30c8\u304c\u7d42\u308f\u308a\u307e\u3057\u305f\uff01 -Commands.xprate.proper.0=[[RED]]XP\u30ec\u30fc\u30c8\u3092\u5909\u66f4\u3059\u308b\u305f\u3081\u306e\u6b63\u3057\u3044\u65b9\u6cd5\u306f\/xprate \u3067\u3059\u3002 -Commands.xprate.proper.1=[[RED]]XP\u30ec\u30fc\u30c8\u3092\u30c7\u30d5\u30a9\u30eb\u30c8\u306b\u623b\u3059\u6b63\u3057\u3044\u65b9\u6cd5\u306f\/xprate reset \u3067\u3059\u3002 -Commands.xprate.proper.2=[[RED]]XP\u30ec\u30fc\u30c8\u3092\u30c7\u30d5\u30a9\u30eb\u30c8\u306b\u623b\u3059\u6b63\u3057\u3044\u65b9\u6cd5\u306f\/xprate reset \u3067\u3059\u3002 +Commands.xprate.proper.0=[[RED]]XP\u30ec\u30fc\u30c8\u3092\u5909\u66f4\u3059\u308b\u305f\u3081\u306e\u6b63\u3057\u3044\u65b9\u6cd5\u306f/xprate \u3067\u3059\u3002 +Commands.xprate.proper.1=[[RED]]XP\u30ec\u30fc\u30c8\u3092\u30c7\u30d5\u30a9\u30eb\u30c8\u306b\u623b\u3059\u6b63\u3057\u3044\u65b9\u6cd5\u306f/xprate reset \u3067\u3059\u3002 +Commands.xprate.proper.2=[[RED]]XP\u30ec\u30fc\u30c8\u3092\u30c7\u30d5\u30a9\u30eb\u30c8\u306b\u623b\u3059\u6b63\u3057\u3044\u65b9\u6cd5\u306f/xprate reset \u3067\u3059\u3002 Commands.NegativeNumberWarn=\u8ca0\u306e\u5024\u3092\u4f7f\u308f\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002 Commands.Event.Start=[[GREEN]]mcMMO[[GOLD]] \u30a4\u30d9\u30f3\u30c8\uff01 Commands.Event.Stop=[[GREEN]]mcMMO[[DARK_AQUA]] \u30a4\u30d9\u30f3\u30c8\u7d42\u4e86\uff01 @@ -1056,17 +1056,17 @@ Smelting.SkillName=\u7cbe\u932c # COMMAND DESCRIPTIONS Commands.Description.addlevels=\u30e6\u30fc\u30b6\u30fc\u306bmcMMO\u30ec\u30d9\u30eb\u3092\u8ffd\u52a0\u3059\u308b -Commands.Description.adminchat=mcMMO\u7ba1\u7406\u8005\u30c1\u30e3\u30c3\u30c8\u306e\u30aa\u30f3\/\u30aa\u30d5\u306e\u5207\u308a\u66ff\u3048\u3001\u307e\u305f\u306f\u7ba1\u7406\u8005\u30c1\u30e3\u30c3\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u9001\u4fe1 +Commands.Description.adminchat=mcMMO\u7ba1\u7406\u8005\u30c1\u30e3\u30c3\u30c8\u306e\u30aa\u30f3/\u30aa\u30d5\u306e\u5207\u308a\u66ff\u3048\u3001\u307e\u305f\u306f\u7ba1\u7406\u8005\u30c1\u30e3\u30c3\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u9001\u4fe1 Commands.Description.addxp=\u30e6\u30fc\u30b6\u30fc\u306bmcMMO XP\u3092\u8ffd\u52a0\u3059\u308b -Commands.Description.hardcore=mcMMO\u30cf\u30fc\u30c9\u30b3\u30a2\u306e\u30d1\u30fc\u30bb\u30f3\u30c6\u30fc\u30b8\u3092\u5909\u66f4\u3059\u308b\u304b\u3001\u30cf\u30fc\u30c9\u30b3\u30a2\u30e2\u30fc\u30c9\u306e\u30aa\u30f3\/\u30aa\u30d5\u3092\u5207\u308a\u66ff\u3048\u307e\u3059 +Commands.Description.hardcore=mcMMO\u30cf\u30fc\u30c9\u30b3\u30a2\u306e\u30d1\u30fc\u30bb\u30f3\u30c6\u30fc\u30b8\u3092\u5909\u66f4\u3059\u308b\u304b\u3001\u30cf\u30fc\u30c9\u30b3\u30a2\u30e2\u30fc\u30c9\u306e\u30aa\u30f3/\u30aa\u30d5\u3092\u5207\u308a\u66ff\u3048\u307e\u3059 Commands.Description.inspect=\u4ed6\u306e\u30d7\u30ec\u30a4\u30e4\u30fc\u306e\u8a73\u7d30\u306amcMMO\u60c5\u5831\u3092\u898b\u308b -Commands.Description.mcability=\u53f3\u30af\u30ea\u30c3\u30af\u3067mcMMO\u30a2\u30d3\u30ea\u30c6\u30a3\u306e\u6709\u52b9\u306b\u3064\u3044\u3066\u30aa\u30f3\/\u30aa\u30d5\u3092\u5207\u308a\u66ff\u3048\u307e\u3059 +Commands.Description.mcability=\u53f3\u30af\u30ea\u30c3\u30af\u3067mcMMO\u30a2\u30d3\u30ea\u30c6\u30a3\u306e\u6709\u52b9\u306b\u3064\u3044\u3066\u30aa\u30f3/\u30aa\u30d5\u3092\u5207\u308a\u66ff\u3048\u307e\u3059 Commands.Description.mccooldown=mcMMO\u30a2\u30d3\u30ea\u30c6\u30a3\u306e\u30af\u30fc\u30eb\u30c0\u30a6\u30f3\u3092\u3059\u3079\u3066\u898b\u308b -Commands.Description.mcchatspy=mcMMO\u30d1\u30fc\u30c6\u30a3\u30fc\u30c1\u30e3\u30c3\u30c8\u306e\u30b9\u30d1\u30a4\u306b\u3064\u3044\u3066\u30aa\u30f3\/\u30aa\u30d5\u3092\u5207\u308a\u66ff\u3048\u307e\u3059 -Commands.Description.mcgod=mcMMO\u306e\u30b4\u30c3\u30c9\u30e2\u30fc\u30c9\u306e\u30aa\u30f3\/\u30aa\u30d5\u3092\u5207\u308a\u66ff\u3048\u307e\u3059 +Commands.Description.mcchatspy=mcMMO\u30d1\u30fc\u30c6\u30a3\u30fc\u30c1\u30e3\u30c3\u30c8\u306e\u30b9\u30d1\u30a4\u306b\u3064\u3044\u3066\u30aa\u30f3/\u30aa\u30d5\u3092\u5207\u308a\u66ff\u3048\u307e\u3059 +Commands.Description.mcgod=mcMMO\u306e\u30b4\u30c3\u30c9\u30e2\u30fc\u30c9\u306e\u30aa\u30f3/\u30aa\u30d5\u3092\u5207\u308a\u66ff\u3048\u307e\u3059 Commands.Description.mchud=mcMMO HUD\u30b9\u30bf\u30a4\u30eb\u3092\u5909\u66f4\u3059\u308b Commands.Description.mcmmo=mcMMO\u306e\u7c21\u5358\u306a\u8aac\u660e\u3092\u8868\u793a\u3059\u308b -Commands.Description.mcnotify=mcMMO\u30a2\u30d3\u30ea\u30c6\u30a3\u306e\u30c1\u30e3\u30c3\u30c8\u8868\u793a\u901a\u77e5\u306b\u3064\u3044\u3066\u30aa\u30f3\/\u30aa\u30d5\u3092\u5207\u308a\u66ff\u3048\u307e\u3059 +Commands.Description.mcnotify=mcMMO\u30a2\u30d3\u30ea\u30c6\u30a3\u306e\u30c1\u30e3\u30c3\u30c8\u8868\u793a\u901a\u77e5\u306b\u3064\u3044\u3066\u30aa\u30f3/\u30aa\u30d5\u3092\u5207\u308a\u66ff\u3048\u307e\u3059 Commands.Description.mcpurge=mcMMO\u30ec\u30d9\u30eb\u306e\u306a\u3044\u30e6\u30fc\u30b6\u30fc\u304a\u3088\u3073{0}\u30f6\u6708\u4ee5\u4e0a\u63a5\u7d9a\u3057\u3066\u3044\u306a\u3044\u30e6\u30fc\u30b6\u30fc\u3092mcMMO\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u524a\u9664\u3057\u307e\u3059\u3002 Commands.Description.mcrank=\u30d7\u30ec\u30a4\u30e4\u30fc\u306emcMMO\u30e9\u30f3\u30ad\u30f3\u30b0\u3092\u8868\u793a\u3059\u308b Commands.Description.mcrefresh=mcMMO\u306e\u3059\u3079\u3066\u306e\u30af\u30fc\u30eb\u30c0\u30a6\u30f3\u3092\u66f4\u65b0\u3059\u308b @@ -1078,13 +1078,13 @@ Commands.Description.mmoedit=\u30e6\u30fc\u30b6\u30fc\u306emcMMO\u30ec\u30d9\u30 Commands.Description.mmodebug=\u30d6\u30ed\u30c3\u30af\u3092\u53e9\u3044\u305f\u3068\u304d\u306b\u6709\u7528\u306a\u60c5\u5831\u3092\u51fa\u529b\u3059\u308b\u30c7\u30d0\u30c3\u30b0\u30e2\u30fc\u30c9\u3092\u5207\u308a\u66ff\u3048\u307e\u3059\u3002 Commands.Description.mmoupdate=mcMMO\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u53e4\u3044\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u73fe\u5728\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u79fb\u884c\u3057\u307e\u3059\u3002 Commands.Description.mcconvert=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u7a2e\u985e\u307e\u305f\u306f\u7d4c\u9a13\u5024\u5f0f\u306e\u7a2e\u985e\u3092\u5909\u63db\u3059\u308b -Commands.Description.mmoshowdb=\u73fe\u5728\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30bf\u30a4\u30d7\u306e\u540d\u524d\u3092\u8868\u793a\u3057\u307e\u3059\uff08\u5f8c\u3067\/mmoupdate\u3067\u4f7f\u7528\u3059\u308b\u305f\u3081\uff09 +Commands.Description.mmoshowdb=\u73fe\u5728\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30bf\u30a4\u30d7\u306e\u540d\u524d\u3092\u8868\u793a\u3057\u307e\u3059\uff08\u5f8c\u3067/mmoupdate\u3067\u4f7f\u7528\u3059\u308b\u305f\u3081\uff09 Commands.Description.party=\u3055\u307e\u3056\u307e\u306amcMMO\u30d1\u30fc\u30c6\u30a3\u306e\u8a2d\u5b9a\u3092\u7ba1\u7406\u3059\u308b -Commands.Description.partychat=mcMMO\u30d1\u30fc\u30c6\u30a3\u30c1\u30e3\u30c3\u30c8\u306e\u30aa\u30f3\/\u30aa\u30d5\u3092\u5207\u308a\u66ff\u3048\u305f\u308a\u3001\u30d1\u30fc\u30c6\u30a3\u30c1\u30e3\u30c3\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u4fe1\u3057\u305f\u308a\u3057\u307e\u3059 +Commands.Description.partychat=mcMMO\u30d1\u30fc\u30c6\u30a3\u30c1\u30e3\u30c3\u30c8\u306e\u30aa\u30f3/\u30aa\u30d5\u3092\u5207\u308a\u66ff\u3048\u305f\u308a\u3001\u30d1\u30fc\u30c6\u30a3\u30c1\u30e3\u30c3\u30c8\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u4fe1\u3057\u305f\u308a\u3057\u307e\u3059 Commands.Description.ptp=mcMMO\u30d1\u30fc\u30c6\u30a3\u30fc\u30e1\u30f3\u30d0\u30fc\u306b\u30c6\u30ec\u30dd\u30fc\u30c8\u3059\u308b Commands.Description.Skill={0}\u306e\u8a73\u7d30\u306amcMMO\u30b9\u30ad\u30eb\u60c5\u5831\u3092\u8868\u793a\u3057\u307e\u3059 Commands.Description.skillreset=\u30e6\u30fc\u30b6\u30fc\u306emcMMO\u30ec\u30d9\u30eb\u3092\u30ea\u30bb\u30c3\u30c8\u3059\u308b -Commands.Description.vampirism=mcMMO\u306e\u30f4\u30a1\u30f3\u30d1\u30a4\u30a2\u306e\u5272\u5408\u3092\u5909\u66f4\u3059\u308b\u304b\u3001\u307e\u305f\u306f\u30f4\u30a1\u30f3\u30d1\u30a4\u30a2\u30e2\u30fc\u30c9\u306e\u30aa\u30f3\/\u30aa\u30d5\u306b\u5207\u308a\u66ff\u3048\u307e\u3059 +Commands.Description.vampirism=mcMMO\u306e\u30f4\u30a1\u30f3\u30d1\u30a4\u30a2\u306e\u5272\u5408\u3092\u5909\u66f4\u3059\u308b\u304b\u3001\u307e\u305f\u306f\u30f4\u30a1\u30f3\u30d1\u30a4\u30a2\u30e2\u30fc\u30c9\u306e\u30aa\u30f3/\u30aa\u30d5\u306b\u5207\u308a\u66ff\u3048\u307e\u3059 Commands.Description.xplock=mcMMO XP\u30d0\u30fc\u3092\u7279\u5b9a\u306emcMMO\u30b9\u30ad\u30eb\u306b\u56fa\u5b9a\u3059\u308b Commands.Description.xprate=mcMMO XP\u306e\u30ec\u30fc\u30c8\u3092\u5909\u66f4\u3059\u308b\u304b\u3001mcMMO XP\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u958b\u59cb\u3059\u308b @@ -1117,7 +1117,7 @@ Holiday.AprilFools.Levelup=[[GOLD]]{0}\u306f\u30ec\u30d9\u30eb[[GREEN]]{1}[[GOLD Holiday.Anniversary=[[BLUE]]{0}\u5468\u5e74\u8a18\u5ff5\uff01\n[[BLUE]]nossr50\u306e\u5168\u3066\u306e\u4ed5\u4e8b\u3068\u5168\u3066\u306e\u958b\u767a\u3092\u8a18\u5ff5\u3057\u3066\uff01 # Reminder Messages -Reminder.Squelched=[[GRAY]]\u30ea\u30de\u30a4\u30f3\u30c0\u30fc: \u3042\u306a\u305f\u306f\u73fe\u5728mcMMO\u304b\u3089\u901a\u77e5\u3092\u53d7\u3051\u53d6\u3063\u3066\u3044\u307e\u305b\u3093\u3002\u901a\u77e5\u3092\u6709\u52b9\u306b\u3059\u308b\u305f\u3081\u306b\u306f\/mcnotify\u30b3\u30de\u30f3\u30c9\u3092\u3082\u3046\u4e00\u5ea6\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u308c\u306f\u81ea\u52d5\u5316\u3055\u308c\u305f1\u6642\u9593\u3054\u3068\u306e\u901a\u77e5\u3067\u3059\u3002 +Reminder.Squelched=[[GRAY]]\u30ea\u30de\u30a4\u30f3\u30c0\u30fc: \u3042\u306a\u305f\u306f\u73fe\u5728mcMMO\u304b\u3089\u901a\u77e5\u3092\u53d7\u3051\u53d6\u3063\u3066\u3044\u307e\u305b\u3093\u3002\u901a\u77e5\u3092\u6709\u52b9\u306b\u3059\u308b\u305f\u3081\u306b\u306f/mcnotify\u30b3\u30de\u30f3\u30c9\u3092\u3082\u3046\u4e00\u5ea6\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u308c\u306f\u81ea\u52d5\u5316\u3055\u308c\u305f1\u6642\u9593\u3054\u3068\u306e\u901a\u77e5\u3067\u3059\u3002 # Locale Locale.Reloaded=[[GREEN]]\u30ed\u30b1\u30fc\u30eb \u30ea\u30ed\u30fc\u30c9\uff01 diff --git a/src/main/resources/locale/locale_ru.properties b/src/main/resources/locale/locale_ru.properties index 7e327c4cd..4811eb8c3 100644 --- a/src/main/resources/locale/locale_ru.properties +++ b/src/main/resources/locale/locale_ru.properties @@ -466,7 +466,6 @@ Taming.Summon.Complete=[[GREEN]]\u0412\u044b\u0437\u043e\u0432 \u0437\u0430\u043 Taming.Summon.Fail.Ocelot=\u0412\u043e\u043a\u0440\u0443\u0433 \u0412\u0430\u0441 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043e\u0446\u0435\u043b\u043e\u0442\u043e\u0432. Taming.Summon.Fail.Wolf=\u0412\u043e\u043a\u0440\u0443\u0433 \u0412\u0430\u0441 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0432\u043e\u043b\u043a\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0437\u0432\u0430\u0442\u044c \u0435\u0449\u0435. Taming.Summon.Fail.Horse=\u0412\u043e\u043a\u0440\u0443\u0433 \u0432\u0430\u0441 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u043b\u043e\u0448\u0430\u0434\u0435\u0439 \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0437\u0432\u0430\u0442\u044c \u0435\u0449\u0435. -Taming.Summon.Name.Format={0}s {1} Taming.Summon.COTW.Success.WithoutLifespan=[[GREEN]](\u0417\u043e\u0432 \u041f\u0440\u0435\u0434\u043a\u043e\u0432) [[GRAY]]\u0412\u044b \u043f\u0440\u0438\u0437\u0432\u0430\u043b\u0438 [[GOLD]]{0}[[GRAY]] Taming.Summon.COTW.Success.WithLifespan=[[GREEN]](\u0417\u043e\u0432 \u041f\u0440\u0435\u0434\u043a\u043e\u0432) [[GRAY]]\u0412\u044b \u043f\u0440\u0438\u0437\u0432\u0430\u043b\u0438 [[GOLD]]{0}[[GRAY]] \u043d\u0430 [[GOLD]]{1}[[GRAY]] \u0441\u0435\u043a. Taming.Summon.COTW.Limit=[[GREEN]](\u0417\u043e\u0432 \u041f\u0440\u0435\u0434\u043a\u043e\u0432) [[GRAY]]\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u043c\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e [[RED]]{0} [[GRAY]]\u043f\u0440\u0438\u0437\u0432\u0430\u043d\u043d\u044b\u0445 [[GRAY]]{1} \u0436\u0438\u0432\u043e\u0442\u043d\u044b\u0445 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. From 7eae59a0b3b2ac8cc6aa049bd55d0b8d4d2eb96d Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 13 Jul 2020 11:39:03 -0700 Subject: [PATCH 04/15] Misc code fixes --- extras/mods/1.6.x/extrabiomesxl.blocks.yml | 18 +-- extras/mods/1.6.x/metallurgy3.tools.yml | 18 --- extras/mods/1.6.x/twilightforest.armor.yml | 20 --- .../nossr50/commands/McImportCommand.java | 11 +- .../nossr50/commands/McconvertCommand.java | 23 ++- .../nossr50/commands/McnotifyCommand.java | 21 ++- .../nossr50/commands/McscoreboardCommand.java | 8 +- .../gmail/nossr50/commands/ToggleCommand.java | 10 +- .../admin/McmmoReloadLocaleCommand.java | 22 ++- .../nossr50/commands/chat/ChatCommand.java | 10 +- .../database/ConvertDatabaseCommand.java | 78 +++++----- .../commands/database/McpurgeCommand.java | 19 ++- .../commands/database/McremoveCommand.java | 50 +++---- .../commands/database/MmoshowdbCommand.java | 19 ++- .../experience/ConvertExperienceCommand.java | 51 ++++--- .../hardcore/HardcoreModeCommand.java | 14 +- .../commands/party/PartyAcceptCommand.java | 48 +++---- .../party/PartyChangeOwnerCommand.java | 37 +++-- .../nossr50/commands/party/PartyCommand.java | 36 ++--- .../commands/party/PartyDisbandCommand.java | 38 +++-- .../commands/party/PartyHelpCommand.java | 29 ++-- .../commands/party/PartyInviteCommand.java | 91 ++++++------ .../commands/party/PartyKickCommand.java | 60 ++++---- .../commands/party/PartyLockCommand.java | 2 +- .../commands/party/PartyQuitCommand.java | 36 +++-- .../commands/party/PartyRenameCommand.java | 84 ++++++----- .../commands/party/PartyXpShareCommand.java | 27 ++-- .../alliance/PartyAllianceAcceptCommand.java | 42 +++--- .../party/alliance/PartyAllianceCommand.java | 24 ++-- .../alliance/PartyAllianceDisbandCommand.java | 34 ++--- .../alliance/PartyAllianceInviteCommand.java | 100 +++++++------ .../commands/party/teleport/PtpCommand.java | 120 ++++++++-------- .../commands/player/InspectCommand.java | 133 +++++++++--------- .../commands/player/MccooldownCommand.java | 57 ++++---- .../commands/player/McrankCommand.java | 10 +- .../commands/player/McstatsCommand.java | 57 ++++---- .../nossr50/commands/player/MctopCommand.java | 8 +- .../commands/skills/AcrobaticsCommand.java | 2 +- .../nossr50/commands/skills/AprilCommand.java | 55 ++++---- .../commands/skills/ExcavationCommand.java | 2 +- .../commands/skills/HerbalismCommand.java | 2 +- .../commands/skills/MmoInfoCommand.java | 8 +- .../nossr50/commands/skills/SkillCommand.java | 84 +++++------ .../commands/skills/SkillGuideCommand.java | 6 +- .../commands/skills/UnarmedCommand.java | 4 +- .../commands/skills/WoodcuttingCommand.java | 2 +- .../gmail/nossr50/config/AdvancedConfig.java | 3 +- .../gmail/nossr50/config/ConfigLoader.java | 2 +- .../gmail/nossr50/config/HiddenConfig.java | 2 +- .../com/gmail/nossr50/config/RankConfig.java | 2 +- .../com/gmail/nossr50/config/SoundConfig.java | 2 +- .../gmail/nossr50/config/WorldBlacklist.java | 2 +- .../config/skills/alchemy/PotionConfig.java | 21 ++- .../config/skills/repair/RepairConfig.java | 2 +- .../config/skills/salvage/SalvageConfig.java | 2 +- .../nossr50/database/DatabaseManager.java | 38 ++--- .../database/FlatfileDatabaseManager.java | 28 ++-- .../nossr50/database/SQLDatabaseManager.java | 7 +- .../nossr50/datatypes/BlockSnapshot.java | 2 +- .../nossr50/datatypes/MobHealthbarType.java | 2 +- .../nossr50/datatypes/chat/ChatMode.java | 6 +- .../nossr50/datatypes/mods/CustomBlock.java | 6 +- .../nossr50/datatypes/mods/CustomEntity.java | 12 +- .../nossr50/datatypes/mods/CustomTool.java | 6 +- .../nossr50/datatypes/party/PartyLeader.java | 4 +- .../nossr50/datatypes/player/McMMOPlayer.java | 8 +- .../datatypes/player/PlayerProfile.java | 8 +- .../nossr50/datatypes/skills/ItemType.java | 2 +- .../datatypes/skills/PrimarySkillType.java | 14 +- .../datatypes/skills/SubSkillType.java | 10 +- .../datatypes/skills/SuperAbilityType.java | 12 +- .../nossr50/datatypes/skills/ToolType.java | 6 +- .../skills/alchemy/AlchemyPotion.java | 2 +- .../datatypes/skills/alchemy/PotionStage.java | 2 +- .../skills/subskills/acrobatics/Roll.java | 38 ++--- .../skills/subskills/taming/TamingSummon.java | 12 +- .../nossr50/events/chat/McMMOChatEvent.java | 4 +- .../events/chat/McMMOPartyChatEvent.java | 2 +- .../hardcore/McMMOPlayerVampirismEvent.java | 2 +- .../party/McMMOPartyAllianceChangeEvent.java | 8 +- .../events/party/McMMOPartyChangeEvent.java | 8 +- .../events/party/McMMOPartyLevelUpEvent.java | 2 +- .../events/party/McMMOPartyTeleportEvent.java | 4 +- .../events/party/McMMOPartyXpGainEvent.java | 2 +- .../players/McMMOPlayerProfileLoadEvent.java | 4 +- .../abilities/McMMOPlayerAbilityEvent.java | 2 +- .../skills/alchemy/McMMOPlayerBrewEvent.java | 2 +- .../fishing/McMMOPlayerMagicHunterEvent.java | 2 +- .../repair/McMMOPlayerRepairCheckEvent.java | 6 +- .../salvage/McMMOPlayerSalvageCheckEvent.java | 6 +- .../unarmed/McMMOPlayerDisarmEvent.java | 2 +- .../nossr50/listeners/InteractionManager.java | 6 +- .../gmail/nossr50/locale/LocaleLoader.java | 2 +- src/main/java/com/gmail/nossr50/mcMMO.java | 3 +- .../com/gmail/nossr50/party/PartyManager.java | 6 +- .../MobHealthDisplayUpdaterTask.java | 2 +- .../nossr50/runnables/PistonTrackerTask.java | 6 +- .../runnables/StickyPistonTrackerTask.java | 6 +- .../runnables/backups/CleanBackupsTask.java | 6 +- .../commands/McScoreboardKeepTask.java | 2 +- .../database/DatabaseConversionTask.java | 7 +- .../database/FormulaConversionTask.java | 4 +- .../runnables/database/UserPurgeTask.java | 2 +- .../runnables/items/ChimaeraWingWarmup.java | 2 +- .../runnables/items/TeleportationWarmup.java | 4 +- .../runnables/party/PartyChatTask.java | 8 +- .../player/PlayerProfileSaveTask.java | 4 +- .../player/PlayerUpdateInventoryTask.java | 2 +- .../runnables/skills/AbilityCooldownTask.java | 4 +- .../runnables/skills/AbilityDisableTask.java | 10 +- .../skills/AlchemyBrewCheckTask.java | 6 +- .../runnables/skills/AlchemyBrewTask.java | 10 +- .../runnables/skills/AwardCombatXpTask.java | 12 +- .../runnables/skills/BleedTimerTask.java | 5 +- .../skills/HerbalismBlockUpdaterTask.java | 2 +- .../skills/SkillUnlockNotificationTask.java | 6 +- .../runnables/skills/ToolLowerTask.java | 4 +- .../skills/acrobatics/AcrobaticsManager.java | 4 +- .../gmail/nossr50/skills/alchemy/Alchemy.java | 4 +- .../gmail/nossr50/skills/archery/Archery.java | 2 +- .../nossr50/skills/archery/TrackedEntity.java | 4 +- .../nossr50/skills/child/FamilyTree.java | 2 +- .../skills/repair/repairables/Repairable.java | 20 +-- .../repair/repairables/RepairableManager.java | 10 +- .../repair/repairables/SimpleRepairable.java | 2 +- .../repairables/SimpleRepairableManager.java | 2 +- .../salvage/salvageables/Salvageable.java | 18 +-- .../salvageables/SalvageableManager.java | 10 +- .../SimpleSalvageableManager.java | 2 +- .../skills/taming/TrackedTamingEntity.java | 4 +- .../gmail/nossr50/util/HolidayManager.java | 4 +- .../com/gmail/nossr50/util/LogFilter.java | 2 +- .../gmail/nossr50/util/MaterialMapStore.java | 70 ++++----- .../java/com/gmail/nossr50/util/Misc.java | 4 +- .../com/gmail/nossr50/util/ModManager.java | 44 +++--- .../nossr50/util/TextComponentFactory.java | 9 +- .../util/blockmeta/ChunkletManager.java | 36 ++--- .../nossr50/util/blockmeta/ChunkletStore.java | 10 +- .../blockmeta/chunkmeta/ChunkManager.java | 54 +++---- .../util/blockmeta/chunkmeta/ChunkStore.java | 18 +-- .../blockmeta/chunkmeta/HashChunkManager.java | 11 +- .../chunkmeta/McMMOSimpleRegionFile.java | 2 +- .../commands/CommandRegistrationManager.java | 4 +- .../util/compat/CompatibilityManager.java | 32 ++--- .../util/experience/FormulaManager.java | 2 +- .../version/SimpleNumericVersion.java | 2 +- .../util/scoreboards/ScoreboardManager.java | 4 +- .../util/scoreboards/ScoreboardWrapper.java | 2 +- .../util/skills/ParticleEffectUtils.java | 2 +- .../gmail/nossr50/util/skills/PerksUtils.java | 5 +- .../gmail/nossr50/util/skills/RankUtils.java | 3 +- .../gmail/nossr50/util/uuid/UUIDFetcher.java | 111 --------------- .../shatt/backup/ZipLibrary.java | 18 +-- 153 files changed, 1139 insertions(+), 1474 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/util/uuid/UUIDFetcher.java diff --git a/extras/mods/1.6.x/extrabiomesxl.blocks.yml b/extras/mods/1.6.x/extrabiomesxl.blocks.yml index a17898063..b689b254a 100755 --- a/extras/mods/1.6.x/extrabiomesxl.blocks.yml +++ b/extras/mods/1.6.x/extrabiomesxl.blocks.yml @@ -99,10 +99,6 @@ Woodcutting: Double_Drops_Enabled: true Is_Log: true # Fir Quarters - X2209|1: - XP_Gain: 80 - Double_Drops_Enabled: true - Is_Log: true X2211|1: XP_Gain: 100 Double_Drops_Enabled: true @@ -116,10 +112,6 @@ Woodcutting: Double_Drops_Enabled: true Is_Log: true # Oak Quarters - X2209|2: - XP_Gain: 70 - Double_Drops_Enabled: true - Is_Log: true X2211|2: XP_Gain: 100 Double_Drops_Enabled: true @@ -133,15 +125,7 @@ Woodcutting: Double_Drops_Enabled: true Is_Log: true # Acacia - X2209|1: - XP_Gain: 80 - Double_Drops_Enabled: true - Is_Log: true - # Cypress - X2209|2: - XP_Gain: 90 - Double_Drops_Enabled: true - Is_Log: true + # Cypress # Bald Cypress Quarter X2225|0: XP_Gain: 90 diff --git a/extras/mods/1.6.x/metallurgy3.tools.yml b/extras/mods/1.6.x/metallurgy3.tools.yml index 9a4938917..2e827d221 100644 --- a/extras/mods/1.6.x/metallurgy3.tools.yml +++ b/extras/mods/1.6.x/metallurgy3.tools.yml @@ -366,25 +366,7 @@ Axes: ### Bows: #Bow_1 - X999: - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material: X99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 #Bow_2 - X999: - XP_Modifer: 1.0 - Ability_Enabled: true - Tier: 1 - Repairable: true - Repair_Material: X99 - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 9 - Durability: 9999 # # Settings for Hoes diff --git a/extras/mods/1.6.x/twilightforest.armor.yml b/extras/mods/1.6.x/twilightforest.armor.yml index 51f4b219d..18dd80cd2 100755 --- a/extras/mods/1.6.x/twilightforest.armor.yml +++ b/extras/mods/1.6.x/twilightforest.armor.yml @@ -68,17 +68,7 @@ Chestplates: Repair_Material_Quantity: 8 Durability: 320 # Knightmetal - X28035: - Repairable: true - Repair_Material: X28032 - Repair_Material_Pretty_Name: "Knightmetal Ingot" - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 8 - Durability: 320 # Phantom - X28035: - Repairable: false - Durability: 480 Helmets: # Ironwood @@ -106,17 +96,7 @@ Helmets: Repair_Material_Quantity: 5 Durability: 220 # Knightmetal - X28034: - Repairable: true - Repair_Material: X28032 - Repair_Material_Pretty_Name: "Knightmetal Ingot" - Repair_Material_Data_Value: 0 - Repair_Material_Quantity: 5 - Durability: 220 # Phantom - X28034: - Repairable: false - Durability: 330 Leggings: # Ironwood diff --git a/src/main/java/com/gmail/nossr50/commands/McImportCommand.java b/src/main/java/com/gmail/nossr50/commands/McImportCommand.java index 7c953a88a..e133d1392 100644 --- a/src/main/java/com/gmail/nossr50/commands/McImportCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McImportCommand.java @@ -18,14 +18,11 @@ public class McImportCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 0: - importModConfig(); - return true; - - default: - return false; + if (args.length == 0) { + importModConfig(); + return true; } + return false; } public boolean importModConfig() { diff --git a/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java b/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java index e104b61d2..8c3c544cc 100644 --- a/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java @@ -22,8 +22,8 @@ public class McconvertCommand implements TabExecutor { private static final List DATABASE_TYPES; private static final List SUBCOMMANDS = ImmutableList.of("database", "experience"); - private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand(); - private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand(); + private final CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand(); + private final CommandExecutor experienceConvertCommand = new ConvertExperienceCommand(); static { ArrayList formulaTypes = new ArrayList(); @@ -54,19 +54,16 @@ public class McconvertCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) { - return databaseConvertCommand.onCommand(sender, command, label, args); - } - else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) { - return experienceConvertCommand.onCommand(sender, command, label, args); - } + if (args.length == 2) { + if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) { + return databaseConvertCommand.onCommand(sender, command, label, args); + } else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) { + return experienceConvertCommand.onCommand(sender, command, label, args); + } - return false; - default: - return false; + return false; } + return false; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java index ac90ce9ab..467797ba7 100644 --- a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java @@ -19,21 +19,18 @@ public class McnotifyCommand implements TabExecutor { return true; } - switch (args.length) { - case 0: - McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); + if (args.length == 0) { + McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); - //Not Loaded yet - if(mcMMOPlayer == null) - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + //Not Loaded yet + if (mcMMOPlayer == null) + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); - sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On"))); - mcMMOPlayer.toggleChatNotifications(); - return true; - - default: - return false; + sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On"))); + mcMMOPlayer.toggleChatNotifications(); + return true; } + return false; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java b/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java index 305aae98e..d731f2932 100644 --- a/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java @@ -70,12 +70,10 @@ public class McscoreboardCommand implements TabExecutor { @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - switch (args.length) { - case 1: - return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList(FIRST_ARGS.size())); - default: - return ImmutableList.of(); + if (args.length == 1) { + return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList(FIRST_ARGS.size())); } + return ImmutableList.of(); } private boolean help(CommandSender sender) { diff --git a/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java b/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java index 11256ecbd..8e74a01ff 100644 --- a/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java @@ -61,13 +61,11 @@ public abstract class ToggleCommand implements TabExecutor { @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - switch (args.length) { - case 1: - List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); - default: - return ImmutableList.of(); + if (args.length == 1) { + List playerNames = CommandUtils.getOnlinePlayerNames(sender); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); } + return ImmutableList.of(); } protected abstract boolean hasOtherPermission(CommandSender sender); diff --git a/src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java index da15b8297..bd78c7853 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java @@ -12,19 +12,17 @@ import org.bukkit.command.CommandSender; public final class McmmoReloadLocaleCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 0: - if (!Permissions.reloadlocale(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - LocaleLoader.reloadLocale(); - sender.sendMessage(LocaleLoader.getString("Locale.Reloaded")); - + if (args.length == 0) { + if (!Permissions.reloadlocale(sender)) { + sender.sendMessage(command.getPermissionMessage()); return true; - default: - return false; + } + + LocaleLoader.reloadLocale(); + sender.sendMessage(LocaleLoader.getString("Locale.Reloaded")); + + return true; } + return false; } } diff --git a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java index b1d93685a..0062f6645 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.List; public abstract class ChatCommand implements TabExecutor { - private ChatMode chatMode; + private final ChatMode chatMode; protected ChatManager chatManager; public ChatCommand(ChatMode chatMode) { @@ -89,12 +89,10 @@ public abstract class ChatCommand implements TabExecutor { @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - switch (args.length) { - case 1: - return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); - default: - return ImmutableList.of(); + if (args.length == 1) { + return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); } + return ImmutableList.of(); } protected String buildChatMessage(String[] args, int index) { diff --git a/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java b/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java index a7834ee03..e1e205b01 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java @@ -17,58 +17,54 @@ import org.bukkit.entity.Player; public class ConvertDatabaseCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - DatabaseType previousType = DatabaseType.getDatabaseType(args[1]); - DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType(); + if (args.length == 2) { + DatabaseType previousType = DatabaseType.getDatabaseType(args[1]); + DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType(); - if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) { - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString())); - return true; - } + if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) { + sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString())); + return true; + } - DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType); + DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType); - if (previousType == DatabaseType.CUSTOM) { - Class clazz; + if (previousType == DatabaseType.CUSTOM) { + Class clazz; - try { - clazz = Class.forName(args[1]); + try { + clazz = Class.forName(args[1]); - if (!DatabaseManager.class.isAssignableFrom(clazz)) { - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1])); - return true; - } - - oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class) clazz); - } - catch (Throwable e) { - e.printStackTrace(); + if (!DatabaseManager.class.isAssignableFrom(clazz)) { sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1])); return true; } + + oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class) clazz); + } catch (Throwable e) { + e.printStackTrace(); + sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1])); + return true; + } + } + + sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString())); + + UserManager.saveAll(); + UserManager.clearAll(); + + for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { + PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId()); + + if (profile.isLoaded()) { + mcMMO.getDatabaseManager().saveUser(profile); } - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString())); + new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + } - UserManager.saveAll(); - UserManager.clearAll(); - - for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { - PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId()); - - if (profile.isLoaded()) { - mcMMO.getDatabaseManager().saveUser(profile); - } - - new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading - } - - new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p); - return true; - - default: - return false; + new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p); + return true; } + return false; } } diff --git a/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java index 3e53140e1..4982f87bf 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java @@ -13,20 +13,17 @@ import java.util.List; public class McpurgeCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 0: - mcMMO.getDatabaseManager().purgePowerlessUsers(); + if (args.length == 0) { + mcMMO.getDatabaseManager().purgePowerlessUsers(); - if (Config.getInstance().getOldUsersCutoff() != -1) { - mcMMO.getDatabaseManager().purgeOldUsers(); - } + if (Config.getInstance().getOldUsersCutoff() != -1) { + mcMMO.getDatabaseManager().purgeOldUsers(); + } - sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success")); - return true; - - default: - return false; + sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success")); + return true; } + return false; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java index ba02d762c..e2e6033fb 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java @@ -18,42 +18,36 @@ import java.util.UUID; public class McremoveCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - String playerName = CommandUtils.getMatchedPlayerName(args[0]); - - if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) { - return true; - } - - UUID uuid = null; - - if(Bukkit.getPlayer(playerName) != null) { - uuid = Bukkit.getPlayer(playerName).getUniqueId(); - } - - if (mcMMO.getDatabaseManager().removeUser(playerName, uuid)) { - sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName)); - } - else { - sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen. - } + if (args.length == 1) { + String playerName = CommandUtils.getMatchedPlayerName(args[0]); + if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) { return true; + } - default: - return false; + UUID uuid = null; + + if (Bukkit.getPlayer(playerName) != null) { + uuid = Bukkit.getPlayer(playerName).getUniqueId(); + } + + if (mcMMO.getDatabaseManager().removeUser(playerName, uuid)) { + sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName)); + } else { + sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen. + } + + return true; } + return false; } @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - switch (args.length) { - case 1: - List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); - default: - return ImmutableList.of(); + if (args.length == 1) { + List playerNames = CommandUtils.getOnlinePlayerNames(sender); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); } + return ImmutableList.of(); } } diff --git a/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java b/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java index 2b4ca7d76..610f35592 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java @@ -13,21 +13,18 @@ import java.util.List; public class MmoshowdbCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 0: - Class clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass(); + if (args.length == 0) { + Class clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass(); - if (clazz != null) { - sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName())); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile"))); + if (clazz != null) { + sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName())); return true; + } - default: - return false; + sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile"))); + return true; } + return false; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java index 147212bd0..156212d74 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java @@ -16,36 +16,33 @@ import java.util.Locale; public class ConvertExperienceCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType(); - FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase(Locale.ENGLISH)); - - if (newType == FormulaType.UNKNOWN) { - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid")); - return true; - } - - if (previousType == newType) { - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Same", newType.toString())); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString())); - - UserManager.saveAll(); - UserManager.clearAll(); - - new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1); - - for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { - new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading - } + if (args.length == 2) { + FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType(); + FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase(Locale.ENGLISH)); + if (newType == FormulaType.UNKNOWN) { + sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid")); return true; + } - default: - return false; + if (previousType == newType) { + sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Same", newType.toString())); + return true; + } + + sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString())); + + UserManager.saveAll(); + UserManager.clearAll(); + + new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1); + + for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { + new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + } + + return true; } + return false; } } diff --git a/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreModeCommand.java b/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreModeCommand.java index 2a59a45b4..fea605da4 100644 --- a/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreModeCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreModeCommand.java @@ -109,16 +109,14 @@ public abstract class HardcoreModeCommand implements TabExecutor { @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - switch (args.length) { - case 1: - if (StringUtils.isDouble(args[0])) { - return ImmutableList.of(); - } - - return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); - default: + if (args.length == 1) { + if (StringUtils.isDouble(args[0])) { return ImmutableList.of(); + } + + return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); } + return ImmutableList.of(); } protected abstract boolean checkTogglePermissions(CommandSender sender); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java index d60868dd9..06ab23d90 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java @@ -12,36 +12,32 @@ import org.bukkit.entity.Player; public class PartyAcceptCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - Player player = (Player) sender; + if (args.length == 1) { + Player player = (Player) sender; - //Check if player profile is loaded - if(UserManager.getPlayer(player) == null) - { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); - return true; - } - - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - - - if (!mcMMOPlayer.hasPartyInvite()) { - sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites")); - return true; - } - - // Changing parties - if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) { - return true; - } - - PartyManager.joinInvitedParty(mcMMOPlayer); + //Check if player profile is loaded + if (UserManager.getPlayer(player) == null) { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); return true; + } - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept")); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + + + if (!mcMMOPlayer.hasPartyInvite()) { + sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites")); return true; + } + + // Changing parties + if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) { + return true; + } + + PartyManager.joinInvitedParty(mcMMOPlayer); + return true; } + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java index ef711fbef..435d93035 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java @@ -15,30 +15,25 @@ import org.bukkit.entity.Player; public class PartyChangeOwnerCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - //Check if player profile is loaded - if(UserManager.getPlayer((Player) sender) == null) - { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); - return true; - } - - Party playerParty = UserManager.getPlayer((Player) sender).getParty(); - String targetName = CommandUtils.getMatchedPlayerName(args[1]); - OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName); - - if (!playerParty.hasMember(target.getUniqueId())) { - sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); - return true; - } - - PartyManager.setPartyLeader(target.getUniqueId(), playerParty); + if (args.length == 2) {//Check if player profile is loaded + if (UserManager.getPlayer((Player) sender) == null) { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); return true; + } - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + Party playerParty = UserManager.getPlayer((Player) sender).getParty(); + String targetName = CommandUtils.getMatchedPlayerName(args[1]); + OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName); + + if (!playerParty.hasMember(target.getUniqueId())) { + sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); return true; + } + + PartyManager.setPartyLeader(target.getUniqueId(), playerParty); + return true; } + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java index b1471d9a0..73638547c 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -38,24 +38,24 @@ public class PartyCommand implements TabExecutor { PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands); } - private CommandExecutor partyJoinCommand = new PartyJoinCommand(); - private CommandExecutor partyAcceptCommand = new PartyAcceptCommand(); - private CommandExecutor partyCreateCommand = new PartyCreateCommand(); - private CommandExecutor partyQuitCommand = new PartyQuitCommand(); - private CommandExecutor partyXpShareCommand = new PartyXpShareCommand(); - private CommandExecutor partyItemShareCommand = new PartyItemShareCommand(); - private CommandExecutor partyInviteCommand = new PartyInviteCommand(); - private CommandExecutor partyKickCommand = new PartyKickCommand(); - private CommandExecutor partyDisbandCommand = new PartyDisbandCommand(); - private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand(); - private CommandExecutor partyLockCommand = new PartyLockCommand(); - private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand(); - private CommandExecutor partyRenameCommand = new PartyRenameCommand(); - private CommandExecutor partyInfoCommand = new PartyInfoCommand(); - private CommandExecutor partyHelpCommand = new PartyHelpCommand(); - private CommandExecutor partyTeleportCommand = new PtpCommand(); - private CommandExecutor partyChatCommand = new PartyChatCommand(); - private CommandExecutor partyAllianceCommand = new PartyAllianceCommand(); + private final CommandExecutor partyJoinCommand = new PartyJoinCommand(); + private final CommandExecutor partyAcceptCommand = new PartyAcceptCommand(); + private final CommandExecutor partyCreateCommand = new PartyCreateCommand(); + private final CommandExecutor partyQuitCommand = new PartyQuitCommand(); + private final CommandExecutor partyXpShareCommand = new PartyXpShareCommand(); + private final CommandExecutor partyItemShareCommand = new PartyItemShareCommand(); + private final CommandExecutor partyInviteCommand = new PartyInviteCommand(); + private final CommandExecutor partyKickCommand = new PartyKickCommand(); + private final CommandExecutor partyDisbandCommand = new PartyDisbandCommand(); + private final CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand(); + private final CommandExecutor partyLockCommand = new PartyLockCommand(); + private final CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand(); + private final CommandExecutor partyRenameCommand = new PartyRenameCommand(); + private final CommandExecutor partyInfoCommand = new PartyInfoCommand(); + private final CommandExecutor partyHelpCommand = new PartyHelpCommand(); + private final CommandExecutor partyTeleportCommand = new PtpCommand(); + private final CommandExecutor partyChatCommand = new PartyChatCommand(); + private final CommandExecutor partyAllianceCommand = new PartyAllianceCommand(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java index 8e10e1719..dc46f242c 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java @@ -13,31 +13,27 @@ import org.bukkit.entity.Player; public class PartyDisbandCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - if(UserManager.getPlayer((Player) sender) == null) - { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + if (args.length == 1) { + if (UserManager.getPlayer((Player) sender) == null) { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + + Party playerParty = UserManager.getPlayer((Player) sender).getParty(); + String partyName = playerParty.getName(); + + for (Player member : playerParty.getOnlineMembers()) { + if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) { return true; } - Party playerParty = UserManager.getPlayer((Player) sender).getParty(); - String partyName = playerParty.getName(); + member.sendMessage(LocaleLoader.getString("Party.Disband")); + } - for (Player member : playerParty.getOnlineMembers()) { - if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) { - return true; - } - - member.sendMessage(LocaleLoader.getString("Party.Disband")); - } - - PartyManager.disbandParty(playerParty); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband")); - return true; + PartyManager.disbandParty(playerParty); + return true; } + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java index fcf4908c0..43fefa480 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java @@ -9,22 +9,19 @@ public class PartyHelpCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - sender.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit")); - sender.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); - sender.sendMessage(LocaleLoader.getString("Party.Help.4", "/party ")); - sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password")); - sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick")); - sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader")); - sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband")); - sender.sendMessage(LocaleLoader.getString("Party.Help.9", "/party itemshare")); - sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party xpshare")); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "help")); - return true; + if (args.length == 1) { + sender.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit")); + sender.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); + sender.sendMessage(LocaleLoader.getString("Party.Help.4", "/party ")); + sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password")); + sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick")); + sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader")); + sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband")); + sender.sendMessage(LocaleLoader.getString("Party.Help.9", "/party itemshare")); + sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party xpshare")); + return true; } + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "help")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java index 588feb3d7..ffb1adee0 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java @@ -15,60 +15,55 @@ import org.bukkit.entity.Player; public class PartyInviteCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - String targetName = CommandUtils.getMatchedPlayerName(args[1]); - McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); + if (args.length == 2) { + String targetName = CommandUtils.getMatchedPlayerName(args[1]); + McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); - if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { - return false; - } + if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { + return false; + } - Player target = mcMMOTarget.getPlayer(); + Player target = mcMMOTarget.getPlayer(); - if(UserManager.getPlayer((Player) sender) == null) - { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); - return true; - } - - Player player = (Player) sender; - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - String playerName = player.getName(); - - if (player.equals(target)) { - sender.sendMessage(LocaleLoader.getString("Party.Invite.Self")); - return true; - } - - if (PartyManager.inSameParty(player, target)) { - sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName)); - return true; - } - - if (!PartyManager.canInvite(mcMMOPlayer)) { - player.sendMessage(LocaleLoader.getString("Party.Locked")); - return true; - } - - Party playerParty = mcMMOPlayer.getParty(); - - if(PartyManager.isPartyFull(target, playerParty)) - { - player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), Config.getInstance().getPartyMaxSize())); - return true; - } - - mcMMOTarget.setPartyInvite(playerParty); - - sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); - target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName)); - target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1")); + if (UserManager.getPlayer((Player) sender) == null) { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); return true; + } - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + Player player = (Player) sender; + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + String playerName = player.getName(); + + if (player.equals(target)) { + sender.sendMessage(LocaleLoader.getString("Party.Invite.Self")); return true; + } + + if (PartyManager.inSameParty(player, target)) { + sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName)); + return true; + } + + if (!PartyManager.canInvite(mcMMOPlayer)) { + player.sendMessage(LocaleLoader.getString("Party.Locked")); + return true; + } + + Party playerParty = mcMMOPlayer.getParty(); + + if (PartyManager.isPartyFull(target, playerParty)) { + player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), Config.getInstance().getPartyMaxSize())); + return true; + } + + mcMMOTarget.setPartyInvite(playerParty); + + sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); + target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName)); + target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1")); + return true; } + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java index ed0adde76..eb5298ad5 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java @@ -16,42 +16,38 @@ import org.bukkit.entity.Player; public class PartyKickCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - if(UserManager.getPlayer((Player) sender) == null) - { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + if (args.length == 2) { + if (UserManager.getPlayer((Player) sender) == null) { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + + Party playerParty = UserManager.getPlayer((Player) sender).getParty(); + String targetName = CommandUtils.getMatchedPlayerName(args[1]); + + if (!playerParty.hasMember(targetName)) { + sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); + return true; + } + + OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName); + + if (target.isOnline()) { + Player onlineTarget = target.getPlayer(); + String partyName = playerParty.getName(); + + if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) { return true; } - Party playerParty = UserManager.getPlayer((Player) sender).getParty(); - String targetName = CommandUtils.getMatchedPlayerName(args[1]); + PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget)); + onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName)); + } - if (!playerParty.hasMember(targetName)) { - sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); - return true; - } - - OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName); - - if (target.isOnline()) { - Player onlineTarget = target.getPlayer(); - String partyName = playerParty.getName(); - - if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) { - return true; - } - - PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget)); - onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName)); - } - - PartyManager.removeFromParty(target, playerParty); - return true; - - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); - return true; + PartyManager.removeFromParty(target, playerParty); + return true; } + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java index fdf02ee23..ffaba4771 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java @@ -67,7 +67,7 @@ public class PartyLockCommand implements CommandExecutor { return; } - if (lock ? party.isLocked() : !party.isLocked()) { + if (lock == party.isLocked()) { sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "IsLocked" : "IsntLocked"))); return; } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java index c8cd07fbf..9fb080d44 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java @@ -14,30 +14,26 @@ import org.bukkit.entity.Player; public class PartyQuitCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - Player player = (Player) sender; + if (args.length == 1) { + Player player = (Player) sender; - if(UserManager.getPlayer((Player) sender) == null) - { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); - return true; - } - - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - Party playerParty = mcMMOPlayer.getParty(); - - if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) { - return true; - } - - PartyManager.removeFromParty(mcMMOPlayer); - sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave")); + if (UserManager.getPlayer((Player) sender) == null) { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); return true; + } - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "quit")); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + Party playerParty = mcMMOPlayer.getParty(); + + if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) { return true; + } + + PartyManager.removeFromParty(mcMMOPlayer); + sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave")); + return true; } + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "quit")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java index 592ac4ca7..e7f50800b 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java @@ -14,53 +14,49 @@ import org.bukkit.entity.Player; public class PartyRenameCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - if(UserManager.getPlayer((Player) sender) == null) - { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); - return true; - } - - McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); - Party playerParty = mcMMOPlayer.getParty(); - - String oldPartyName = playerParty.getName(); - String newPartyName = args[1]; - - // This is to prevent party leaders from spamming other players with the rename message - if (oldPartyName.equalsIgnoreCase(newPartyName)) { - sender.sendMessage(LocaleLoader.getString("Party.Rename.Same")); - return true; - } - - Player player = mcMMOPlayer.getPlayer(); - - // Check to see if the party exists, and if it does cancel renaming the party - if (PartyManager.checkPartyExistence(player, newPartyName)) { - return true; - } - - String leaderName = playerParty.getLeader().getPlayerName(); - - for (Player member : playerParty.getOnlineMembers()) { - if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) { - return true; - } - - if (!member.getName().equalsIgnoreCase(leaderName)) { - member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName)); - } - } - - playerParty.setName(newPartyName); - - sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName)); + if (args.length == 2) { + if (UserManager.getPlayer((Player) sender) == null) { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); return true; + } - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">")); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); + Party playerParty = mcMMOPlayer.getParty(); + + String oldPartyName = playerParty.getName(); + String newPartyName = args[1]; + + // This is to prevent party leaders from spamming other players with the rename message + if (oldPartyName.equalsIgnoreCase(newPartyName)) { + sender.sendMessage(LocaleLoader.getString("Party.Rename.Same")); return true; + } + + Player player = mcMMOPlayer.getPlayer(); + + // Check to see if the party exists, and if it does cancel renaming the party + if (PartyManager.checkPartyExistence(player, newPartyName)) { + return true; + } + + String leaderName = playerParty.getLeader().getPlayerName(); + + for (Player member : playerParty.getOnlineMembers()) { + if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) { + return true; + } + + if (!member.getName().equalsIgnoreCase(leaderName)) { + member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName)); + } + } + + playerParty.setName(newPartyName); + + sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName)); + return true; } + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java index 26b0922da..f90c7c21c 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java @@ -29,24 +29,19 @@ public class PartyXpShareCommand implements CommandExecutor { return true; } - switch (args.length) { - case 2: - if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) { - handleChangingShareMode(party, ShareMode.NONE); - } - else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) { - handleChangingShareMode(party, ShareMode.EQUAL); - } - else { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "")); - } - - return true; - - default: + if (args.length == 2) { + if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) { + handleChangingShareMode(party, ShareMode.NONE); + } else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) { + handleChangingShareMode(party, ShareMode.EQUAL); + } else { sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "")); - return true; + } + + return true; } + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "")); + return true; } private void handleChangingShareMode(Party party, ShareMode mode) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java index e4854a0cc..caa3a509d 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java @@ -12,32 +12,28 @@ import org.bukkit.entity.Player; public class PartyAllianceAcceptCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - if(UserManager.getPlayer((Player) sender) == null) - { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); - return true; - } - Player player = (Player) sender; - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - - if (!mcMMOPlayer.hasPartyAllianceInvite()) { - sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites")); - return true; - } - - if (mcMMOPlayer.getParty().getAlly() != null) { - player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies")); - return true; - } - - PartyManager.acceptAllianceInvite(mcMMOPlayer); + if (args.length == 2) { + if (UserManager.getPlayer((Player) sender) == null) { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); return true; + } + Player player = (Player) sender; + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept")); + if (!mcMMOPlayer.hasPartyAllianceInvite()) { + sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites")); return true; + } + + if (mcMMOPlayer.getParty().getAlly() != null) { + player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies")); + return true; + } + + PartyManager.acceptAllianceInvite(mcMMOPlayer); + return true; } + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java index 7741115fd..5283137e3 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java @@ -27,9 +27,9 @@ public class PartyAllianceCommand implements TabExecutor { public static final List ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband"); - private CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand(); - private CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand(); - private CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand(); + private final CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand(); + private final CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand(); + private final CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -109,19 +109,17 @@ public class PartyAllianceCommand implements TabExecutor { @Override public List onTabComplete(CommandSender commandSender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - List matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList(ALLIANCE_SUBCOMMANDS.size())); + if (args.length == 1) { + List matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList(ALLIANCE_SUBCOMMANDS.size())); - if (matches.size() == 0) { - List playerNames = CommandUtils.getOnlinePlayerNames(commandSender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); - } + if (matches.size() == 0) { + List playerNames = CommandUtils.getOnlinePlayerNames(commandSender); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + } - return matches; - default: - return ImmutableList.of(); + return matches; } + return ImmutableList.of(); } private void displayPartyHeader() { diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java index 44829d4c8..e610c136e 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java @@ -13,28 +13,24 @@ import org.bukkit.entity.Player; public class PartyAllianceDisbandCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 2: - if(UserManager.getPlayer((Player) sender) == null) - { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); - return true; - } - Player player = (Player) sender; - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - Party party = mcMMOPlayer.getParty(); - - if (party.getAlly() == null) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.None")); - return true; - } - - PartyManager.disbandAlliance(player, party, party.getAlly()); + if (args.length == 2) { + if (UserManager.getPlayer((Player) sender) == null) { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); return true; + } + Player player = (Player) sender; + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + Party party = mcMMOPlayer.getParty(); - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband")); + if (party.getAlly() == null) { + sender.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.None")); return true; + } + + PartyManager.disbandAlliance(player, party, party.getAlly()); + return true; } + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java index 97461021a..06694edd2 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java @@ -14,64 +14,60 @@ import org.bukkit.entity.Player; public class PartyAllianceInviteCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 3: - String targetName = CommandUtils.getMatchedPlayerName(args[2]); - McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); + if (args.length == 3) { + String targetName = CommandUtils.getMatchedPlayerName(args[2]); + McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); - if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { - return false; - } + if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { + return false; + } - Player target = mcMMOTarget.getPlayer(); + Player target = mcMMOTarget.getPlayer(); - if(UserManager.getPlayer((Player) sender) == null) - { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); - return true; - } - - Player player = (Player) sender; - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - String playerName = player.getName(); - - if (player.equals(target)) { - sender.sendMessage(LocaleLoader.getString("Party.Invite.Self")); - return true; - } - - if (!mcMMOTarget.inParty()) { - player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName)); - return true; - } - - if (PartyManager.inSameParty(player, target)) { - sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName)); - return true; - } - - if (!mcMMOTarget.getParty().getLeader().getUniqueId().equals(target.getUniqueId())) { - player.sendMessage(LocaleLoader.getString("Party.Target.NotOwner", targetName)); - return true; - } - - Party playerParty = mcMMOPlayer.getParty(); - - if (playerParty.getAlly() != null) { - player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies")); - return true; - } - - mcMMOTarget.setPartyAllianceInvite(playerParty); - - sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); - target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.0", playerParty.getName(), playerName)); - target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.1")); + if (UserManager.getPlayer((Player) sender) == null) { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); return true; + } - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "alliance", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + Player player = (Player) sender; + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + String playerName = player.getName(); + + if (player.equals(target)) { + sender.sendMessage(LocaleLoader.getString("Party.Invite.Self")); return true; + } + + if (!mcMMOTarget.inParty()) { + player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName)); + return true; + } + + if (PartyManager.inSameParty(player, target)) { + sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName)); + return true; + } + + if (!mcMMOTarget.getParty().getLeader().getUniqueId().equals(target.getUniqueId())) { + player.sendMessage(LocaleLoader.getString("Party.Target.NotOwner", targetName)); + return true; + } + + Party playerParty = mcMMOPlayer.getParty(); + + if (playerParty.getAlly() != null) { + player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies")); + return true; + } + + mcMMOTarget.setPartyAllianceInvite(playerParty); + + sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); + target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.0", playerParty.getName(), playerName)); + target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.1")); + return true; } + sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "alliance", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java index 8d046c8fb..4fec2eeb6 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java @@ -33,9 +33,9 @@ import java.util.List; public class PtpCommand implements TabExecutor { public static final List TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall"); - private CommandExecutor ptpToggleCommand = new PtpToggleCommand(); - private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand(); - private CommandExecutor ptpAcceptCommand = new PtpAcceptCommand(); + private final CommandExecutor ptpToggleCommand = new PtpToggleCommand(); + private final CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand(); + private final CommandExecutor ptpAcceptCommand = new PtpAcceptCommand(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -80,85 +80,79 @@ public class PtpCommand implements TabExecutor { return true; } - switch (args.length) { - case 1: - if (args[0].equalsIgnoreCase("toggle")) { - return ptpToggleCommand.onCommand(sender, command, label, args); - } + if (args.length == 1) { + if (args[0].equalsIgnoreCase("toggle")) { + return ptpToggleCommand.onCommand(sender, command, label, args); + } - if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) { - return ptpAcceptAnyCommand.onCommand(sender, command, label, args); - } + if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) { + return ptpAcceptAnyCommand.onCommand(sender, command, label, args); + } - long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); - int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown(); + long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); + int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown(); - if (hurtCooldown > 0) { - int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player); + if (hurtCooldown > 0) { + int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player); - if (timeRemaining > 0) { - player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining)); - return true; - } - } - - if (args[0].equalsIgnoreCase("accept")) { - return ptpAcceptCommand.onCommand(sender, command, label, args); - } - - if (!Permissions.partyTeleportSend(sender)) { - sender.sendMessage(command.getPermissionMessage()); + if (timeRemaining > 0) { + player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining)); return true; } + } - int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); - long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse(); + if (args[0].equalsIgnoreCase("accept")) { + return ptpAcceptCommand.onCommand(sender, command, label, args); + } - if (ptpCooldown > 0) { - int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player); - - if (timeRemaining > 0) { - player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining)); - return true; - } - } - - sendTeleportRequest(sender, player, CommandUtils.getMatchedPlayerName(args[0])); + if (!Permissions.partyTeleportSend(sender)) { + sender.sendMessage(command.getPermissionMessage()); return true; + } - default: - return false; + int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); + long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse(); + + if (ptpCooldown > 0) { + int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player); + + if (timeRemaining > 0) { + player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining)); + return true; + } + } + + sendTeleportRequest(sender, player, CommandUtils.getMatchedPlayerName(args[0])); + return true; } + return false; } @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - switch (args.length) { - case 1: - List matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList(TELEPORT_SUBCOMMANDS.size())); + if (args.length == 1) { + List matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList(TELEPORT_SUBCOMMANDS.size())); - if (matches.size() == 0) { - if(UserManager.getPlayer((Player) sender) == null) - { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); - return ImmutableList.of(); - } - - Player player = (Player) sender; - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - - if (!mcMMOPlayer.inParty()) { - return ImmutableList.of(); - } - - List playerNames = mcMMOPlayer.getParty().getOnlinePlayerNames(player); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + if (matches.size() == 0) { + if (UserManager.getPlayer((Player) sender) == null) { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return ImmutableList.of(); } - return matches; - default: - return ImmutableList.of(); + Player player = (Player) sender; + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + + if (!mcMMOPlayer.inParty()) { + return ImmutableList.of(); + } + + List playerNames = mcMMOPlayer.getParty().getOnlinePlayerNames(player); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + } + + return matches; } + return ImmutableList.of(); } private void sendTeleportRequest(CommandSender sender, Player player, String targetName) { diff --git a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java index 89560bb0f..b3fb2ba17 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java @@ -23,86 +23,79 @@ import java.util.List; public class InspectCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - String playerName = CommandUtils.getMatchedPlayerName(args[0]); - McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); + if (args.length == 1) { + String playerName = CommandUtils.getMatchedPlayerName(args[0]); + McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); - // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. - if (mcMMOPlayer == null) { - PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile + // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. + if (mcMMOPlayer == null) { + PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile - if (!CommandUtils.isLoaded(sender, profile)) { - return true; - } - - if (Config.getInstance().getScoreboardsEnabled() && sender instanceof Player && Config.getInstance().getInspectUseBoard()) { - ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile); - - if (!Config.getInstance().getInspectUseChat()) { - return true; - } - } - - sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName)); - - sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering")); - for (PrimarySkillType skill : PrimarySkillType.GATHERING_SKILLS) { - sender.sendMessage(CommandUtils.displaySkill(profile, skill)); - } - - sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat")); - for (PrimarySkillType skill : PrimarySkillType.COMBAT_SKILLS) { - sender.sendMessage(CommandUtils.displaySkill(profile, skill)); - } - - sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc")); - for (PrimarySkillType skill : PrimarySkillType.MISC_SKILLS) { - sender.sendMessage(CommandUtils.displaySkill(profile, skill)); - } - - } - else { - Player target = mcMMOPlayer.getPlayer(); - - if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) { - sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); - return true; - } - else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) { - return true; - } - - if (Config.getInstance().getScoreboardsEnabled() && sender instanceof Player && Config.getInstance().getInspectUseBoard()) { - ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile()); - - if (!Config.getInstance().getInspectUseChat()) { - return true; - } - } - - sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName())); - CommandUtils.printGatheringSkills(target, sender); - CommandUtils.printCombatSkills(target, sender); - CommandUtils.printMiscSkills(target, sender); - sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); + if (!CommandUtils.isLoaded(sender, profile)) { + return true; } - return true; + if (Config.getInstance().getScoreboardsEnabled() && sender instanceof Player && Config.getInstance().getInspectUseBoard()) { + ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile); - default: - return false; + if (!Config.getInstance().getInspectUseChat()) { + return true; + } + } + + sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName)); + + sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering")); + for (PrimarySkillType skill : PrimarySkillType.GATHERING_SKILLS) { + sender.sendMessage(CommandUtils.displaySkill(profile, skill)); + } + + sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat")); + for (PrimarySkillType skill : PrimarySkillType.COMBAT_SKILLS) { + sender.sendMessage(CommandUtils.displaySkill(profile, skill)); + } + + sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc")); + for (PrimarySkillType skill : PrimarySkillType.MISC_SKILLS) { + sender.sendMessage(CommandUtils.displaySkill(profile, skill)); + } + + } else { + Player target = mcMMOPlayer.getPlayer(); + + if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) { + sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); + return true; + } else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) { + return true; + } + + if (Config.getInstance().getScoreboardsEnabled() && sender instanceof Player && Config.getInstance().getInspectUseBoard()) { + ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile()); + + if (!Config.getInstance().getInspectUseChat()) { + return true; + } + } + + sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName())); + CommandUtils.printGatheringSkills(target, sender); + CommandUtils.printCombatSkills(target, sender); + CommandUtils.printMiscSkills(target, sender); + sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); + } + + return true; } + return false; } @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - switch (args.length) { - case 1: - List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); - default: - return ImmutableList.of(); + if (args.length == 1) { + List playerNames = CommandUtils.getOnlinePlayerNames(sender); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); } + return ImmutableList.of(); } } diff --git a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java index 7a856f301..ab736762b 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java @@ -26,49 +26,44 @@ public class MccooldownCommand implements TabExecutor { return true; } - switch (args.length) { - case 0: - Player player = (Player) sender; + if (args.length == 0) { + Player player = (Player) sender; - if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getCooldownUseBoard()) { - ScoreboardManager.enablePlayerCooldownScoreboard(player); + if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getCooldownUseBoard()) { + ScoreboardManager.enablePlayerCooldownScoreboard(player); - if (!Config.getInstance().getCooldownUseChat()) { - return true; - } - } - - if(UserManager.getPlayer(player) == null) - { - player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + if (!Config.getInstance().getCooldownUseChat()) { return true; } + } - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + if (UserManager.getPlayer(player) == null) { + player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } - player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header")); - player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - for (SuperAbilityType ability : SuperAbilityType.values()) { - if (!ability.getPermissions(player)) { - continue; - } + player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header")); + player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); - int seconds = mcMMOPlayer.calculateTimeRemaining(ability); - - if (seconds <= 0) { - player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName())); - } - else { - player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds)); - } + for (SuperAbilityType ability : SuperAbilityType.values()) { + if (!ability.getPermissions(player)) { + continue; } - return true; + int seconds = mcMMOPlayer.calculateTimeRemaining(ability); - default: - return false; + if (seconds <= 0) { + player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName())); + } else { + player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds)); + } + } + + return true; } + return false; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java index c973b0608..20458624f 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -73,13 +73,11 @@ public class McrankCommand implements TabExecutor { @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - switch (args.length) { - case 1: - List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); - default: - return ImmutableList.of(); + if (args.length == 1) { + List playerNames = CommandUtils.getOnlinePlayerNames(sender); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); } + return ImmutableList.of(); } private void display(CommandSender sender, String playerName) { diff --git a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java index 187d866eb..2b623b0e4 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java @@ -24,45 +24,40 @@ public class McstatsCommand implements TabExecutor { return true; } - switch (args.length) { - case 0: - if(UserManager.getPlayer((Player) sender) == null) - { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + if (args.length == 0) { + if (UserManager.getPlayer((Player) sender) == null) { + sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + return true; + } + + Player player = (Player) sender; + + if (Config.getInstance().getStatsUseBoard() && Config.getInstance().getScoreboardsEnabled()) { + ScoreboardManager.enablePlayerStatsScoreboard(player); + + if (!Config.getInstance().getStatsUseChat()) { return true; } + } - Player player = (Player) sender; + player.sendMessage(LocaleLoader.getString("Stats.Own.Stats")); + player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); - if (Config.getInstance().getStatsUseBoard() && Config.getInstance().getScoreboardsEnabled()) { - ScoreboardManager.enablePlayerStatsScoreboard(player); + CommandUtils.printGatheringSkills(player); + CommandUtils.printCombatSkills(player); + CommandUtils.printMiscSkills(player); - if (!Config.getInstance().getStatsUseChat()) { - return true; - } - } + int powerLevelCap = Config.getInstance().getPowerLevelCap(); - player.sendMessage(LocaleLoader.getString("Stats.Own.Stats")); - player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); + if (powerLevelCap != Integer.MAX_VALUE) { + player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap)); + } else { + player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel())); + } - CommandUtils.printGatheringSkills(player); - CommandUtils.printCombatSkills(player); - CommandUtils.printMiscSkills(player); - - int powerLevelCap = Config.getInstance().getPowerLevelCap(); - - if (powerLevelCap != Integer.MAX_VALUE) { - player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap)); - } - else { - player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel())); - } - - return true; - - default: - return false; + return true; } + return false; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java index dc9acb3b5..a17224566 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -67,12 +67,10 @@ public class MctopCommand implements TabExecutor { @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - switch (args.length) { - case 1: - return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SKILL_NAMES, new ArrayList(PrimarySkillType.SKILL_NAMES.size())); - default: - return ImmutableList.of(); + if (args.length == 1) { + return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SKILL_NAMES, new ArrayList(PrimarySkillType.SKILL_NAMES.size())); } + return ImmutableList.of(); } private void display(int page, PrimarySkillType skill, CommandSender sender, Command command) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java index 1588cbd77..247615acb 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java @@ -71,7 +71,7 @@ public class AcrobaticsCommand extends SkillCommand { graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs); //damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold(); - String rollStrings[] = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL); + String[] rollStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL); //Format double rollChanceLucky = rollChance * 1.333D; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AprilCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AprilCommand.java index 294839b9e..8b29b3413 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AprilCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AprilCommand.java @@ -29,44 +29,41 @@ public class AprilCommand implements TabExecutor { skillName = StringUtils.getCapitalized(label); - switch (args.length) { - case 0: - Player player = (Player) sender; - FakeSkillType fakeSkillType = FakeSkillType.getByName(skillName); + if (args.length == 0) { + Player player = (Player) sender; + FakeSkillType fakeSkillType = FakeSkillType.getByName(skillName); - float skillValue = Misc.getRandom().nextInt(99); + float skillValue = Misc.getRandom().nextInt(99); - player.sendMessage(LocaleLoader.getString("Skills.Header", skillName)); - player.sendMessage(LocaleLoader.getString("Commands.XPGain", getXPGainString(fakeSkillType))); - player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, Misc.getRandom().nextInt(1000), 1000 + Misc.getRandom().nextInt(1000))); + player.sendMessage(LocaleLoader.getString("Skills.Header", skillName)); + player.sendMessage(LocaleLoader.getString("Commands.XPGain", getXPGainString(fakeSkillType))); + player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, Misc.getRandom().nextInt(1000), 1000 + Misc.getRandom().nextInt(1000))); - List effectMessages = effectsDisplay(fakeSkillType); + List effectMessages = effectsDisplay(fakeSkillType); - if (!effectMessages.isEmpty()) { - player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects"))); + if (!effectMessages.isEmpty()) { + player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects"))); - for (String message : effectMessages) { - player.sendMessage(message); - } + for (String message : effectMessages) { + player.sendMessage(message); } + } - List statsMessages = statsDisplay(fakeSkillType); + List statsMessages = statsDisplay(fakeSkillType); - if (!statsMessages.isEmpty()) { - player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self"))); + if (!statsMessages.isEmpty()) { + player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self"))); - for (String message : statsMessages) { - player.sendMessage(message); - } + for (String message : statsMessages) { + player.sendMessage(message); } + } - player.sendMessage(LocaleLoader.formatString("[[DARK_AQUA]]Guide for {0} available - type /APRIL FOOLS ! :D", skillName)); - return true; - - default: - return true; + player.sendMessage(LocaleLoader.formatString("[[DARK_AQUA]]Guide for {0} available - type /APRIL FOOLS ! :D", skillName)); + return true; } + return true; } private String getXPGainString(FakeSkillType fakeSkillType) { @@ -102,12 +99,10 @@ public class AprilCommand implements TabExecutor { @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - switch (args.length) { - case 1: - return ImmutableList.of("?"); - default: - return ImmutableList.of(); + if (args.length == 1) { + return ImmutableList.of("?"); } + return ImmutableList.of(); } private List effectsDisplay(FakeSkillType fakeSkillType) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java index 2d9093311..b047b117b 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java @@ -29,7 +29,7 @@ public class ExcavationCommand extends SkillCommand { protected void dataCalculations(Player player, float skillValue) { // GIGA DRILL BREAKER if (canGigaDrill) { - String gigaDrillStrings[] = calculateLengthDisplayValues(player, skillValue); + String[] gigaDrillStrings = calculateLengthDisplayValues(player, skillValue); gigaDrillBreakerLength = gigaDrillStrings[0]; gigaDrillBreakerLengthEndurance = gigaDrillStrings[1]; } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java index caff87ad5..7b8609a75 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java @@ -45,7 +45,7 @@ public class HerbalismCommand extends SkillCommand { // DOUBLE DROPS if (canDoubleDrop) { - String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_DOUBLE_DROPS);; + String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_DOUBLE_DROPS); doubleDropChance = doubleDropStrings[0]; doubleDropChanceLucky = doubleDropStrings[1]; } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java index 95dc29458..c1b5f2e0d 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java @@ -62,12 +62,10 @@ public class MmoInfoCommand implements TabExecutor { @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - switch (args.length) { - case 1: - return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SUBSKILL_NAMES, new ArrayList(PrimarySkillType.SUBSKILL_NAMES.size())); - default: - return ImmutableList.of(); + if (args.length == 1) { + return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SUBSKILL_NAMES, new ArrayList(PrimarySkillType.SUBSKILL_NAMES.size())); } + return ImmutableList.of(); } private void displayInfo(Player player, String subSkillName) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 1241b9e11..fe58a35fb 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -35,12 +35,12 @@ import java.util.Set; public abstract class SkillCommand implements TabExecutor { protected PrimarySkillType skill; - private String skillName; + private final String skillName; protected DecimalFormat percent = new DecimalFormat("##0.00%"); protected DecimalFormat decimal = new DecimalFormat("##0.00"); - private CommandExecutor skillGuideCommand; + private final CommandExecutor skillGuideCommand; public SkillCommand(PrimarySkillType skill) { this.skill = skill; @@ -64,64 +64,60 @@ public abstract class SkillCommand implements TabExecutor { return true; } - switch (args.length) { - case 0: - Player player = (Player) sender; - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + if (args.length == 0) { + Player player = (Player) sender; + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - boolean isLucky = Permissions.lucky(player, skill); - boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0); - float skillValue = mcMMOPlayer.getSkillLevel(skill); + boolean isLucky = Permissions.lucky(player, skill); + boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0); + float skillValue = mcMMOPlayer.getSkillLevel(skill); - //Send the players a few blank lines to make finding the top of the skill command easier - if(AdvancedConfig.getInstance().doesSkillCommandSendBlankLines()) - for(int i = 0; i < 2; i++) - { - player.sendMessage(""); - } + //Send the players a few blank lines to make finding the top of the skill command easier + if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines()) + for (int i = 0; i < 2; i++) { + player.sendMessage(""); + } - permissionsCheck(player); - dataCalculations(player, skillValue); + permissionsCheck(player); + dataCalculations(player, skillValue); - sendSkillCommandHeader(player, mcMMOPlayer, (int) skillValue); + sendSkillCommandHeader(player, mcMMOPlayer, (int) skillValue); - //Make JSON text components - List subskillTextComponents = getTextComponents(player); + //Make JSON text components + List subskillTextComponents = getTextComponents(player); - //Subskills Header - player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", LocaleLoader.getString("Effects.SubSkills.Overhaul"))); + //Subskills Header + player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", LocaleLoader.getString("Effects.SubSkills.Overhaul"))); - //Send JSON text components + //Send JSON text components - TextComponentFactory.sendPlayerSubSkillList(player, subskillTextComponents); + TextComponentFactory.sendPlayerSubSkillList(player, subskillTextComponents); /*for(TextComponent tc : subskillTextComponents) { player.spigot().sendMessage(new TextComponent[]{tc, new TextComponent(": TESTING")}); }*/ - //Stats - getStatMessages(player, isLucky, hasEndurance, skillValue); + //Stats + getStatMessages(player, isLucky, hasEndurance, skillValue); - //Header + //Header - //Link Header - if(Config.getInstance().getUrlLinksEnabled()) - { - player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header")); - TextComponentFactory.sendPlayerUrlHeader(player); - } + //Link Header + if (Config.getInstance().getUrlLinksEnabled()) { + player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header")); + TextComponentFactory.sendPlayerUrlHeader(player); + } - if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getSkillUseBoard()) { - ScoreboardManager.enablePlayerSkillScoreboard(player, skill); - } + if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getSkillUseBoard()) { + ScoreboardManager.enablePlayerSkillScoreboard(player, skill); + } - return true; - default: - return skillGuideCommand.onCommand(sender, command, label, args); + return true; } + return skillGuideCommand.onCommand(sender, command, label, args); } private void getStatMessages(Player player, boolean isLucky, boolean hasEndurance, float skillValue) { @@ -170,7 +166,7 @@ public abstract class SkillCommand implements TabExecutor { //TODO: Add JSON here for (PrimarySkillType parent : parents) { parentList.add(parent); - /*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/; + /*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/ } String parentMessage = ""; @@ -216,12 +212,10 @@ public abstract class SkillCommand implements TabExecutor { @Override public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { - switch (args.length) { - case 1: - return ImmutableList.of("?"); - default: - return ImmutableList.of(); + if (args.length == 1) { + return ImmutableList.of("?"); } + return ImmutableList.of(); } protected int calculateRank(float skillValue, int maxLevel, int rankChangeLevel) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java index 6f34f77b1..47d2667bb 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java @@ -11,10 +11,10 @@ import java.util.ArrayList; import java.util.Arrays; public class SkillGuideCommand implements CommandExecutor { - private String header; - private ArrayList guide; + private final String header; + private final ArrayList guide; - private String invalidPage = LocaleLoader.getString("Guides.Page.Invalid"); + private final String invalidPage = LocaleLoader.getString("Guides.Page.Invalid"); public SkillGuideCommand(PrimarySkillType skill) { header = LocaleLoader.getString("Guides.Header", skill.getName()); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java index e126cf38c..d427ccb16 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java @@ -40,7 +40,7 @@ public class UnarmedCommand extends SkillCommand { protected void dataCalculations(Player player, float skillValue) { // UNARMED_ARROW_DEFLECT if (canDeflect) { - String[] deflectStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_ARROW_DEFLECT);; + String[] deflectStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_ARROW_DEFLECT); deflectChance = deflectStrings[0]; deflectChanceLucky = deflectStrings[1]; } @@ -54,7 +54,7 @@ public class UnarmedCommand extends SkillCommand { // UNARMED_DISARM if (canDisarm) { - String[] disarmStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_DISARM);; + String[] disarmStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_DISARM); disarmChance = disarmStrings[0]; disarmChanceLucky = disarmStrings[1]; } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java index daec5581d..6fce8dc62 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java @@ -46,7 +46,7 @@ public class WoodcuttingCommand extends SkillCommand { } private void setDoubleDropClassicChanceStrings(Player player) { - String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.WOODCUTTING_HARVEST_LUMBER);; + String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.WOODCUTTING_HARVEST_LUMBER); doubleDropChance = doubleDropStrings[0]; doubleDropChanceLucky = doubleDropStrings[1]; } diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 296d95cff..a90d81fef 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -687,9 +687,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { } public double getMaximumProbability(SubSkillType subSkillType) { - double maximumProbability = config.getDouble(subSkillType.getAdvConfigAddress() + ".ChanceMax", 100.0D); - return maximumProbability; + return config.getDouble(subSkillType.getAdvConfigAddress() + ".ChanceMax", 100.0D); } public double getMaximumProbability(AbstractSubSkill abstractSubSkill) diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java index 025fe981b..a71c3b6a8 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java @@ -10,7 +10,7 @@ import java.util.List; public abstract class ConfigLoader { protected static final mcMMO plugin = mcMMO.p; protected String fileName; - private File configFile; + private final File configFile; protected FileConfiguration config; public ConfigLoader(String relativePath, String fileName) { diff --git a/src/main/java/com/gmail/nossr50/config/HiddenConfig.java b/src/main/java/com/gmail/nossr50/config/HiddenConfig.java index 58e6d8816..d4b646fd3 100644 --- a/src/main/java/com/gmail/nossr50/config/HiddenConfig.java +++ b/src/main/java/com/gmail/nossr50/config/HiddenConfig.java @@ -7,7 +7,7 @@ import java.io.InputStreamReader; public class HiddenConfig { private static HiddenConfig instance; - private String fileName; + private final String fileName; private YamlConfiguration config; private boolean chunkletsEnabled; private int conversionRate; diff --git a/src/main/java/com/gmail/nossr50/config/RankConfig.java b/src/main/java/com/gmail/nossr50/config/RankConfig.java index f5a1a7e71..6beb13ec5 100644 --- a/src/main/java/com/gmail/nossr50/config/RankConfig.java +++ b/src/main/java/com/gmail/nossr50/config/RankConfig.java @@ -13,7 +13,7 @@ public class RankConfig extends AutoUpdateConfigLoader { { super("skillranks.yml"); validate(); - this.instance = this; + instance = this; } @Override diff --git a/src/main/java/com/gmail/nossr50/config/SoundConfig.java b/src/main/java/com/gmail/nossr50/config/SoundConfig.java index 1bd215461..734e770aa 100644 --- a/src/main/java/com/gmail/nossr50/config/SoundConfig.java +++ b/src/main/java/com/gmail/nossr50/config/SoundConfig.java @@ -9,7 +9,7 @@ public class SoundConfig extends AutoUpdateConfigLoader { { super("sounds.yml"); validate(); - this.instance = this; + instance = this; } @Override diff --git a/src/main/java/com/gmail/nossr50/config/WorldBlacklist.java b/src/main/java/com/gmail/nossr50/config/WorldBlacklist.java index d9bd04b68..f0fd6bd2b 100644 --- a/src/main/java/com/gmail/nossr50/config/WorldBlacklist.java +++ b/src/main/java/com/gmail/nossr50/config/WorldBlacklist.java @@ -11,7 +11,7 @@ import java.util.ArrayList; */ public class WorldBlacklist { private static ArrayList blacklist; - private mcMMO plugin; + private final mcMMO plugin; private final String blackListFileName = "world_blacklist.txt"; diff --git a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java index 1c8ae0f13..bb479c931 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java @@ -18,16 +18,16 @@ import java.util.Map; public class PotionConfig extends ConfigLoader { private static PotionConfig instance; - private List concoctionsIngredientsTierOne = new ArrayList(); - private List concoctionsIngredientsTierTwo = new ArrayList(); - private List concoctionsIngredientsTierThree = new ArrayList(); - private List concoctionsIngredientsTierFour = new ArrayList(); - private List concoctionsIngredientsTierFive = new ArrayList(); - private List concoctionsIngredientsTierSix = new ArrayList(); - private List concoctionsIngredientsTierSeven = new ArrayList(); - private List concoctionsIngredientsTierEight = new ArrayList(); + private final List concoctionsIngredientsTierOne = new ArrayList(); + private final List concoctionsIngredientsTierTwo = new ArrayList(); + private final List concoctionsIngredientsTierThree = new ArrayList(); + private final List concoctionsIngredientsTierFour = new ArrayList(); + private final List concoctionsIngredientsTierFive = new ArrayList(); + private final List concoctionsIngredientsTierSix = new ArrayList(); + private final List concoctionsIngredientsTierSeven = new ArrayList(); + private final List concoctionsIngredientsTierEight = new ArrayList(); - private Map potionMap = new HashMap(); + private final Map potionMap = new HashMap(); private PotionConfig() { super("potions.yml"); @@ -280,8 +280,7 @@ public class PotionConfig extends ConfigLoader { green += color.getGreen(); blue += color.getBlue(); } - Color color = Color.fromRGB(red/colors.size(), green/colors.size(), blue/colors.size()); - return color; + return Color.fromRGB(red/colors.size(), green/colors.size(), blue/colors.size()); } } diff --git a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java index 8449faf2b..76ea32bbc 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java @@ -15,7 +15,7 @@ import java.util.*; public class RepairConfig extends ConfigLoader { private List repairables; - private HashSet notSupported; + private final HashSet notSupported; public RepairConfig(String fileName) { super(fileName); diff --git a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java index 28bee3198..a858c2890 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java @@ -18,7 +18,7 @@ import java.util.*; public class SalvageConfig extends ConfigLoader { private List salvageables; - private HashSet notSupported; + private final HashSet notSupported; public SalvageConfig(String fileName) { super(fileName); diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java index 314b91800..f5769d93e 100644 --- a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java @@ -12,19 +12,19 @@ import java.util.UUID; public interface DatabaseManager { // One month in milliseconds - public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff(); + long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff(); // During convertUsers, how often to output a status - public final int progressInterval = 200; + int progressInterval = 200; /** * Purge users with 0 power level from the database. */ - public void purgePowerlessUsers(); + void purgePowerlessUsers(); /** * Purge users who haven't logged on in over a certain time frame from the database. */ - public void purgeOldUsers(); + void purgeOldUsers(); /** * Remove a user from the database. @@ -33,14 +33,14 @@ public interface DatabaseManager { * @param uuid player UUID, can be null * @return true if the user was successfully removed, false otherwise */ - public boolean removeUser(String playerName, UUID uuid); + boolean removeUser(String playerName, UUID uuid); /** * Removes any cache used for faster lookups * Currently only used for SQL * @param uuid target UUID to cleanup */ - public void cleanupUser(UUID uuid); + void cleanupUser(UUID uuid); /** * Save a user to the database. @@ -48,7 +48,7 @@ public interface DatabaseManager { * @param profile The profile of the player to save * @return true if successful, false on failure */ - public boolean saveUser(PlayerProfile profile); + boolean saveUser(PlayerProfile profile); /** * Retrieve leaderboard info. @@ -58,7 +58,7 @@ public interface DatabaseManager { * @param statsPerPage The number of stats per page * @return the requested leaderboard information */ - public List readLeaderboard(PrimarySkillType skill, int pageNumber, int statsPerPage); + List readLeaderboard(PrimarySkillType skill, int pageNumber, int statsPerPage); /** * Retrieve rank info into a HashMap from PrimarySkillType to the rank. @@ -69,7 +69,7 @@ public interface DatabaseManager { * @param playerName The name of the user to retrieve the rankings for * @return the requested rank information */ - public Map readRank(String playerName); + Map readRank(String playerName); /** * Add a new user to the database. @@ -77,7 +77,7 @@ public interface DatabaseManager { * @param playerName The name of the player to be added to the database * @param uuid The uuid of the player to be added to the database */ - public void newUser(String playerName, UUID uuid); + void newUser(String playerName, UUID uuid); /** * Load a player from the database. @@ -91,7 +91,7 @@ public interface DatabaseManager { * and createNew is false */ @Deprecated - public PlayerProfile loadPlayerProfile(String playerName, boolean createNew); + PlayerProfile loadPlayerProfile(String playerName, boolean createNew); /** * Load a player from the database. @@ -99,7 +99,7 @@ public interface DatabaseManager { * @param uuid The uuid of the player to load from the database * @return The player's data, or an unloaded PlayerProfile if not found */ - public PlayerProfile loadPlayerProfile(UUID uuid); + PlayerProfile loadPlayerProfile(UUID uuid); /** * Load a player from the database. Attempt to use uuid, fall back on playername @@ -111,14 +111,14 @@ public interface DatabaseManager { * @return The player's data, or an unloaded PlayerProfile if not found * and createNew is false */ - public PlayerProfile loadPlayerProfile(String playerName, UUID uuid, boolean createNew); + PlayerProfile loadPlayerProfile(String playerName, UUID uuid, boolean createNew); /** * Get all users currently stored in the database. * * @return list of playernames */ - public List getStoredUsers(); + List getStoredUsers(); /** * Convert all users from this database to the provided database using @@ -126,21 +126,21 @@ public interface DatabaseManager { * * @param destination The DatabaseManager to save to */ - public void convertUsers(DatabaseManager destination); + void convertUsers(DatabaseManager destination); - public boolean saveUserUUID(String userName, UUID uuid); + boolean saveUserUUID(String userName, UUID uuid); - public boolean saveUserUUIDs(Map fetchedUUIDs); + boolean saveUserUUIDs(Map fetchedUUIDs); /** * Retrieve the type of database in use. Custom databases should return CUSTOM. * * @return The type of database */ - public DatabaseType getDatabaseType(); + DatabaseType getDatabaseType(); /** * Called when the plugin disables */ - public void onDisable(); + void onDisable(); } diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index a634fbf6b..138e4615c 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java @@ -809,20 +809,20 @@ public final class FlatfileDatabaseManager implements DatabaseManager { SkillComparator c = new SkillComparator(); - Collections.sort(mining, c); - Collections.sort(woodcutting, c); - Collections.sort(repair, c); - Collections.sort(unarmed, c); - Collections.sort(herbalism, c); - Collections.sort(excavation, c); - Collections.sort(archery, c); - Collections.sort(swords, c); - Collections.sort(axes, c); - Collections.sort(acrobatics, c); - Collections.sort(taming, c); - Collections.sort(fishing, c); - Collections.sort(alchemy, c); - Collections.sort(powerLevels, c); + mining.sort(c); + woodcutting.sort(c); + repair.sort(c); + unarmed.sort(c); + herbalism.sort(c); + excavation.sort(c); + archery.sort(c); + swords.sort(c); + axes.sort(c); + acrobatics.sort(c); + taming.sort(c); + fishing.sort(c); + alchemy.sort(c); + powerLevels.sort(c); playerStatHash.put(PrimarySkillType.MINING, mining); playerStatHash.put(PrimarySkillType.WOODCUTTING, woodcutting); diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index e7637edb8..be165b87b 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -23,7 +23,7 @@ import java.util.concurrent.locks.ReentrantLock; public final class SQLDatabaseManager implements DatabaseManager { private static final String ALL_QUERY_VERSION = "total"; - private String tablePrefix = Config.getInstance().getMySQLTablePrefix(); + private final String tablePrefix = Config.getInstance().getMySQLTablePrefix(); private final Map cachedUserIDs = new HashMap(); @@ -33,7 +33,7 @@ public final class SQLDatabaseManager implements DatabaseManager { private boolean debug = false; - private ReentrantLock massUpdateLock = new ReentrantLock(); + private final ReentrantLock massUpdateLock = new ReentrantLock(); protected SQLDatabaseManager() { String connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName() @@ -1488,9 +1488,8 @@ public final class SQLDatabaseManager implements DatabaseManager { resultSet = statement.executeQuery(); if (resultSet.next()) { - int id = resultSet.getInt("id"); - return id; + return resultSet.getInt("id"); } } catch (SQLException ex) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/BlockSnapshot.java b/src/main/java/com/gmail/nossr50/datatypes/BlockSnapshot.java index 83e572b41..ca60cc4a8 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/BlockSnapshot.java +++ b/src/main/java/com/gmail/nossr50/datatypes/BlockSnapshot.java @@ -9,7 +9,7 @@ import org.bukkit.block.Block; */ public class BlockSnapshot { private final Material oldType; - private Block blockRef; + private final Block blockRef; public BlockSnapshot(Material oldType, Block blockRef) { this.oldType = oldType; diff --git a/src/main/java/com/gmail/nossr50/datatypes/MobHealthbarType.java b/src/main/java/com/gmail/nossr50/datatypes/MobHealthbarType.java index 3c67df798..e46eb7af5 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/MobHealthbarType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/MobHealthbarType.java @@ -3,5 +3,5 @@ package com.gmail.nossr50.datatypes; public enum MobHealthbarType { HEARTS, BAR, - DISABLED; + DISABLED } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/datatypes/chat/ChatMode.java b/src/main/java/com/gmail/nossr50/datatypes/chat/ChatMode.java index 1596faf2a..a327ad11c 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/chat/ChatMode.java +++ b/src/main/java/com/gmail/nossr50/datatypes/chat/ChatMode.java @@ -6,10 +6,10 @@ public enum ChatMode { ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")), PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off")); - private String enabledMessage; - private String disabledMessage; + private final String enabledMessage; + private final String disabledMessage; - private ChatMode(String enabledMessage, String disabledMessage) { + ChatMode(String enabledMessage, String disabledMessage) { this.enabledMessage = enabledMessage; this.disabledMessage = disabledMessage; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/mods/CustomBlock.java b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomBlock.java index 65e9d6121..924c66415 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/mods/CustomBlock.java +++ b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomBlock.java @@ -1,9 +1,9 @@ package com.gmail.nossr50.datatypes.mods; public class CustomBlock { - private int xpGain; - private boolean canDoubleDrop; - private int smeltingXpGain; + private final int xpGain; + private final boolean canDoubleDrop; + private final int smeltingXpGain; public CustomBlock(int xpGain, boolean canDoubleDrop, int smeltingXpGain) { this.xpGain = xpGain; diff --git a/src/main/java/com/gmail/nossr50/datatypes/mods/CustomEntity.java b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomEntity.java index 2d89d1547..c1b8fc118 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/mods/CustomEntity.java +++ b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomEntity.java @@ -3,12 +3,12 @@ package com.gmail.nossr50.datatypes.mods; import org.bukkit.inventory.ItemStack; public class CustomEntity { - private double xpMultiplier; - private boolean canBeTamed; - private int tamingXP; - private boolean canBeSummoned; - private ItemStack callOfTheWildItem; - private int callOfTheWildAmount; + private final double xpMultiplier; + private final boolean canBeTamed; + private final int tamingXP; + private final boolean canBeSummoned; + private final ItemStack callOfTheWildItem; + private final int callOfTheWildAmount; public CustomEntity(double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) { this.xpMultiplier = xpMultiplier; diff --git a/src/main/java/com/gmail/nossr50/datatypes/mods/CustomTool.java b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomTool.java index 93c24dfab..af02f90b4 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/mods/CustomTool.java +++ b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomTool.java @@ -1,9 +1,9 @@ package com.gmail.nossr50.datatypes.mods; public class CustomTool { - private double xpMultiplier; - private boolean abilityEnabled; - private int tier; + private final double xpMultiplier; + private final boolean abilityEnabled; + private final int tier; public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier) { this.xpMultiplier = xpMultiplier; diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/PartyLeader.java b/src/main/java/com/gmail/nossr50/datatypes/party/PartyLeader.java index 3292b3723..4317b83df 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/PartyLeader.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/PartyLeader.java @@ -3,8 +3,8 @@ package com.gmail.nossr50.datatypes.party; import java.util.UUID; public class PartyLeader { - private UUID uuid; - private String playerName; + private final UUID uuid; + private final String playerName; public PartyLeader(UUID uuid, String playerName) { this.uuid = uuid; diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index d848d98d9..214081384 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -65,11 +65,11 @@ import java.util.Set; import java.util.UUID; public class McMMOPlayer { - private Player player; - private PlayerProfile profile; + private final Player player; + private final PlayerProfile profile; private final Map skillManagers = new HashMap(); - private ExperienceBarManager experienceBarManager; + private final ExperienceBarManager experienceBarManager; private Party party; private Party invite; @@ -102,7 +102,7 @@ public class McMMOPlayer { private boolean isUsingUnarmed; private final FixedMetadataValue playerMetadata; - private String playerName; + private final String playerName; public McMMOPlayer(Player player, PlayerProfile profile) { this.playerName = player.getName(); diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index ceefb54d3..f8463aa02 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -38,8 +38,8 @@ public class PlayerProfile { private final Map uniquePlayerData = new HashMap<>(); //Misc data that doesn't fit into other categories (chimaera wing, etc..) // Store previous XP gains for diminished returns - private DelayQueue gainedSkillsXp = new DelayQueue(); - private HashMap rollingSkillsXp = new HashMap(); + private final DelayQueue gainedSkillsXp = new DelayQueue(); + private final HashMap rollingSkillsXp = new HashMap(); @Deprecated public PlayerProfile(String playerName) { @@ -248,9 +248,7 @@ public class PlayerProfile { protected void resetCooldowns() { markProfileDirty(); - for (SuperAbilityType ability : abilityDATS.keySet()) { - abilityDATS.put(ability, 0); - } + abilityDATS.replaceAll((a, v) -> 0); } /* diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/ItemType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/ItemType.java index f0d786d73..b6f99cc4f 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/ItemType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/ItemType.java @@ -3,5 +3,5 @@ package com.gmail.nossr50.datatypes.skills; public enum ItemType { ARMOR, TOOL, - OTHER; + OTHER } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java index 75fd7540f..fd9f89639 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java @@ -65,11 +65,11 @@ public enum PrimarySkillType { WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, SuperAbilityType.TREE_FELLER, ToolType.AXE, ImmutableList.of(SubSkillType.WOODCUTTING_LEAF_BLOWER, SubSkillType.WOODCUTTING_TREE_FELLER, SubSkillType.WOODCUTTING_HARVEST_LUMBER)); - private Class managerClass; - private Color skillColor; - private SuperAbilityType ability; - private ToolType tool; - private List subSkillTypes; + private final Class managerClass; + private final Color skillColor; + private final SuperAbilityType ability; + private final ToolType tool; + private final List subSkillTypes; public static final List SKILL_NAMES; public static final List SUBSKILL_NAMES; @@ -110,11 +110,11 @@ public enum PrimarySkillType { NON_CHILD_SKILLS = ImmutableList.copyOf(nonChildSkills); } - private PrimarySkillType(Class managerClass, Color skillColor, List subSkillTypes) { + PrimarySkillType(Class managerClass, Color skillColor, List subSkillTypes) { this(managerClass, skillColor, null, null, subSkillTypes); } - private PrimarySkillType(Class managerClass, Color skillColor, SuperAbilityType ability, ToolType tool, List subSkillTypes) { + PrimarySkillType(Class managerClass, Color skillColor, SuperAbilityType ability, ToolType tool, List subSkillTypes) { this.managerClass = managerClass; this.skillColor = skillColor; this.ability = ability; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java index 1e67e9b38..f72ede1bd 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java @@ -189,7 +189,7 @@ public enum SubSkillType { String subskillNameWithoutPrefix = subSkillName.substring(subStringIndex); if(subskillNameWithoutPrefix.contains("_")) { - String splitStrings[] = subskillNameWithoutPrefix.split("_"); + String[] splitStrings = subskillNameWithoutPrefix.split("_"); for(String string : splitStrings) { @@ -215,7 +215,7 @@ public enum SubSkillType { String subskillNameWithoutPrefix = subSkillName.substring(subStringIndex); if(subskillNameWithoutPrefix.contains("_")) { - String splitStrings[] = subskillNameWithoutPrefix.split("_"); + String[] splitStrings = subskillNameWithoutPrefix.split("_"); for(int i = 0; i < splitStrings.length; i++) { @@ -295,14 +295,12 @@ public enum SubSkillType { public String getLocaleStat(String... vars) { - String statMsg = LocaleLoader.getString("Ability.Generic.Template", (Object[]) vars); - return statMsg; + return LocaleLoader.getString("Ability.Generic.Template", (Object[]) vars); } public String getCustomLocaleStat(String... vars) { - String statMsg = LocaleLoader.getString("Ability.Generic.Template.Custom", (Object[]) vars); - return statMsg; + return LocaleLoader.getString("Ability.Generic.Template.Custom", (Object[]) vars); } private String getFromLocaleSubAddress(String s) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java index 4aa3df817..cb4b0b10e 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java @@ -85,14 +85,14 @@ public enum SuperAbilityType { BLAST_MINING.subSkillTypeDefinition = SubSkillType.MINING_BLAST_MINING; } - private String abilityOn; - private String abilityOff; - private String abilityPlayer; - private String abilityRefresh; - private String abilityPlayerOff; + private final String abilityOn; + private final String abilityOff; + private final String abilityPlayer; + private final String abilityRefresh; + private final String abilityPlayerOff; private SubSkillType subSkillTypeDefinition; - private SuperAbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) { + SuperAbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) { this.abilityOn = abilityOn; this.abilityOff = abilityOff; this.abilityPlayer = abilityPlayer; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java index 2d50ebac4..9fdb444e9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/ToolType.java @@ -12,10 +12,10 @@ public enum ToolType { SHOVEL("Excavation.Ability.Lower", "Excavation.Ability.Ready"), SWORD("Swords.Ability.Lower", "Swords.Ability.Ready"); - private String lowerTool; - private String raiseTool; + private final String lowerTool; + private final String raiseTool; - private ToolType(String lowerTool, String raiseTool) { + ToolType(String lowerTool, String raiseTool) { this.lowerTool = lowerTool; this.raiseTool = raiseTool; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java b/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java index 1f522679a..c767004df 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java @@ -14,7 +14,7 @@ import java.util.Map; import java.util.Map.Entry; public class AlchemyPotion { - private Material material; + private final Material material; private PotionData data; private String name; private List lore; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/PotionStage.java b/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/PotionStage.java index 70da6d529..fe2778eed 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/PotionStage.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/PotionStage.java @@ -16,7 +16,7 @@ public enum PotionStage { int numerical; - private PotionStage(int numerical) { + PotionStage(int numerical) { this.numerical = numerical; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java index eae0f6c7d..0718fec8c 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java @@ -65,31 +65,24 @@ public class Roll extends AcrobaticsSubSkill { if(!EventUtils.isRealPlayerDamaged(entityDamageEvent)) return false; - switch (entityDamageEvent.getCause()) { - case FALL: + if (entityDamageEvent.getCause() == EntityDamageEvent.DamageCause.FALL) {//Grab the player + McMMOPlayer mcMMOPlayer = EventUtils.getMcMMOPlayer(entityDamageEvent.getEntity()); - //Grab the player - McMMOPlayer mcMMOPlayer = EventUtils.getMcMMOPlayer(entityDamageEvent.getEntity()); + if (mcMMOPlayer == null) + return false; - if(mcMMOPlayer == null) - break; + /* + * Check for success + */ + Player player = (Player) ((EntityDamageEvent) event).getEntity(); + if (canRoll(player)) { + entityDamageEvent.setDamage(rollCheck(player, mcMMOPlayer, entityDamageEvent.getDamage())); - /* - * Check for success - */ - Player player = (Player) ((EntityDamageEvent) event).getEntity(); - if (canRoll(player)) { - entityDamageEvent.setDamage(rollCheck(player, mcMMOPlayer, entityDamageEvent.getDamage())); - - if (entityDamageEvent.getFinalDamage() == 0) { - entityDamageEvent.setCancelled(true); - return true; - } + if (entityDamageEvent.getFinalDamage() == 0) { + entityDamageEvent.setCancelled(true); + return true; } - break; - - default: - break; + } } return false; @@ -420,8 +413,7 @@ public class Roll extends AcrobaticsSubSkill { playerChanceRoll = RandomChanceUtil.getRandomChanceExecutionChance(roll); playerChanceGrace = RandomChanceUtil.getRandomChanceExecutionChance(graceful); - Double[] stats = { playerChanceRoll, playerChanceGrace }; //DEBUG - return stats; + return new Double[]{ playerChanceRoll, playerChanceGrace }; } public void addFallLocation(Player player) diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/taming/TamingSummon.java b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/taming/TamingSummon.java index ebb2a5690..f92155a6a 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/taming/TamingSummon.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/taming/TamingSummon.java @@ -8,12 +8,12 @@ import org.bukkit.entity.EntityType; */ public class TamingSummon { - private Material itemType; - private int itemAmountRequired; - private int entitiesSummoned; - private int summonLifespan; - private int summonCap; - private CallOfTheWildType callOfTheWildType; + private final Material itemType; + private final int itemAmountRequired; + private final int entitiesSummoned; + private final int summonLifespan; + private final int summonCap; + private final CallOfTheWildType callOfTheWildType; private EntityType entityType; public TamingSummon(CallOfTheWildType callOfTheWildType, Material itemType, int itemAmountRequired, int entitiesSummoned, int summonLifespan, int summonCap) { diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java index 9c4f3ae68..3dee6a384 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java @@ -7,8 +7,8 @@ import org.bukkit.plugin.Plugin; public abstract class McMMOChatEvent extends Event implements Cancellable { private boolean cancelled; - private Plugin plugin; - private String sender; + private final Plugin plugin; + private final String sender; private String displayName; private String message; diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java index ffa54f815..66f37cdda 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java @@ -6,7 +6,7 @@ import org.bukkit.plugin.Plugin; * Called when a chat is sent to a party channel */ public class McMMOPartyChatEvent extends McMMOChatEvent { - private String party; + private final String party; public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, String party, String message) { super(plugin, sender, displayName, message); diff --git a/src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerVampirismEvent.java b/src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerVampirismEvent.java index 735094f67..8aa59d521 100644 --- a/src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerVampirismEvent.java +++ b/src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerVampirismEvent.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import java.util.HashMap; public class McMMOPlayerVampirismEvent extends McMMOPlayerDeathPenaltyEvent { - private boolean isVictim; + private final boolean isVictim; public McMMOPlayerVampirismEvent(Player player, boolean isVictim, HashMap levelChanged, HashMap experienceChanged) { super(player, levelChanged, experienceChanged); diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyAllianceChangeEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyAllianceChangeEvent.java index 1e126e501..f902561a2 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyAllianceChangeEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyAllianceChangeEvent.java @@ -6,9 +6,9 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancellable { - private String oldAlly; - private String newAlly; - private EventReason reason; + private final String oldAlly; + private final String newAlly; + private final EventReason reason; private boolean cancelled; public McMMOPartyAllianceChangeEvent(Player player, String oldAlly, String newAlly, EventReason reason) { @@ -62,7 +62,7 @@ public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancel /** * Any reason that doesn't fit elsewhere. */ - CUSTOM; + CUSTOM } /** Following are required for Cancellable **/ diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java index f2d3f537e..bac977001 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java @@ -9,9 +9,9 @@ import org.bukkit.event.player.PlayerEvent; * Called when a player attempts to join, leave, or change parties. */ public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable { - private String oldParty; - private String newParty; - private EventReason reason; + private final String oldParty; + private final String newParty; + private final EventReason reason; private boolean cancelled; public McMMOPartyChangeEvent(Player player, String oldParty, String newParty, EventReason reason) { @@ -75,7 +75,7 @@ public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable { /** * Any reason that doesn't fit elsewhere. */ - CUSTOM; + CUSTOM } /** Following are required for Cancellable **/ diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyLevelUpEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyLevelUpEvent.java index 0fcdabd7a..b6790dd48 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyLevelUpEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyLevelUpEvent.java @@ -6,7 +6,7 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; public class McMMOPartyLevelUpEvent extends Event implements Cancellable { - private Party party; + private final Party party; private int levelsChanged; private boolean cancelled; diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java index 9bc1fe1ee..88a5f666b 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java @@ -8,8 +8,8 @@ import org.bukkit.event.player.PlayerTeleportEvent; * Called just before a player teleports using the /ptp command. */ public class McMMOPartyTeleportEvent extends PlayerTeleportEvent { - private String party; - private Player target; + private final String party; + private final Player target; public McMMOPartyTeleportEvent(Player player, Player target, String party) { super(player, player.getLocation(), target.getLocation(), TeleportCause.COMMAND); diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyXpGainEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyXpGainEvent.java index 16dbd95a2..1b001f3b8 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyXpGainEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyXpGainEvent.java @@ -6,7 +6,7 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; public class McMMOPartyXpGainEvent extends Event implements Cancellable { - private Party party; + private final Party party; private float xpGained; private boolean cancelled; diff --git a/src/main/java/com/gmail/nossr50/events/players/McMMOPlayerProfileLoadEvent.java b/src/main/java/com/gmail/nossr50/events/players/McMMOPlayerProfileLoadEvent.java index fa654014e..e8a517754 100644 --- a/src/main/java/com/gmail/nossr50/events/players/McMMOPlayerProfileLoadEvent.java +++ b/src/main/java/com/gmail/nossr50/events/players/McMMOPlayerProfileLoadEvent.java @@ -9,8 +9,8 @@ import org.bukkit.event.HandlerList; public class McMMOPlayerProfileLoadEvent extends Event implements Cancellable { private boolean cancelled; - private PlayerProfile profile; - private Player player; + private final PlayerProfile profile; + private final Player player; public McMMOPlayerProfileLoadEvent(Player player, PlayerProfile profile){ super(!Bukkit.isPrimaryThread()); diff --git a/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityEvent.java b/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityEvent.java index bb1fd5f3a..706055df3 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/abilities/McMMOPlayerAbilityEvent.java @@ -6,7 +6,7 @@ import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent; import org.bukkit.entity.Player; public class McMMOPlayerAbilityEvent extends McMMOPlayerSkillEvent { - private SuperAbilityType ability; + private final SuperAbilityType ability; protected McMMOPlayerAbilityEvent(Player player, PrimarySkillType skill) { super(player, skill); diff --git a/src/main/java/com/gmail/nossr50/events/skills/alchemy/McMMOPlayerBrewEvent.java b/src/main/java/com/gmail/nossr50/events/skills/alchemy/McMMOPlayerBrewEvent.java index 1611fc178..ca62829cb 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/alchemy/McMMOPlayerBrewEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/alchemy/McMMOPlayerBrewEvent.java @@ -9,7 +9,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; public class McMMOPlayerBrewEvent extends McMMOPlayerSkillEvent implements Cancellable { - private BlockState brewingStand; + private final BlockState brewingStand; private boolean cancelled; diff --git a/src/main/java/com/gmail/nossr50/events/skills/fishing/McMMOPlayerMagicHunterEvent.java b/src/main/java/com/gmail/nossr50/events/skills/fishing/McMMOPlayerMagicHunterEvent.java index 8c993b5a4..decd27ad5 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/fishing/McMMOPlayerMagicHunterEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/fishing/McMMOPlayerMagicHunterEvent.java @@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Map; public class McMMOPlayerMagicHunterEvent extends McMMOPlayerFishingTreasureEvent { - private Map enchants; + private final Map enchants; public McMMOPlayerMagicHunterEvent(Player player, ItemStack treasure, int xp, Map enchants) { super(player, treasure, xp); diff --git a/src/main/java/com/gmail/nossr50/events/skills/repair/McMMOPlayerRepairCheckEvent.java b/src/main/java/com/gmail/nossr50/events/skills/repair/McMMOPlayerRepairCheckEvent.java index 638f8c202..fd4a02754 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/repair/McMMOPlayerRepairCheckEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/repair/McMMOPlayerRepairCheckEvent.java @@ -10,9 +10,9 @@ import org.bukkit.inventory.ItemStack; * Called just before a player repairs an object with mcMMO. */ public class McMMOPlayerRepairCheckEvent extends McMMOPlayerSkillEvent implements Cancellable { - private short repairAmount; - private ItemStack repairMaterial; - private ItemStack repairedObject; + private final short repairAmount; + private final ItemStack repairMaterial; + private final ItemStack repairedObject; private boolean cancelled; public McMMOPlayerRepairCheckEvent(Player player, short repairAmount, ItemStack repairMaterial, ItemStack repairedObject) { diff --git a/src/main/java/com/gmail/nossr50/events/skills/salvage/McMMOPlayerSalvageCheckEvent.java b/src/main/java/com/gmail/nossr50/events/skills/salvage/McMMOPlayerSalvageCheckEvent.java index 0a44c2621..6a8061763 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/salvage/McMMOPlayerSalvageCheckEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/salvage/McMMOPlayerSalvageCheckEvent.java @@ -10,9 +10,9 @@ import org.bukkit.inventory.ItemStack; * Called just before a player salvages an item with mcMMO. */ public class McMMOPlayerSalvageCheckEvent extends McMMOPlayerSkillEvent implements Cancellable { - private ItemStack salvageItem; - private ItemStack salvageResults; - private ItemStack enchantedBook; + private final ItemStack salvageItem; + private final ItemStack salvageResults; + private final ItemStack enchantedBook; private boolean cancelled; public McMMOPlayerSalvageCheckEvent(Player player, ItemStack salvageItem, ItemStack salvageResults, ItemStack enchantedBook) { diff --git a/src/main/java/com/gmail/nossr50/events/skills/unarmed/McMMOPlayerDisarmEvent.java b/src/main/java/com/gmail/nossr50/events/skills/unarmed/McMMOPlayerDisarmEvent.java index 0859a37d1..7404aaa22 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/unarmed/McMMOPlayerDisarmEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/unarmed/McMMOPlayerDisarmEvent.java @@ -7,7 +7,7 @@ import org.bukkit.event.Cancellable; public class McMMOPlayerDisarmEvent extends McMMOPlayerSkillEvent implements Cancellable { private boolean cancelled; - private Player defender; + private final Player defender; public McMMOPlayerDisarmEvent(Player defender) { super(defender, PrimarySkillType.UNARMED); diff --git a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java index 0a25c37b3..48a8faff2 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java +++ b/src/main/java/com/gmail/nossr50/listeners/InteractionManager.java @@ -39,8 +39,7 @@ public class InteractionManager { subSkillList.add(abstractSubSkill); //Init ArrayList - if(interactRegister.get(abstractSubSkill.getInteractType()) == null) - interactRegister.put(abstractSubSkill.getInteractType(), new ArrayList<>()); + interactRegister.computeIfAbsent(abstractSubSkill.getInteractType(), k -> new ArrayList<>()); //Registration array reference ArrayList arrayRef = interactRegister.get(abstractSubSkill.getInteractType()); @@ -51,8 +50,7 @@ public class InteractionManager { String lowerCaseName = abstractSubSkill.getConfigKeyName().toLowerCase(Locale.ENGLISH); //Register in name map - if(subSkillNameMap.get(lowerCaseName) == null) - subSkillNameMap.put(lowerCaseName, abstractSubSkill); + subSkillNameMap.putIfAbsent(lowerCaseName, abstractSubSkill); mcMMO.p.getLogger().info("Registered subskill: "+ abstractSubSkill.getConfigKeyName()); } diff --git a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java index 42df75d0f..11fc4841b 100644 --- a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java +++ b/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java @@ -20,7 +20,7 @@ public final class LocaleLoader { private static ResourceBundle filesystemBundle = null; private static ResourceBundle enBundle = null; - private LocaleLoader() {}; + private LocaleLoader() {} public static String getString(String key) { return getString(key, (Object[]) null); diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index ec7f5df41..98b19710a 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -506,7 +506,6 @@ public class mcMMO extends JavaPlugin { new ChildConfig(); List repairables = new ArrayList(); - List salvageables = new ArrayList(); if (Config.getInstance().getToolModsEnabled()) { new ToolConfigManager(this); @@ -532,7 +531,7 @@ public class mcMMO extends JavaPlugin { // Load salvage configs, make manager and register them at this time SalvageConfigManager sManager = new SalvageConfigManager(this); - salvageables.addAll(sManager.getLoadedSalvageables()); + List salvageables = new ArrayList(sManager.getLoadedSalvageables()); salvageableManager = new SimpleSalvageableManager(salvageables.size()); salvageableManager.registerSalvageables(salvageables); } diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index f27390613..2074fc4bb 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -33,9 +33,9 @@ import java.util.Map.Entry; import java.util.UUID; public final class PartyManager { - private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml"; - private static List parties = new ArrayList(); - private static File partyFile = new File(partiesFilePath); + private static final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml"; + private static final List parties = new ArrayList(); + private static final File partyFile = new File(partiesFilePath); private PartyManager() {} diff --git a/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java b/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java index 111ed9482..3e5cc78cc 100644 --- a/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java @@ -5,7 +5,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.scheduler.BukkitRunnable; public class MobHealthDisplayUpdaterTask extends BukkitRunnable { - private LivingEntity target; + private final LivingEntity target; public MobHealthDisplayUpdaterTask(LivingEntity target) { this.target = target; diff --git a/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java b/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java index 9f01d64e5..61daa764d 100644 --- a/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java @@ -9,9 +9,9 @@ import org.bukkit.scheduler.BukkitRunnable; import java.util.List; public class PistonTrackerTask extends BukkitRunnable { - private List blocks; - private BlockFace direction; - private Block futureEmptyBlock; + private final List blocks; + private final BlockFace direction; + private final Block futureEmptyBlock; public PistonTrackerTask(List blocks, BlockFace direction, Block futureEmptyBlock) { this.blocks = blocks; diff --git a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java index 00062659b..d90da3b31 100644 --- a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java @@ -7,9 +7,9 @@ import org.bukkit.block.BlockFace; import org.bukkit.scheduler.BukkitRunnable; public class StickyPistonTrackerTask extends BukkitRunnable { - private BlockFace direction; - private Block block; - private Block movedBlock; + private final BlockFace direction; + private final Block block; + private final Block movedBlock; public StickyPistonTrackerTask(BlockFace direction, Block block, Block movedBlock) { this.direction = direction; diff --git a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java index 822683030..d0c333592 100644 --- a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java @@ -58,11 +58,7 @@ public class CleanBackupsTask extends BukkitRunnable { continue; } else { - List savedWeeks = savedYearsWeeks.get(year); - if (savedWeeks == null) { - savedWeeks = new ArrayList(); - savedYearsWeeks.put(year, savedWeeks); - } + List savedWeeks = savedYearsWeeks.computeIfAbsent(year, k -> new ArrayList()); if (!savedWeeks.contains(weekOfYear) && Config.getInstance().getKeepWeeklyPastMonth()) { // Keep one backup of each week diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java index 5a318596f..a5d02c1dc 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McScoreboardKeepTask.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; public class McScoreboardKeepTask extends BukkitRunnable { - private Player player; + private final Player player; public McScoreboardKeepTask(Player player) { this.player = player; diff --git a/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java index eaf30befe..0089ee677 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java @@ -21,11 +21,6 @@ public class DatabaseConversionTask extends BukkitRunnable { public void run() { sourceDatabase.convertUsers(mcMMO.getDatabaseManager()); - mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, new Runnable() { - @Override - public void run() { - sender.sendMessage(message); - } - }); + mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, () -> sender.sendMessage(message)); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java index f818cebba..f8b231b58 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java @@ -14,8 +14,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.scheduler.BukkitRunnable; public class FormulaConversionTask extends BukkitRunnable { - private CommandSender sender; - private FormulaType formulaType; + private final CommandSender sender; + private final FormulaType formulaType; public FormulaConversionTask(CommandSender sender, FormulaType formulaType) { this.sender = sender; diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java index db8d83f3d..8ce66bfa8 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java @@ -7,7 +7,7 @@ import org.bukkit.scheduler.BukkitRunnable; import java.util.concurrent.locks.ReentrantLock; public class UserPurgeTask extends BukkitRunnable { - private ReentrantLock lock = new ReentrantLock(); + private final ReentrantLock lock = new ReentrantLock(); @Override public void run() { lock.lock(); diff --git a/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java index 5e267a56a..b4ae92426 100644 --- a/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java +++ b/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java @@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; public class ChimaeraWingWarmup extends BukkitRunnable { - private McMMOPlayer mcMMOPlayer; + private final McMMOPlayer mcMMOPlayer; public ChimaeraWingWarmup(McMMOPlayer mcMMOPlayer) { this.mcMMOPlayer = mcMMOPlayer; diff --git a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java index d9a62429b..d3315d4ab 100644 --- a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java +++ b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java @@ -14,8 +14,8 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; public class TeleportationWarmup extends BukkitRunnable { - private McMMOPlayer mcMMOPlayer; - private McMMOPlayer mcMMOTarget; + private final McMMOPlayer mcMMOPlayer; + private final McMMOPlayer mcMMOTarget; public TeleportationWarmup(McMMOPlayer mcMMOPlayer, McMMOPlayer mcMMOTarget) { this.mcMMOPlayer = mcMMOPlayer; diff --git a/src/main/java/com/gmail/nossr50/runnables/party/PartyChatTask.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyChatTask.java index ff4b4999f..aca2d25e1 100644 --- a/src/main/java/com/gmail/nossr50/runnables/party/PartyChatTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyChatTask.java @@ -12,11 +12,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public class PartyChatTask extends BukkitRunnable { - private Plugin plugin; + private final Plugin plugin; - private Party party; - private String senderName; - private String displayName; + private final Party party; + private final String senderName; + private final String displayName; private String message; public PartyChatTask(Plugin plugin, Party party, String senderName, String displayName, String message) { diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java index 593d785ca..2a6d30c69 100644 --- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileSaveTask.java @@ -4,8 +4,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile; import org.bukkit.scheduler.BukkitRunnable; public class PlayerProfileSaveTask extends BukkitRunnable { - private PlayerProfile playerProfile; - private boolean isSync; + private final PlayerProfile playerProfile; + private final boolean isSync; public PlayerProfileSaveTask(PlayerProfile playerProfile, boolean isSync) { this.playerProfile = playerProfile; diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java index d255eee2a..cdfb17d88 100644 --- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerUpdateInventoryTask.java @@ -5,7 +5,7 @@ import org.bukkit.scheduler.BukkitRunnable; @SuppressWarnings("deprecation") public class PlayerUpdateInventoryTask extends BukkitRunnable { - private Player player; + private final Player player; public PlayerUpdateInventoryTask(Player player) { this.player = player; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java index a5b59303a..56c772a84 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java @@ -7,8 +7,8 @@ import com.gmail.nossr50.util.player.NotificationManager; import org.bukkit.scheduler.BukkitRunnable; public class AbilityCooldownTask extends BukkitRunnable { - private McMMOPlayer mcMMOPlayer; - private SuperAbilityType ability; + private final McMMOPlayer mcMMOPlayer; + private final SuperAbilityType ability; public AbilityCooldownTask(McMMOPlayer mcMMOPlayer, SuperAbilityType ability) { this.mcMMOPlayer = mcMMOPlayer; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java index 5aea0ea18..53f05f594 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java @@ -17,8 +17,8 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; public class AbilityDisableTask extends BukkitRunnable { - private McMMOPlayer mcMMOPlayer; - private SuperAbilityType ability; + private final McMMOPlayer mcMMOPlayer; + private final SuperAbilityType ability; public AbilityDisableTask(McMMOPlayer mcMMOPlayer, SuperAbilityType ability) { this.mcMMOPlayer = mcMMOPlayer; @@ -41,7 +41,7 @@ public class AbilityDisableTask extends BukkitRunnable { case BERSERK: if (Config.getInstance().getRefreshChunksEnabled()) { - resendChunkRadiusAt(player, 1); + resendChunkRadiusAt(player); } // Fallthrough @@ -66,13 +66,15 @@ public class AbilityDisableTask extends BukkitRunnable { new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR); } - private void resendChunkRadiusAt(Player player, int radius) { + private void resendChunkRadiusAt(Player player) { Chunk chunk = player.getLocation().getChunk(); World world = player.getWorld(); int chunkX = chunk.getX(); int chunkZ = chunk.getZ(); + int radius = 1; + for (int x = chunkX - radius; x <= chunkX + radius; x++) { for (int z = chunkZ - radius; z <= chunkZ + radius; z++) { world.refreshChunk(x, z); diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java index 904aebc35..e81804ac8 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java @@ -11,9 +11,9 @@ import org.bukkit.scheduler.BukkitRunnable; import java.util.Arrays; public class AlchemyBrewCheckTask extends BukkitRunnable { - private Player player; - private BrewingStand brewingStand; - private ItemStack[] oldInventory; + private final Player player; + private final BrewingStand brewingStand; + private final ItemStack[] oldInventory; public AlchemyBrewCheckTask(Player player, BrewingStand brewingStand) { this.player = player; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java index 8bd1d8c7e..7a615bd96 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java @@ -18,14 +18,14 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; public class AlchemyBrewTask extends BukkitRunnable { - private static double DEFAULT_BREW_SPEED = 1.0; - private static int DEFAULT_BREW_TICKS = 400; + private static final double DEFAULT_BREW_SPEED = 1.0; + private static final int DEFAULT_BREW_TICKS = 400; - private BlockState brewingStand; - private Location location; + private final BlockState brewingStand; + private final Location location; private double brewSpeed; private double brewTimer; - private Player player; + private final Player player; private int fuel; private boolean firstRun = true; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java index d7aee1718..735ed8c17 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AwardCombatXpTask.java @@ -8,12 +8,12 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.scheduler.BukkitRunnable; public class AwardCombatXpTask extends BukkitRunnable { - private McMMOPlayer mcMMOPlayer; - private double baseXp; - private PrimarySkillType primarySkillType; - private LivingEntity target; - private XPGainReason xpGainReason; - private double baseHealth; + private final McMMOPlayer mcMMOPlayer; + private final double baseXp; + private final PrimarySkillType primarySkillType; + private final LivingEntity target; + private final XPGainReason xpGainReason; + private final double baseHealth; public AwardCombatXpTask(McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, double baseXp, LivingEntity target, XPGainReason xpGainReason) { this.mcMMOPlayer = mcMMOPlayer; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index e8b283bff..e471ba1e3 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.Map.Entry; public class BleedTimerTask extends BukkitRunnable { - private static Map bleedList = new HashMap(); + private static final Map bleedList = new HashMap(); private static boolean isIterating = false; @Override @@ -155,8 +155,7 @@ public class BleedTimerTask extends BukkitRunnable { int bleedRank = container.bleedRank; int toolTier = container.toolTier; - BleedContainer newContainer = new BleedContainer(target, bleedTicks, bleedRank, toolTier, source); - return newContainer; + return new BleedContainer(target, bleedTicks, bleedRank, toolTier, source); } /** diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java index 38f5eb84d..102c9b0b7 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/HerbalismBlockUpdaterTask.java @@ -4,7 +4,7 @@ import org.bukkit.block.BlockState; import org.bukkit.scheduler.BukkitRunnable; public class HerbalismBlockUpdaterTask extends BukkitRunnable { - private BlockState blockState; + private final BlockState blockState; public HerbalismBlockUpdaterTask(BlockState blockState) { this.blockState = blockState; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java index 2e23e42eb..342f77162 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java @@ -7,9 +7,9 @@ import org.bukkit.scheduler.BukkitRunnable; public class SkillUnlockNotificationTask extends BukkitRunnable { - private McMMOPlayer mcMMOPlayer; - private SubSkillType subSkillType; - private int rank; + private final McMMOPlayer mcMMOPlayer; + private final SubSkillType subSkillType; + private final int rank; /** * Notify a player about a newly unlocked subskill * @param mcMMOPlayer target player diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java index bff688e4f..5f8881ff0 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java @@ -8,8 +8,8 @@ import com.gmail.nossr50.util.player.NotificationManager; import org.bukkit.scheduler.BukkitRunnable; public class ToolLowerTask extends BukkitRunnable { - private McMMOPlayer mcMMOPlayer; - private ToolType tool; + private final McMMOPlayer mcMMOPlayer; + private final ToolType tool; public ToolLowerTask(McMMOPlayer mcMMOPlayer, ToolType tool) { this.mcMMOPlayer = mcMMOPlayer; diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index c241cd946..8c5076cbf 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -32,9 +32,9 @@ public class AcrobaticsManager extends SkillManager { } private long rollXPCooldown = 0; - private long rollXPInterval = (1000 * 3); //1 Minute + private final long rollXPInterval = (1000 * 3); //1 Minute private long rollXPIntervalLengthen = (1000 * 10); //10 Seconds - private LimitedSizeList fallLocationMap; + private final LimitedSizeList fallLocationMap; public boolean hasFallenInLocationBefore(Location location) { diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java b/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java index 478957de6..025f54563 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java @@ -64,9 +64,7 @@ public final class Alchemy { public static void finishAllBrews() { mcMMO.p.debug("Completing " + brewingStandMap.size() + " unfinished Alchemy brews."); - List toFinish = new ArrayList(); - - toFinish.addAll(brewingStandMap.values()); + List toFinish = new ArrayList(brewingStandMap.values()); for (AlchemyBrewTask alchemyBrewTask : toFinish) { alchemyBrewTask.finishImmediately(); diff --git a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java index 9d3634e46..d40c1c9fd 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java @@ -15,7 +15,7 @@ import java.util.Iterator; import java.util.List; public class Archery { - private static List trackedEntities = new ArrayList(); + private static final List trackedEntities = new ArrayList(); public static double skillShotMaxBonusDamage = AdvancedConfig.getInstance().getSkillShotDamageMax(); diff --git a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java index 851a007df..8cc97cc29 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/TrackedEntity.java @@ -7,8 +7,8 @@ import org.bukkit.scheduler.BukkitRunnable; import java.util.UUID; public class TrackedEntity extends BukkitRunnable { - private LivingEntity livingEntity; - private UUID id; + private final LivingEntity livingEntity; + private final UUID id; private int arrowCount; protected TrackedEntity(LivingEntity livingEntity) { diff --git a/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java b/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java index 72ecbe530..5e4437358 100644 --- a/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java +++ b/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java @@ -8,7 +8,7 @@ import java.util.HashMap; import java.util.Set; public class FamilyTree { - private static HashMap> tree = new HashMap>(); + private static final HashMap> tree = new HashMap>(); public static Set getParents(PrimarySkillType childSkill) { enforceChildSkill(childSkill); diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java index 24384872e..b59333f9d 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/Repairable.java @@ -12,35 +12,35 @@ public interface Repairable { * * @return the type of this repairable */ - public Material getItemMaterial(); + Material getItemMaterial(); /** * Gets the id of the material used to repair this item * * @return the id of the repair material */ - public Material getRepairMaterial(); + Material getRepairMaterial(); /** * Gets the pretty name of the material used to repair this item * * @return the pretty name of the repair material */ - public String getRepairMaterialPrettyName(); + String getRepairMaterialPrettyName(); /** * Gets the RepairItemType value for this repairable item * * @return the RepairItemType for this repairable */ - public ItemType getRepairItemType(); + ItemType getRepairItemType(); /** * Gets the RepairMaterialType value for this repairable item * * @return the RepairMaterialType for this repairable */ - public MaterialType getRepairMaterialType(); + MaterialType getRepairMaterialType(); /** * Gets the minimum quantity of repair materials ignoring all other repair bonuses @@ -49,14 +49,14 @@ public interface Repairable { * * @return the minimum number of items */ - public int getMinimumQuantity(); + int getMinimumQuantity(); /** * Gets the maximum durability of this item before it breaks * * @return the maximum durability */ - public short getMaximumDurability(); + short getMaximumDurability(); /** * Gets the base repair durability on which to calculate bonuses. @@ -65,19 +65,19 @@ public interface Repairable { * * @return the base repair durability */ - public short getBaseRepairDurability(ItemStack itemStack); + short getBaseRepairDurability(ItemStack itemStack); /** * Gets the minimum repair level needed to repair this item * * @return the minimum level to repair this item, or 0 for no minimum */ - public int getMinimumLevel(); + int getMinimumLevel(); /** * Gets the xpMultiplier for this repairable * * @return the xpMultiplier of this repairable */ - public double getXpMultiplier(); + double getXpMultiplier(); } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java index fff27e718..fbfe46019 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/RepairableManager.java @@ -11,14 +11,14 @@ public interface RepairableManager { * * @param repairable Repairable to register */ - public void registerRepairable(Repairable repairable); + void registerRepairable(Repairable repairable); /** * Register a list of repairables with the RepairManager * * @param repairables List to register */ - public void registerRepairables(List repairables); + void registerRepairables(List repairables); /** * Checks if an item is repairable @@ -27,7 +27,7 @@ public interface RepairableManager { * * @return true if repairable, false if not */ - public boolean isRepairable(Material type); + boolean isRepairable(Material type); /** * Checks if an item is repairable @@ -36,7 +36,7 @@ public interface RepairableManager { * * @return true if repairable, false if not */ - public boolean isRepairable(ItemStack itemStack); + boolean isRepairable(ItemStack itemStack); /** * Gets the repairable with this type @@ -45,5 +45,5 @@ public interface RepairableManager { * * @return the repairable, can be null */ - public Repairable getRepairable(Material type); + Repairable getRepairable(Material type); } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java index aecfac359..de201456d 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairable.java @@ -11,7 +11,7 @@ public class SimpleRepairable implements Repairable { private final Material itemMaterial, repairMaterial; private final int minimumLevel; private final short maximumDurability; - private String repairMaterialPrettyName; + private final String repairMaterialPrettyName; private final ItemType repairItemType; private final MaterialType repairMaterialType; private final double xpMultiplier; diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairableManager.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairableManager.java index 8fe95d830..05edc0d67 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairableManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairableManager.java @@ -7,7 +7,7 @@ import java.util.HashMap; import java.util.List; public class SimpleRepairableManager implements RepairableManager { - private HashMap repairables; + private final HashMap repairables; public SimpleRepairableManager() { this(55); diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/Salvageable.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/Salvageable.java index 07831d5ea..1d9ac26a9 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/Salvageable.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/Salvageable.java @@ -10,28 +10,28 @@ public interface Salvageable { * * @return the type of this salvageable */ - public Material getItemMaterial(); + Material getItemMaterial(); /** * Gets the material of the items dropped when salvaging this item * * @return the material of the salvage drop */ - public Material getSalvageMaterial(); + Material getSalvageMaterial(); /** * Gets the ItemType value for this salvageable item * * @return the ItemType for this salvageable */ - public ItemType getSalvageItemType(); + ItemType getSalvageItemType(); /** * Gets the MaterialType value for this salvageable item * * @return the MaterialType for this salvageable */ - public MaterialType getSalvageMaterialType(); + MaterialType getSalvageMaterialType(); /** * Gets the maximum quantity of salvage materials ignoring all other salvage bonuses @@ -40,14 +40,14 @@ public interface Salvageable { * * @return the maximum number of items */ - public int getMaximumQuantity(); + int getMaximumQuantity(); /** * Gets the maximum durability of this item before it breaks * * @return the maximum durability */ - public short getMaximumDurability(); + short getMaximumDurability(); /** * Gets the base salvage durability on which to calculate bonuses. @@ -56,19 +56,19 @@ public interface Salvageable { * * @return the base salvage durability */ - public short getBaseSalvageDurability(); + short getBaseSalvageDurability(); /** * Gets the minimum salvage level needed to salvage this item * * @return the minimum level to salvage this item, or 0 for no minimum */ - public int getMinimumLevel(); + int getMinimumLevel(); /** * Gets the xpMultiplier for this salvageable * * @return the xpMultiplier of this salvageable */ - public double getXpMultiplier(); + double getXpMultiplier(); } diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java index fb9f4b84e..24add9b40 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SalvageableManager.java @@ -11,14 +11,14 @@ public interface SalvageableManager { * * @param salvageable Salvageable to register */ - public void registerSalvageable(Salvageable salvageable); + void registerSalvageable(Salvageable salvageable); /** * Register a list of salvageables with the SalvageManager * * @param salvageables List to register */ - public void registerSalvageables(List salvageables); + void registerSalvageables(List salvageables); /** * Checks if an item is salvageable @@ -27,7 +27,7 @@ public interface SalvageableManager { * * @return true if salvageable, false if not */ - public boolean isSalvageable(Material type); + boolean isSalvageable(Material type); /** * Checks if an item is salvageable @@ -36,7 +36,7 @@ public interface SalvageableManager { * * @return true if salvageable, false if not */ - public boolean isSalvageable(ItemStack itemStack); + boolean isSalvageable(ItemStack itemStack); /** * Gets the salvageable with this type @@ -45,5 +45,5 @@ public interface SalvageableManager { * * @return the salvageable, can be null */ - public Salvageable getSalvageable(Material type); + Salvageable getSalvageable(Material type); } diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageableManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageableManager.java index 872364e64..6a9a41f9c 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageableManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageableManager.java @@ -8,7 +8,7 @@ import java.util.List; public class SimpleSalvageableManager implements SalvageableManager { - private HashMap salvageables; + private final HashMap salvageables; public SimpleSalvageableManager() { this(55); diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java index 0a8e99637..aabcd44da 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java @@ -13,9 +13,9 @@ import org.bukkit.scheduler.BukkitRunnable; import java.util.UUID; public class TrackedTamingEntity extends BukkitRunnable { - private LivingEntity livingEntity; + private final LivingEntity livingEntity; private final CallOfTheWildType callOfTheWildType; - private UUID id; + private final UUID id; private int length; private final TamingManager tamingManagerRef; diff --git a/src/main/java/com/gmail/nossr50/util/HolidayManager.java b/src/main/java/com/gmail/nossr50/util/HolidayManager.java index 7ae7fb2fc..903db4e16 100644 --- a/src/main/java/com/gmail/nossr50/util/HolidayManager.java +++ b/src/main/java/com/gmail/nossr50/util/HolidayManager.java @@ -25,8 +25,8 @@ import java.util.*; import java.util.regex.Pattern; public final class HolidayManager { - private ArrayList hasCelebrated; - private int currentYear; + private final ArrayList hasCelebrated; + private final int currentYear; private static final int START_YEAR = 2011; private static final List ALL_COLORS; diff --git a/src/main/java/com/gmail/nossr50/util/LogFilter.java b/src/main/java/com/gmail/nossr50/util/LogFilter.java index fde20cd1e..355c070e7 100644 --- a/src/main/java/com/gmail/nossr50/util/LogFilter.java +++ b/src/main/java/com/gmail/nossr50/util/LogFilter.java @@ -6,7 +6,7 @@ import java.util.logging.Filter; import java.util.logging.LogRecord; public class LogFilter implements Filter { - private boolean debug; + private final boolean debug; public LogFilter(mcMMO plugin) { // Doing a config loading lite here, because we can't depend on the config loader to have loaded before any debug messages are sent diff --git a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java index 15f52fcbc..3ca4370f9 100644 --- a/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java +++ b/src/main/java/com/gmail/nossr50/util/MaterialMapStore.java @@ -15,46 +15,46 @@ import java.util.Locale; */ public class MaterialMapStore { - private HashSet abilityBlackList; - private HashSet toolBlackList; - private HashSet mossyWhiteList; - private HashSet leavesWhiteList; - private HashSet herbalismAbilityBlackList; - private HashSet blockCrackerWhiteList; - private HashSet canMakeShroomyWhiteList; - private HashSet multiBlockPlant; - private HashSet foodItemWhiteList; - private HashSet glassBlocks; + private final HashSet abilityBlackList; + private final HashSet toolBlackList; + private final HashSet mossyWhiteList; + private final HashSet leavesWhiteList; + private final HashSet herbalismAbilityBlackList; + private final HashSet blockCrackerWhiteList; + private final HashSet canMakeShroomyWhiteList; + private final HashSet multiBlockPlant; + private final HashSet foodItemWhiteList; + private final HashSet glassBlocks; - private HashSet netheriteArmor; - private HashSet netheriteTools; - private HashSet woodTools; - private HashSet stoneTools; - private HashSet leatherArmor; - private HashSet ironArmor; - private HashSet ironTools; - private HashSet stringTools; - private HashSet goldArmor; - private HashSet goldTools; - private HashSet chainmailArmor; - private HashSet diamondArmor; - private HashSet diamondTools; - private HashSet armors; + private final HashSet netheriteArmor; + private final HashSet netheriteTools; + private final HashSet woodTools; + private final HashSet stoneTools; + private final HashSet leatherArmor; + private final HashSet ironArmor; + private final HashSet ironTools; + private final HashSet stringTools; + private final HashSet goldArmor; + private final HashSet goldTools; + private final HashSet chainmailArmor; + private final HashSet diamondArmor; + private final HashSet diamondTools; + private final HashSet armors; - private HashSet swords; - private HashSet axes; - private HashSet hoes; - private HashSet shovels; - private HashSet pickAxes; - private HashSet tridents; - private HashSet bows; - private HashSet tools; + private final HashSet swords; + private final HashSet axes; + private final HashSet hoes; + private final HashSet shovels; + private final HashSet pickAxes; + private final HashSet tridents; + private final HashSet bows; + private final HashSet tools; - private HashSet enchantables; + private final HashSet enchantables; - private HashSet ores; + private final HashSet ores; - private HashMap tierValue; + private final HashMap tierValue; public MaterialMapStore() diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index cbb60ee46..7346f42f1 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -18,7 +18,7 @@ import java.util.Random; import java.util.Set; public final class Misc { - private static Random random = new Random(); + private static final Random random = new Random(); public static final int TIME_CONVERSION_FACTOR = 1000; public static final int TICK_CONVERSION_FACTOR = 20; @@ -39,7 +39,7 @@ public final class Misc { public static final Set modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO", "ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST", "THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS", "MARICULTURE", "MINESTRAPPOLATION"); - private Misc() {}; + private Misc() {} /** * Determines if an entity is an NPC but not a villager diff --git a/src/main/java/com/gmail/nossr50/util/ModManager.java b/src/main/java/com/gmail/nossr50/util/ModManager.java index 025775801..1cf04b98f 100644 --- a/src/main/java/com/gmail/nossr50/util/ModManager.java +++ b/src/main/java/com/gmail/nossr50/util/ModManager.java @@ -22,36 +22,36 @@ import java.util.HashMap; import java.util.List; public class ModManager { - private List repairables = new ArrayList(); + private final List repairables = new ArrayList(); // Armor Mods - private List customBoots = new ArrayList(); - private List customChestplates = new ArrayList(); - private List customHelmets = new ArrayList(); - private List customLeggings = new ArrayList(); + private final List customBoots = new ArrayList(); + private final List customChestplates = new ArrayList(); + private final List customHelmets = new ArrayList(); + private final List customLeggings = new ArrayList(); // Block Mods - private List customExcavationBlocks = new ArrayList(); - private List customHerbalismBlocks = new ArrayList(); - private List customMiningBlocks = new ArrayList(); - private List customOres = new ArrayList(); - private List customLogs = new ArrayList(); - private List customLeaves = new ArrayList(); - private List customAbilityBlocks = new ArrayList(); - private HashMap customBlockMap = new HashMap<>(); + private final List customExcavationBlocks = new ArrayList(); + private final List customHerbalismBlocks = new ArrayList(); + private final List customMiningBlocks = new ArrayList(); + private final List customOres = new ArrayList(); + private final List customLogs = new ArrayList(); + private final List customLeaves = new ArrayList(); + private final List customAbilityBlocks = new ArrayList(); + private final HashMap customBlockMap = new HashMap<>(); // Entity Mods - private HashMap customEntityClassMap = new HashMap(); - private HashMap customEntityTypeMap = new HashMap(); + private final HashMap customEntityClassMap = new HashMap(); + private final HashMap customEntityTypeMap = new HashMap(); // Tool Mods - private List customAxes = new ArrayList(); - private List customBows = new ArrayList(); - private List customHoes = new ArrayList(); - private List customPickaxes = new ArrayList(); - private List customShovels = new ArrayList(); - private List customSwords = new ArrayList(); - private HashMap customToolMap = new HashMap(); + private final List customAxes = new ArrayList(); + private final List customBows = new ArrayList(); + private final List customHoes = new ArrayList(); + private final List customPickaxes = new ArrayList(); + private final List customShovels = new ArrayList(); + private final List customSwords = new ArrayList(); + private final HashMap customToolMap = new HashMap(); public void registerCustomArmor(CustomArmorConfig config) { customBoots.addAll(config.customBoots); diff --git a/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java b/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java index 70791e3b2..f96e305a2 100644 --- a/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java +++ b/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java @@ -44,8 +44,7 @@ public class TextComponentFactory { public static TextComponent getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel) { - TextComponent textComponent = new TextComponent(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name."+StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel)); - return textComponent; + return new TextComponent(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name."+StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel)); } private static TextComponent getNotificationTextComponent(String text) @@ -347,7 +346,6 @@ public class TextComponentFactory { ChatColor ccRank = ChatColor.BLUE; ChatColor ccCurRank = ChatColor.GREEN; ChatColor ccPossessive = ChatColor.WHITE; - ChatColor ccNumRanks = ccCurRank; //ChatColor ccDescriptionHeader = ChatColor.DARK_PURPLE; //ChatColor ccDescription = ChatColor.WHITE; ChatColor ccLocked = ChatColor.DARK_GRAY; @@ -375,7 +373,7 @@ public class TextComponentFactory { nextRank = RankUtils.getRankUnlockLevel(abstractSubSkill, curRank+1); } - addRanked(ccRank, ccCurRank, ccPossessive, ccNumRanks, componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(player, abstractSubSkill), nextRank); + addRanked(ccRank, ccCurRank, ccPossessive, ccCurRank, componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(player, abstractSubSkill), nextRank); componentBuilder.append(LocaleLoader.getString("JSON.DescriptionHeader")); componentBuilder.append("\n").append(abstractSubSkill.getDescription()).append("\n"); @@ -456,7 +454,6 @@ public class TextComponentFactory { ChatColor ccRank = ChatColor.BLUE; ChatColor ccCurRank = ChatColor.GREEN; ChatColor ccPossessive = ChatColor.WHITE; - ChatColor ccNumRanks = ccCurRank; ChatColor ccDescriptionHeader = ChatColor.DARK_PURPLE; ChatColor ccDescription = ChatColor.DARK_GRAY; ChatColor ccLocked = ChatColor.DARK_GRAY; @@ -484,7 +481,7 @@ public class TextComponentFactory { nextRank = RankUtils.getRankUnlockLevel(subSkillType, curRank+1); } - addRanked(ccRank, ccCurRank, ccPossessive, ccNumRanks, componentBuilder, subSkillType.getNumRanks(), RankUtils.getRank(player, subSkillType), nextRank); + addRanked(ccRank, ccCurRank, ccPossessive, ccCurRank, componentBuilder, subSkillType.getNumRanks(), RankUtils.getRank(player, subSkillType), nextRank); } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManager.java index e3e3d0b2e..feb54acd3 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletManager.java @@ -12,7 +12,7 @@ public interface ChunkletManager { * @param cz Chunklet Z coordinate that needs to be loaded * @param world World that the chunklet needs to be loaded in */ - public void loadChunklet(int cx, int cy, int cz, World world); + void loadChunklet(int cx, int cy, int cz, World world); /** * Unload a specific chunklet @@ -22,7 +22,7 @@ public interface ChunkletManager { * @param cz Chunklet Z coordinate that needs to be unloaded * @param world World that the chunklet needs to be unloaded from */ - public void unloadChunklet(int cx, int cy, int cz, World world); + void unloadChunklet(int cx, int cy, int cz, World world); /** * Load a given Chunk's Chunklet data @@ -31,7 +31,7 @@ public interface ChunkletManager { * @param cz Chunk Z coordinate that is to be loaded * @param world World that the Chunk is in */ - public void loadChunk(int cx, int cz, World world); + void loadChunk(int cx, int cz, World world); /** * Unload a given Chunk's Chunklet data @@ -40,7 +40,7 @@ public interface ChunkletManager { * @param cz Chunk Z coordinate that is to be unloaded * @param world World that the Chunk is in */ - public void unloadChunk(int cx, int cz, World world); + void unloadChunk(int cx, int cz, World world); /** * Informs the ChunkletManager a chunk is loaded @@ -49,7 +49,7 @@ public interface ChunkletManager { * @param cz Chunk Z coordinate that is loaded * @param world World that the chunk was loaded in */ - public void chunkLoaded(int cx, int cz, World world); + void chunkLoaded(int cx, int cz, World world); /** * Informs the ChunkletManager a chunk is unloaded @@ -58,38 +58,38 @@ public interface ChunkletManager { * @param cz Chunk Z coordinate that is unloaded * @param world World that the chunk was unloaded in */ - public void chunkUnloaded(int cx, int cz, World world); + void chunkUnloaded(int cx, int cz, World world); /** * Save all ChunkletStores related to the given world * * @param world World to save */ - public void saveWorld(World world); + void saveWorld(World world); /** * Unload all ChunkletStores from memory related to the given world after saving them * * @param world World to unload */ - public void unloadWorld(World world); + void unloadWorld(World world); /** * Load all ChunkletStores from all loaded chunks from this world into memory * * @param world World to load */ - public void loadWorld(World world); + void loadWorld(World world); /** * Save all ChunkletStores */ - public void saveAll(); + void saveAll(); /** * Unload all ChunkletStores after saving them */ - public void unloadAll(); + void unloadAll(); /** * Check to see if a given location is set to true @@ -100,7 +100,7 @@ public interface ChunkletManager { * @param world World to check in * @return true if the given location is set to true, false if otherwise */ - public boolean isTrue(int x, int y, int z, World world); + boolean isTrue(int x, int y, int z, World world); /** * Check to see if a given block location is set to true @@ -108,7 +108,7 @@ public interface ChunkletManager { * @param block Block location to check * @return true if the given block location is set to true, false if otherwise */ - public boolean isTrue(Block block); + boolean isTrue(Block block); /** * Set a given location to true, should create stores as necessary if the location does not exist @@ -118,14 +118,14 @@ public interface ChunkletManager { * @param z Z coordinate to set * @param world World to set in */ - public void setTrue(int x, int y, int z, World world); + void setTrue(int x, int y, int z, World world); /** * Set a given block location to true, should create stores as necessary if the location does not exist * * @param block Block location to set */ - public void setTrue(Block block); + void setTrue(Block block); /** * Set a given location to false, should not create stores if one does not exist for the given location @@ -135,17 +135,17 @@ public interface ChunkletManager { * @param z Z coordinate to set * @param world World to set in */ - public void setFalse(int x, int y, int z, World world); + void setFalse(int x, int y, int z, World world); /** * Set a given block location to false, should not create stores if one does not exist for the given location * * @param block Block location to set */ - public void setFalse(Block block); + void setFalse(Block block); /** * Delete any ChunkletStores that are empty */ - public void cleanUp(); + void cleanUp(); } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletStore.java index 5514df13c..9b1537782 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/ChunkletStore.java @@ -14,7 +14,7 @@ public interface ChunkletStore extends Serializable { * @param z z coordinate in current chunklet * @return true if the value is true at the given coordinates, false if otherwise */ - public boolean isTrue(int x, int y, int z); + boolean isTrue(int x, int y, int z); /** * Set the value to true at the given coordinates @@ -23,7 +23,7 @@ public interface ChunkletStore extends Serializable { * @param y y coordinate in current chunklet * @param z z coordinate in current chunklet */ - public void setTrue(int x, int y, int z); + void setTrue(int x, int y, int z); /** * Set the value to false at the given coordinates @@ -32,17 +32,17 @@ public interface ChunkletStore extends Serializable { * @param y y coordinate in current chunklet * @param z z coordinate in current chunklet */ - public void setFalse(int x, int y, int z); + void setFalse(int x, int y, int z); /** * @return true if all values in the chunklet are false, false if otherwise */ - public boolean isEmpty(); + boolean isEmpty(); /** * Set all values in this ChunkletStore to the values from another provided ChunkletStore * * @param otherStore Another ChunkletStore that this one should copy all data from */ - public void copyFrom(ChunkletStore otherStore); + void copyFrom(ChunkletStore otherStore); } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java index 3cf9b1faa..d64824a0e 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkManager.java @@ -8,13 +8,13 @@ import org.bukkit.entity.Entity; import java.io.IOException; public interface ChunkManager { - public void closeAll(); + void closeAll(); - public ChunkStore readChunkStore(World world, int x, int z) throws IOException; + ChunkStore readChunkStore(World world, int x, int z) throws IOException; - public void writeChunkStore(World world, int x, int z, ChunkStore data); + void writeChunkStore(World world, int x, int z, ChunkStore data); - public void closeChunkStore(World world, int x, int z); + void closeChunkStore(World world, int x, int z); /** * Loads a specific chunklet @@ -24,7 +24,7 @@ public interface ChunkManager { * @param cz Chunklet Z coordinate that needs to be loaded * @param world World that the chunklet needs to be loaded in */ - public void loadChunklet(int cx, int cy, int cz, World world); + void loadChunklet(int cx, int cy, int cz, World world); /** * Unload a specific chunklet @@ -34,7 +34,7 @@ public interface ChunkManager { * @param cz Chunklet Z coordinate that needs to be unloaded * @param world World that the chunklet needs to be unloaded from */ - public void unloadChunklet(int cx, int cy, int cz, World world); + void unloadChunklet(int cx, int cy, int cz, World world); /** * Load a given Chunk's Chunklet data @@ -43,7 +43,7 @@ public interface ChunkManager { * @param cz Chunk Z coordinate that is to be loaded * @param world World that the Chunk is in */ - public void loadChunk(int cx, int cz, World world, Entity[] entities); + void loadChunk(int cx, int cz, World world, Entity[] entities); /** * Unload a given Chunk's Chunklet data @@ -52,7 +52,7 @@ public interface ChunkManager { * @param cz Chunk Z coordinate that is to be unloaded * @param world World that the Chunk is in */ - public void unloadChunk(int cx, int cz, World world); + void unloadChunk(int cx, int cz, World world); /** * Saves a given Chunk's Chunklet data @@ -61,9 +61,9 @@ public interface ChunkManager { * @param cz Chunk Z coordinate that is to be saved * @param world World that the Chunk is in */ - public void saveChunk(int cx, int cz, World world); + void saveChunk(int cx, int cz, World world); - public boolean isChunkLoaded(int cx, int cz, World world); + boolean isChunkLoaded(int cx, int cz, World world); /** * Informs the ChunkletManager a chunk is loaded @@ -72,7 +72,7 @@ public interface ChunkManager { * @param cz Chunk Z coordinate that is loaded * @param world World that the chunk was loaded in */ - public void chunkLoaded(int cx, int cz, World world); + void chunkLoaded(int cx, int cz, World world); /** * Informs the ChunkletManager a chunk is unloaded @@ -81,38 +81,38 @@ public interface ChunkManager { * @param cz Chunk Z coordinate that is unloaded * @param world World that the chunk was unloaded in */ - public void chunkUnloaded(int cx, int cz, World world); + void chunkUnloaded(int cx, int cz, World world); /** * Save all ChunkletStores related to the given world * * @param world World to save */ - public void saveWorld(World world); + void saveWorld(World world); /** * Unload all ChunkletStores from memory related to the given world after saving them * * @param world World to unload */ - public void unloadWorld(World world); + void unloadWorld(World world); /** * Load all ChunkletStores from all loaded chunks from this world into memory * * @param world World to load */ - public void loadWorld(World world); + void loadWorld(World world); /** * Save all ChunkletStores */ - public void saveAll(); + void saveAll(); /** * Unload all ChunkletStores after saving them */ - public void unloadAll(); + void unloadAll(); /** * Check to see if a given location is set to true @@ -123,7 +123,7 @@ public interface ChunkManager { * @param world World to check in * @return true if the given location is set to true, false if otherwise */ - public boolean isTrue(int x, int y, int z, World world); + boolean isTrue(int x, int y, int z, World world); /** * Check to see if a given block location is set to true @@ -131,7 +131,7 @@ public interface ChunkManager { * @param block Block location to check * @return true if the given block location is set to true, false if otherwise */ - public boolean isTrue(Block block); + boolean isTrue(Block block); /** * Check to see if a given BlockState location is set to true @@ -139,7 +139,7 @@ public interface ChunkManager { * @param blockState BlockState to check * @return true if the given BlockState location is set to true, false if otherwise */ - public boolean isTrue(BlockState blockState); + boolean isTrue(BlockState blockState); /** * Set a given location to true, should create stores as necessary if the location does not exist @@ -149,21 +149,21 @@ public interface ChunkManager { * @param z Z coordinate to set * @param world World to set in */ - public void setTrue(int x, int y, int z, World world); + void setTrue(int x, int y, int z, World world); /** * Set a given block location to true, should create stores as necessary if the location does not exist * * @param block Block location to set */ - public void setTrue(Block block); + void setTrue(Block block); /** * Set a given BlockState location to true, should create stores as necessary if the location does not exist * * @param blockState BlockState location to set */ - public void setTrue(BlockState blockState); + void setTrue(BlockState blockState); /** * Set a given location to false, should not create stores if one does not exist for the given location @@ -173,24 +173,24 @@ public interface ChunkManager { * @param z Z coordinate to set * @param world World to set in */ - public void setFalse(int x, int y, int z, World world); + void setFalse(int x, int y, int z, World world); /** * Set a given block location to false, should not create stores if one does not exist for the given location * * @param block Block location to set */ - public void setFalse(Block block); + void setFalse(Block block); /** * Set a given BlockState location to false, should not create stores if one does not exist for the given location * * @param blockState BlockState location to set */ - public void setFalse(BlockState blockState); + void setFalse(BlockState blockState); /** * Delete any ChunkletStores that are empty */ - public void cleanUp(); + void cleanUp(); } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStore.java index d4f585f9a..69b2acae1 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/ChunkStore.java @@ -13,28 +13,28 @@ public interface ChunkStore extends Serializable { * * @return true if the has been modified since it was last saved */ - public boolean isDirty(); + boolean isDirty(); /** * Checks the chunk's save state * * @param dirty the save state of the current chunk */ - public void setDirty(boolean dirty); + void setDirty(boolean dirty); /** * Checks the chunk's x coordinate * * @return the chunk's x coordinate. */ - public int getChunkX(); + int getChunkX(); /** * Checks the chunk's z coordinate * * @return the chunk's z coordinate. */ - public int getChunkZ(); + int getChunkZ(); /** * Checks the value at the given coordinates @@ -44,7 +44,7 @@ public interface ChunkStore extends Serializable { * @param z z coordinate in current chunklet * @return true if the value is true at the given coordinates, false if otherwise */ - public boolean isTrue(int x, int y, int z); + boolean isTrue(int x, int y, int z); /** * Set the value to true at the given coordinates @@ -53,7 +53,7 @@ public interface ChunkStore extends Serializable { * @param y y coordinate in current chunklet * @param z z coordinate in current chunklet */ - public void setTrue(int x, int y, int z); + void setTrue(int x, int y, int z); /** * Set the value to false at the given coordinates @@ -62,17 +62,17 @@ public interface ChunkStore extends Serializable { * @param y y coordinate in current chunklet * @param z z coordinate in current chunklet */ - public void setFalse(int x, int y, int z); + void setFalse(int x, int y, int z); /** * @return true if all values in the chunklet are false, false if otherwise */ - public boolean isEmpty(); + boolean isEmpty(); /** * Set all values in this ChunkletStore to the values from another provided ChunkletStore * * @param otherStore Another ChunkletStore that this one should copy all data from */ - public void copyFrom(ChunkletStore otherStore); + void copyFrom(ChunkletStore otherStore); } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java index 532f87d66..13e93ebd3 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java @@ -11,10 +11,10 @@ import java.io.*; import java.util.*; public class HashChunkManager implements ChunkManager { - private HashMap> regionFiles = new HashMap>(); + private final HashMap> regionFiles = new HashMap>(); public HashMap store = new HashMap(); public ArrayList converters = new ArrayList(); - private HashMap oldData = new HashMap(); + private final HashMap oldData = new HashMap(); @Override public synchronized void closeAll() { @@ -98,12 +98,7 @@ public class HashChunkManager implements ChunkManager { UUID key = world.getUID(); - HashMap worldRegions = regionFiles.get(key); - - if (worldRegions == null) { - worldRegions = new HashMap(); - regionFiles.put(key, worldRegions); - } + HashMap worldRegions = regionFiles.computeIfAbsent(key, k -> new HashMap()); int rx = x >> 5; int rz = z >> 5; diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java index 6a506d2ef..b3646e5fb 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java @@ -39,7 +39,7 @@ public class McMMOSimpleRegionFile { @SuppressWarnings("unused") private long lastAccessTime = System.currentTimeMillis(); @SuppressWarnings("unused") - private static long TIMEOUT_TIME = 300000; // 5 min + private static final long TIMEOUT_TIME = 300000; // 5 min public McMMOSimpleRegionFile(File f, int rx, int rz) { this(f, rx, rz, 10); diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java index 594431af0..744ca5aae 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java @@ -32,9 +32,9 @@ import java.util.List; import java.util.Locale; public final class CommandRegistrationManager { - private CommandRegistrationManager() {}; + private CommandRegistrationManager() {} - private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission"); + private static final String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission"); private static void registerSkillCommands() { for (PrimarySkillType skill : PrimarySkillType.values()) { diff --git a/src/main/java/com/gmail/nossr50/util/compat/CompatibilityManager.java b/src/main/java/com/gmail/nossr50/util/compat/CompatibilityManager.java index ae0532ccb..67eededab 100644 --- a/src/main/java/com/gmail/nossr50/util/compat/CompatibilityManager.java +++ b/src/main/java/com/gmail/nossr50/util/compat/CompatibilityManager.java @@ -104,23 +104,21 @@ public class CompatibilityManager { } private NMSVersion determineNMSVersion() { - switch(minecraftGameVersion.getMajorVersion().asInt()) { - case 1: - switch(minecraftGameVersion.getMinorVersion().asInt()) { - case 12: - return NMSVersion.NMS_1_12_2; - case 13: - return NMSVersion.NMS_1_13_2; - case 14: - return NMSVersion.NMS_1_14_4; - case 15: - return NMSVersion.NMS_1_15_2; - case 16: - switch(minecraftGameVersion.getPatchVersion().asInt()) { - case 1: - return NMSVersion.NMS_1_16_1; - } - } + if (minecraftGameVersion.getMajorVersion().asInt() == 1) { + switch (minecraftGameVersion.getMinorVersion().asInt()) { + case 12: + return NMSVersion.NMS_1_12_2; + case 13: + return NMSVersion.NMS_1_13_2; + case 14: + return NMSVersion.NMS_1_14_4; + case 15: + return NMSVersion.NMS_1_15_2; + case 16: + if (minecraftGameVersion.getPatchVersion().asInt() == 1) { + return NMSVersion.NMS_1_16_1; + } + } } return NMSVersion.UNSUPPORTED; diff --git a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java index eda9dc52c..3926ff9ad 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java @@ -12,7 +12,7 @@ import java.util.HashMap; import java.util.Map; public class FormulaManager { - private static File formulaFile = new File(mcMMO.getFlatFileDirectory() + "formula.yml"); + private static final File formulaFile = new File(mcMMO.getFlatFileDirectory() + "formula.yml"); // Experience needed to reach a level, cached values to improve conversion speed private Map experienceNeededRetroLinear; diff --git a/src/main/java/com/gmail/nossr50/util/platform/version/SimpleNumericVersion.java b/src/main/java/com/gmail/nossr50/util/platform/version/SimpleNumericVersion.java index b76bbac05..8330e4279 100644 --- a/src/main/java/com/gmail/nossr50/util/platform/version/SimpleNumericVersion.java +++ b/src/main/java/com/gmail/nossr50/util/platform/version/SimpleNumericVersion.java @@ -3,7 +3,7 @@ package com.gmail.nossr50.util.platform.version; import org.jetbrains.annotations.NotNull; public class SimpleNumericVersion extends SimpleVersion implements NumericVersioned { - private int versionNumber; + private final int versionNumber; public SimpleNumericVersion(int versionNumber) { super(String.valueOf(versionNumber)); diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java index 006199554..d07a8ef08 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -130,7 +130,7 @@ public class ScoreboardManager { abilityLabelsSkill = abilityLabelSkillBuilder.build(); } - private static List dirtyPowerLevels = new ArrayList(); + private static final List dirtyPowerLevels = new ArrayList(); public enum SidebarType { NONE, @@ -138,7 +138,7 @@ public class ScoreboardManager { STATS_BOARD, COOLDOWNS_BOARD, RANK_BOARD, - TOP_BOARD; + TOP_BOARD } private static String formatAbility(String abilityName) { diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java index 36c58c17a..5223bbce1 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java @@ -37,7 +37,7 @@ public class ScoreboardWrapper { // Internal usage variables (should exist) private SidebarType sidebarType; private Objective sidebarObjective; - private Objective powerObjective; + private final Objective powerObjective; // Parameter variables (May be null / invalid) private Scoreboard oldBoard = null; diff --git a/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java index 9c9f19cf6..807b6fb5c 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java @@ -14,7 +14,7 @@ import org.bukkit.entity.Player; public final class ParticleEffectUtils { - private ParticleEffectUtils() {}; + private ParticleEffectUtils() {} public static void playGreenThumbEffect(Location location) { World world = location.getWorld(); diff --git a/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java b/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java index eaa93d25f..70063bdea 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/PerksUtils.java @@ -11,7 +11,7 @@ public final class PerksUtils { private static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75; private static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100; - private PerksUtils() {}; + private PerksUtils() {} public static int handleCooldownPerks(Player player, int cooldown) { if (Permissions.halvedCooldowns(player)) { @@ -47,7 +47,6 @@ public final class PerksUtils { public static float handleXpPerks(Player player, float xp, PrimarySkillType skill) { double modifier = 1.0F; - double originalXP = xp; if (Permissions.customXpBoost(player, skill)) { if(UserManager.getPlayer(player) != null && UserManager.getPlayer(player).isDebugMode()) { @@ -79,7 +78,7 @@ public final class PerksUtils { if(UserManager.getPlayer(player) != null && UserManager.getPlayer(player).isDebugMode()) { player.sendMessage(ChatColor.GOLD + "[DEBUG] " + ChatColor.RESET + "XP Perk Multiplier - " + ChatColor.GOLD + modifier); - player.sendMessage(ChatColor.GOLD + "[DEBUG] " + ChatColor.RESET + "Original XP before perk boosts " + ChatColor.RED + originalXP); + player.sendMessage(ChatColor.GOLD + "[DEBUG] " + ChatColor.RESET + "Original XP before perk boosts " + ChatColor.RED + (double) xp); player.sendMessage(ChatColor.GOLD + "[DEBUG] " + ChatColor.RESET + "XP AFTER PERKS " + ChatColor.DARK_RED + modifiedXP); } diff --git a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java index 2806dd91a..2fb58d018 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java @@ -276,8 +276,7 @@ public class RankUtils { if (subSkillRanks == null) subSkillRanks = new HashMap<>(); - if (subSkillRanks.get(s) == null) - subSkillRanks.put(s, new HashMap<>()); + subSkillRanks.computeIfAbsent(s, k -> new HashMap<>()); } /* public static int getSubSkillUnlockRequirement(SubSkillType subSkillType) diff --git a/src/main/java/com/gmail/nossr50/util/uuid/UUIDFetcher.java b/src/main/java/com/gmail/nossr50/util/uuid/UUIDFetcher.java deleted file mode 100644 index 1da4ddd16..000000000 --- a/src/main/java/com/gmail/nossr50/util/uuid/UUIDFetcher.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.gmail.nossr50.util.uuid; - -import com.google.common.collect.ImmutableList; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; - -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.nio.ByteBuffer; -import java.util.*; -import java.util.concurrent.Callable; - -public class UUIDFetcher implements Callable> { - private static final int PROFILES_PER_REQUEST = 10; - private static final long RATE_LIMIT = 100L; - private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft"; - private final List names; - private final boolean rateLimiting; - - public UUIDFetcher(List names, boolean rateLimiting) { - this.names = ImmutableList.copyOf(names); - this.rateLimiting = rateLimiting; - } - - public UUIDFetcher(List names) { - this(names, true); - } - - public Map call() throws Exception { - Map uuidMap = new HashMap(); - int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST); - for (int i = 0; i < requests; i++) { - HttpURLConnection connection = createConnection(); - - List nameSubList = names.subList(i * PROFILES_PER_REQUEST, Math.min((i + 1) * PROFILES_PER_REQUEST, names.size())); - JsonArray array = new JsonArray(); - - for(String name : nameSubList) - { - JsonPrimitive element = new JsonPrimitive(name); - array.add(element); - } - - Gson gson = new Gson(); - String body = array.toString(); - - writeBody(connection, body); - InputStreamReader tempStream = new InputStreamReader(connection.getInputStream()); - JsonObject[] jsonStreamArray = gson.fromJson(tempStream, JsonObject[].class); - tempStream.close(); - - for (JsonObject jsonProfile : jsonStreamArray) { - String id = jsonProfile.get("id").getAsString(); - String name = jsonProfile.get("name").getAsString(); - UUID uuid = UUIDFetcher.getUUID(id); - uuidMap.put(name, uuid); - } - if (rateLimiting && i != requests - 1) { - Thread.sleep(RATE_LIMIT); - } - } - return uuidMap; - } - - private static void writeBody(HttpURLConnection connection, String body) throws Exception { - OutputStream stream = connection.getOutputStream(); - stream.write(body.getBytes()); - stream.flush(); - stream.close(); - } - - private static HttpURLConnection createConnection() throws Exception { - URL url = new URL(PROFILE_URL); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("POST"); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setUseCaches(false); - connection.setDoInput(true); - connection.setDoOutput(true); - return connection; - } - - private static UUID getUUID(String id) { - return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32)); - } - - public static byte[] toBytes(UUID uuid) { - ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]); - byteBuffer.putLong(uuid.getMostSignificantBits()); - byteBuffer.putLong(uuid.getLeastSignificantBits()); - return byteBuffer.array(); - } - - public static UUID fromBytes(byte[] array) { - if (array.length != 16) { - throw new IllegalArgumentException("Illegal byte array length: " + array.length); - } - ByteBuffer byteBuffer = ByteBuffer.wrap(array); - long mostSignificant = byteBuffer.getLong(); - long leastSignificant = byteBuffer.getLong(); - return new UUID(mostSignificant, leastSignificant); - } - - public static UUID getUUIDOf(String name) throws Exception { - return new UUIDFetcher(Arrays.asList(name)).call().get(name); - } -} diff --git a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java index c990d336e..67e797ef0 100644 --- a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java +++ b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java @@ -16,15 +16,15 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class ZipLibrary { - private static String BACKUP_DIRECTORY = mcMMO.getMainDirectory() + "backup" + File.separator; - private static File BACKUP_DIR = new File(BACKUP_DIRECTORY); - private static File FLAT_FILE_DIRECTORY = new File(mcMMO.getFlatFileDirectory()); - private static File MOD_FILE_DIRECTORY = new File(mcMMO.getModDirectory()); - private static File CONFIG_FILE = new File(mcMMO.getMainDirectory() + "config.yml"); - private static File EXPERIENCE_FILE = new File(mcMMO.getMainDirectory() + "experience.yml"); - private static File TREASURE_FILE = new File(mcMMO.getMainDirectory() + "treasures.yml"); - private static File ADVANCED_FILE = new File(mcMMO.getMainDirectory() + "advanced.yml"); - private static File REPAIR_FILE = new File(mcMMO.getMainDirectory() + "repair.vanilla.yml"); + private static final String BACKUP_DIRECTORY = mcMMO.getMainDirectory() + "backup" + File.separator; + private static final File BACKUP_DIR = new File(BACKUP_DIRECTORY); + private static final File FLAT_FILE_DIRECTORY = new File(mcMMO.getFlatFileDirectory()); + private static final File MOD_FILE_DIRECTORY = new File(mcMMO.getModDirectory()); + private static final File CONFIG_FILE = new File(mcMMO.getMainDirectory() + "config.yml"); + private static final File EXPERIENCE_FILE = new File(mcMMO.getMainDirectory() + "experience.yml"); + private static final File TREASURE_FILE = new File(mcMMO.getMainDirectory() + "treasures.yml"); + private static final File ADVANCED_FILE = new File(mcMMO.getMainDirectory() + "advanced.yml"); + private static final File REPAIR_FILE = new File(mcMMO.getMainDirectory() + "repair.vanilla.yml"); public static void mcMMOBackup() throws IOException { if (Config.getInstance().getUseMySQL()) { From fdd951f1f1890d4bcb62fb6d44fd576df63ad8fe Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 13 Jul 2020 12:31:30 -0700 Subject: [PATCH 05/15] Second Smelt makes use of its own section in Bonus Drops in config.yml Co-authored-by: t00thpick1 --- Changelog.txt | 11 +++ .../java/com/gmail/nossr50/api/PartyAPI.java | 2 +- .../java/com/gmail/nossr50/api/SkillAPI.java | 2 +- .../nossr50/chat/ChatManagerFactory.java | 4 +- .../gmail/nossr50/commands/MHDCommand.java | 5 +- .../nossr50/commands/McImportCommand.java | 38 ++++----- .../nossr50/commands/McconvertCommand.java | 15 ++-- .../gmail/nossr50/commands/McmmoCommand.java | 3 +- .../nossr50/commands/McnotifyCommand.java | 5 +- .../nossr50/commands/McscoreboardCommand.java | 7 +- .../gmail/nossr50/commands/ToggleCommand.java | 7 +- .../gmail/nossr50/commands/XprateCommand.java | 9 +- .../admin/McmmoReloadLocaleCommand.java | 3 +- .../commands/admin/PlayerDebugCommand.java | 3 +- .../nossr50/commands/chat/ChatCommand.java | 7 +- .../database/ConvertDatabaseCommand.java | 3 +- .../commands/database/McpurgeCommand.java | 5 +- .../commands/database/McremoveCommand.java | 7 +- .../commands/database/MmoshowdbCommand.java | 5 +- .../experience/ConvertExperienceCommand.java | 3 +- .../experience/ExperienceCommand.java | 9 +- .../experience/SkillresetCommand.java | 9 +- .../hardcore/HardcoreModeCommand.java | 7 +- .../commands/party/PartyAcceptCommand.java | 3 +- .../party/PartyChangeOwnerCommand.java | 3 +- .../party/PartyChangePasswordCommand.java | 3 +- .../nossr50/commands/party/PartyCommand.java | 25 +++--- .../commands/party/PartyCreateCommand.java | 3 +- .../commands/party/PartyDisbandCommand.java | 3 +- .../commands/party/PartyHelpCommand.java | 3 +- .../commands/party/PartyInfoCommand.java | 7 +- .../commands/party/PartyInviteCommand.java | 3 +- .../commands/party/PartyItemShareCommand.java | 3 +- .../commands/party/PartyJoinCommand.java | 3 +- .../commands/party/PartyKickCommand.java | 3 +- .../commands/party/PartyLockCommand.java | 3 +- .../commands/party/PartyQuitCommand.java | 3 +- .../commands/party/PartyRenameCommand.java | 3 +- .../commands/party/PartyXpShareCommand.java | 3 +- .../alliance/PartyAllianceAcceptCommand.java | 3 +- .../party/alliance/PartyAllianceCommand.java | 9 +- .../alliance/PartyAllianceDisbandCommand.java | 3 +- .../alliance/PartyAllianceInviteCommand.java | 3 +- .../party/teleport/PtpAcceptAnyCommand.java | 3 +- .../party/teleport/PtpAcceptCommand.java | 3 +- .../commands/party/teleport/PtpCommand.java | 9 +- .../party/teleport/PtpToggleCommand.java | 3 +- .../commands/player/InspectCommand.java | 7 +- .../commands/player/MccooldownCommand.java | 5 +- .../commands/player/McrankCommand.java | 7 +- .../commands/player/McstatsCommand.java | 5 +- .../nossr50/commands/player/MctopCommand.java | 9 +- .../nossr50/commands/player/XPBarCommand.java | 2 +- .../nossr50/commands/server/Mcmmoupgrade.java | 3 +- .../commands/skills/AcrobaticsCommand.java | 2 +- .../commands/skills/AlchemyCommand.java | 2 +- .../nossr50/commands/skills/AprilCommand.java | 9 +- .../commands/skills/ArcheryCommand.java | 2 +- .../nossr50/commands/skills/AxesCommand.java | 2 +- .../commands/skills/ExcavationCommand.java | 2 +- .../commands/skills/FishingCommand.java | 2 +- .../commands/skills/HerbalismCommand.java | 2 +- .../commands/skills/MiningCommand.java | 2 +- .../commands/skills/MmoInfoCommand.java | 7 +- .../commands/skills/RepairCommand.java | 2 +- .../commands/skills/SalvageCommand.java | 2 +- .../nossr50/commands/skills/SkillCommand.java | 22 +++-- .../commands/skills/SkillGuideCommand.java | 7 +- .../commands/skills/SmeltingCommand.java | 2 +- .../commands/skills/SwordsCommand.java | 2 +- .../commands/skills/TamingCommand.java | 2 +- .../commands/skills/UnarmedCommand.java | 2 +- .../commands/skills/WoodcuttingCommand.java | 2 +- .../gmail/nossr50/config/AdvancedConfig.java | 2 +- .../config/AutoUpdateConfigLoader.java | 18 ++-- .../java/com/gmail/nossr50/config/Config.java | 2 +- .../com/gmail/nossr50/config/RankConfig.java | 2 +- .../config/experience/ExperienceConfig.java | 2 +- .../config/mods/CustomArmorConfig.java | 10 +-- .../config/mods/CustomEntityConfig.java | 4 +- .../nossr50/config/mods/CustomToolConfig.java | 16 ++-- .../config/party/ItemWeightConfig.java | 2 +- .../config/skills/alchemy/PotionConfig.java | 28 +++---- .../config/skills/repair/RepairConfig.java | 6 +- .../skills/repair/RepairConfigManager.java | 2 +- .../config/skills/salvage/SalvageConfig.java | 6 +- .../skills/salvage/SalvageConfigManager.java | 2 +- .../config/treasure/TreasureConfig.java | 30 +++---- .../database/FlatfileDatabaseManager.java | 84 +++++++++---------- .../nossr50/database/SQLDatabaseManager.java | 25 +++--- .../datatypes/experience/SkillXpGain.java | 3 +- .../gmail/nossr50/datatypes/party/Party.java | 18 ++-- .../nossr50/datatypes/player/McMMOPlayer.java | 16 +--- .../datatypes/player/PlayerProfile.java | 11 ++- .../datatypes/skills/PrimarySkillType.java | 6 +- .../datatypes/skills/SubSkillType.java | 20 ++--- .../skills/subskills/interfaces/Rank.java | 6 +- .../nossr50/events/chat/McMMOChatEvent.java | 3 +- .../McMMOPlayerExperienceEvent.java | 3 +- .../experience/McMMOPlayerLevelDownEvent.java | 3 +- .../experience/McMMOPlayerLevelUpEvent.java | 3 +- .../experience/McMMOPlayerXpGainEvent.java | 3 +- .../fake/FakeEntityDamageByEntityEvent.java | 2 +- .../events/fake/FakeEntityDamageEvent.java | 2 +- .../McMMOPlayerDeathPenaltyEvent.java | 3 +- .../McMMOPlayerPreDeathPenaltyEvent.java | 3 +- .../events/items/McMMOItemSpawnEvent.java | 3 +- .../party/McMMOPartyAllianceChangeEvent.java | 3 +- .../events/party/McMMOPartyChangeEvent.java | 3 +- .../events/party/McMMOPartyLevelUpEvent.java | 3 +- .../events/party/McMMOPartyTeleportEvent.java | 5 +- .../events/party/McMMOPartyXpGainEvent.java | 3 +- .../players/McMMOPlayerProfileLoadEvent.java | 3 +- .../scoreboard/McMMOScoreboardEvent.java | 5 +- .../skills/McMMOPlayerNotificationEvent.java | 3 +- .../events/skills/McMMOPlayerSkillEvent.java | 3 +- .../nossr50/listeners/BlockListener.java | 3 +- .../nossr50/listeners/EntityListener.java | 14 ++-- .../nossr50/listeners/InventoryListener.java | 1 - .../nossr50/listeners/PlayerListener.java | 81 +++++++++--------- .../gmail/nossr50/listeners/SelfListener.java | 1 - src/main/java/com/gmail/nossr50/mcMMO.java | 13 ++- .../com/gmail/nossr50/party/PartyManager.java | 20 ++--- .../nossr50/runnables/CheckDateTask.java | 2 +- .../runnables/backups/CleanBackupsTask.java | 8 +- .../runnables/party/PartyAutoKickTask.java | 4 +- .../player/PlayerProfileLoadingTask.java | 2 +- .../runnables/skills/BleedTimerTask.java | 5 +- .../runnables/skills/DelayedCropReplant.java | 2 +- .../gmail/nossr50/skills/alchemy/Alchemy.java | 4 +- .../skills/alchemy/AlchemyPotionBrewer.java | 26 +++--- .../gmail/nossr50/skills/archery/Archery.java | 2 +- .../com/gmail/nossr50/skills/axes/Axes.java | 5 +- .../nossr50/skills/child/FamilyTree.java | 2 +- .../nossr50/skills/excavation/Excavation.java | 2 +- .../skills/excavation/ExcavationManager.java | 2 +- .../gmail/nossr50/skills/fishing/Fishing.java | 2 +- .../skills/fishing/FishingManager.java | 12 +-- .../skills/herbalism/HerbalismManager.java | 4 +- .../nossr50/skills/mining/BlastMining.java | 2 +- .../nossr50/skills/mining/MiningManager.java | 2 +- .../nossr50/skills/repair/RepairManager.java | 16 ++-- .../repairables/SimpleRepairableManager.java | 2 +- .../SimpleSalvageableManager.java | 2 +- .../skills/smelting/SmeltingManager.java | 14 ++-- .../nossr50/skills/taming/TamingManager.java | 5 +- .../woodcutting/WoodcuttingManager.java | 4 +- .../com/gmail/nossr50/util/BlockUtils.java | 2 +- .../com/gmail/nossr50/util/ChimaeraWing.java | 3 +- .../gmail/nossr50/util/EnchantmentUtils.java | 2 +- .../gmail/nossr50/util/HardcoreManager.java | 8 +- .../gmail/nossr50/util/HolidayManager.java | 10 +-- .../com/gmail/nossr50/util/ItemUtils.java | 11 ++- .../gmail/nossr50/util/MobHealthbarUtils.java | 10 +-- .../com/gmail/nossr50/util/ModManager.java | 42 +++++----- .../nossr50/util/adapter/BiomeAdapter.java | 4 +- .../util/blockmeta/HashChunkletManager.java | 2 +- .../util/blockmeta/NullChunkletManager.java | 16 ---- .../blockmeta/chunkmeta/HashChunkManager.java | 30 ++----- .../chunkmeta/McMMOSimpleRegionFile.java | 2 +- .../conversion/BlockStoreConversionMain.java | 2 - .../BlockStoreConversionXDirectory.java | 1 - .../BlockStoreConversionZDirectory.java | 1 - .../commands/CommandRegistrationManager.java | 2 +- .../nossr50/util/commands/CommandUtils.java | 8 +- ...rAttackCooldownExploitPreventionLayer.java | 1 - .../util/experience/FormulaManager.java | 6 +- .../nossr50/util/player/UserManager.java | 6 +- .../util/scoreboards/ScoreboardManager.java | 4 +- .../util/scoreboards/ScoreboardWrapper.java | 4 +- .../nossr50/util/skills/CombatUtils.java | 6 +- .../util/skills/ParticleEffectUtils.java | 11 --- .../gmail/nossr50/util/skills/SkillUtils.java | 2 +- .../nossr50/worldguard/WorldGuardManager.java | 2 +- .../shatt/backup/ZipLibrary.java | 2 +- src/main/resources/config.yml | 10 +++ 176 files changed, 642 insertions(+), 604 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 57c2f7967..0fcacba94 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,16 @@ Version 2.1.134 + Minor code cleanup + Smelting now has a Bonus Drops section in config.yml + Smelting now only doubles smelting results for items which have bonus drop entries in the config + Fixed a bug where players could set each other on fire when partied or when PVP was disabled Fixed a NPE that could happen with thrown potions + Fixed a potential NPE when damaging player armor with Axes + Fixed a potential NPE when damaging a player with Blast Mining + Fixed a potential NPE when checking tools related to Super Abilities + Fixed a potential NPE when checking the Chimaera Wing + Fixed a potential NPE when creating party member lists + Fixed a potential NPE when fishing + Fixed a potential NPE when players right click blocks Fixed a locale mistake in locale hu_HU Fixed a locale mistake in locale ru Changed the UUID updater task to not catastrophically fail when requests failed diff --git a/src/main/java/com/gmail/nossr50/api/PartyAPI.java b/src/main/java/com/gmail/nossr50/api/PartyAPI.java index eaea5027b..97a2bbe40 100644 --- a/src/main/java/com/gmail/nossr50/api/PartyAPI.java +++ b/src/main/java/com/gmail/nossr50/api/PartyAPI.java @@ -185,7 +185,7 @@ public final class PartyAPI { */ @Deprecated public static List getOnlineAndOfflineMembers(Player player) { - List members = new ArrayList(); + List members = new ArrayList<>(); for (UUID memberUniqueId : PartyManager.getAllMembers(player).keySet()) { OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId); diff --git a/src/main/java/com/gmail/nossr50/api/SkillAPI.java b/src/main/java/com/gmail/nossr50/api/SkillAPI.java index ee230bc72..cdb686af8 100644 --- a/src/main/java/com/gmail/nossr50/api/SkillAPI.java +++ b/src/main/java/com/gmail/nossr50/api/SkillAPI.java @@ -82,7 +82,7 @@ public final class SkillAPI { } private static List getListFromEnum(List skillsTypes) { - List skills = new ArrayList(); + List skills = new ArrayList<>(); for (PrimarySkillType primarySkillType : skillsTypes) { skills.add(primarySkillType.name()); diff --git a/src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java b/src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java index 308e736df..4146d26c7 100644 --- a/src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java +++ b/src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java @@ -6,8 +6,8 @@ import org.bukkit.plugin.Plugin; import java.util.HashMap; public class ChatManagerFactory { - private static final HashMap adminChatManagers = new HashMap(); - private static final HashMap partyChatManagers = new HashMap(); + private static final HashMap adminChatManagers = new HashMap<>(); + private static final HashMap partyChatManagers = new HashMap<>(); public static ChatManager getChatManager(Plugin plugin, ChatMode mode) { switch (mode) { diff --git a/src/main/java/com/gmail/nossr50/commands/MHDCommand.java b/src/main/java/com/gmail/nossr50/commands/MHDCommand.java index 3d8c2d445..a85fe9426 100644 --- a/src/main/java/com/gmail/nossr50/commands/MHDCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/MHDCommand.java @@ -10,13 +10,14 @@ import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; +import org.jetbrains.annotations.NotNull; import java.util.List; public class MHDCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (mcMMO.getDatabaseManager() instanceof SQLDatabaseManager) { SQLDatabaseManager m = (SQLDatabaseManager) mcMMO.getDatabaseManager(); m.resetMobHealthSettings(); @@ -39,7 +40,7 @@ public class MHDCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { return ImmutableList.of(); } } diff --git a/src/main/java/com/gmail/nossr50/commands/McImportCommand.java b/src/main/java/com/gmail/nossr50/commands/McImportCommand.java index e133d1392..ce43f9675 100644 --- a/src/main/java/com/gmail/nossr50/commands/McImportCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McImportCommand.java @@ -7,6 +7,7 @@ import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; import java.io.*; import java.util.ArrayList; @@ -17,7 +18,7 @@ public class McImportCommand implements CommandExecutor { int fileAmount; @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 0) { importModConfig(); return true; @@ -31,7 +32,7 @@ public class McImportCommand implements CommandExecutor { mcMMO.p.getLogger().info("Starting import of mod materials..."); fileAmount = 0; - HashMap> materialNames = new HashMap>(); + HashMap> materialNames = new HashMap<>(); BufferedReader in = null; @@ -63,11 +64,10 @@ public class McImportCommand implements CommandExecutor { ModConfigType type = ModConfigType.getModConfigType(materialName); if (!materialNames.containsKey(type)) { - materialNames.put(type, new ArrayList()); + materialNames.put(type, new ArrayList<>()); } materialNames.get(type).add(materialName); - continue; } } catch (FileNotFoundException e) { @@ -91,13 +91,13 @@ public class McImportCommand implements CommandExecutor { private void createOutput(HashMap> materialNames) { for (ModConfigType modConfigType : materialNames.keySet()) { - HashMap> materialNamesType = new HashMap>(); + HashMap> materialNamesType = new HashMap<>(); for (String materialName : materialNames.get(modConfigType)) { String modName = Misc.getModName(materialName); if (!materialNamesType.containsKey(modName)) { - materialNamesType.put(modName, new ArrayList()); + materialNamesType.put(modName, new ArrayList<>()); } materialNamesType.get(modName).add(materialName); @@ -167,16 +167,10 @@ public class McImportCommand implements CommandExecutor { out = new FileWriter(outputFile); out.write(writer.toString()); - } - catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); return; - } - catch (Exception e) { - e.printStackTrace(); - return; - } - finally { + } finally { tryClose(out); fileAmount++; } @@ -199,7 +193,7 @@ public class McImportCommand implements CommandExecutor { } private HashMap> getConfigSectionsBlocks(String modName, HashMap> materialNames) { - HashMap> configSections = new HashMap>(); + HashMap> configSections = new HashMap<>(); // Go through all the materials and categorise them under a skill for (String materialName : materialNames.get(modName)) { @@ -218,7 +212,7 @@ public class McImportCommand implements CommandExecutor { } if (!configSections.containsKey(skillName)) { - configSections.put(skillName, new ArrayList()); + configSections.put(skillName, new ArrayList<>()); } ArrayList skillContents = configSections.get(skillName); @@ -238,7 +232,7 @@ public class McImportCommand implements CommandExecutor { } private HashMap> getConfigSectionsTools(String modName, HashMap> materialNames) { - HashMap> configSections = new HashMap>(); + HashMap> configSections = new HashMap<>(); // Go through all the materials and categorise them under a tool type for (String materialName : materialNames.get(modName)) { @@ -263,7 +257,7 @@ public class McImportCommand implements CommandExecutor { } if (!configSections.containsKey(toolType)) { - configSections.put(toolType, new ArrayList()); + configSections.put(toolType, new ArrayList<>()); } ArrayList skillContents = configSections.get(toolType); @@ -278,7 +272,7 @@ public class McImportCommand implements CommandExecutor { } private HashMap> getConfigSectionsArmor(String modName, HashMap> materialNames) { - HashMap> configSections = new HashMap>(); + HashMap> configSections = new HashMap<>(); // Go through all the materials and categorise them under an armor type for (String materialName : materialNames.get(modName)) { @@ -297,7 +291,7 @@ public class McImportCommand implements CommandExecutor { } if (!configSections.containsKey(toolType)) { - configSections.put(toolType, new ArrayList()); + configSections.put(toolType, new ArrayList<>()); } ArrayList skillContents = configSections.get(toolType); @@ -323,14 +317,14 @@ public class McImportCommand implements CommandExecutor { } private HashMap> getConfigSectionsUnknown(String modName, HashMap> materialNames) { - HashMap> configSections = new HashMap>(); + HashMap> configSections = new HashMap<>(); // Go through all the materials and print them for (String materialName : materialNames.get(modName)) { String configKey = "UNIDENTIFIED"; if (!configSections.containsKey(configKey)) { - configSections.put(configKey, new ArrayList()); + configSections.put(configKey, new ArrayList<>()); } ArrayList skillContents = configSections.get(configKey); diff --git a/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java b/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java index 8c3c544cc..e00510078 100644 --- a/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java @@ -12,6 +12,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collections; @@ -26,8 +27,8 @@ public class McconvertCommand implements TabExecutor { private final CommandExecutor experienceConvertCommand = new ConvertExperienceCommand(); static { - ArrayList formulaTypes = new ArrayList(); - ArrayList databaseTypes = new ArrayList(); + ArrayList formulaTypes = new ArrayList<>(); + ArrayList databaseTypes = new ArrayList<>(); for (FormulaType type : FormulaType.values()) { formulaTypes.add(type.toString()); @@ -53,7 +54,7 @@ public class McconvertCommand implements TabExecutor { } @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 2) { if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) { return databaseConvertCommand.onCommand(sender, command, label, args); @@ -67,17 +68,17 @@ public class McconvertCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { switch (args.length) { case 1: - return StringUtil.copyPartialMatches(args[0], SUBCOMMANDS, new ArrayList(SUBCOMMANDS.size())); + return StringUtil.copyPartialMatches(args[0], SUBCOMMANDS, new ArrayList<>(SUBCOMMANDS.size())); case 2: if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) { - return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList(DATABASE_TYPES.size())); + return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList<>(DATABASE_TYPES.size())); } if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[0].equalsIgnoreCase("exp")) { - return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList(FORMULA_TYPES.size())); + return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<>(FORMULA_TYPES.size())); } return ImmutableList.of(); diff --git a/src/main/java/com/gmail/nossr50/commands/McmmoCommand.java b/src/main/java/com/gmail/nossr50/commands/McmmoCommand.java index 16280c9d0..23b4c8658 100644 --- a/src/main/java/com/gmail/nossr50/commands/McmmoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McmmoCommand.java @@ -9,10 +9,11 @@ import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; public class McmmoCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { switch (args.length) { case 0: if (!Permissions.mcmmoDescription(sender)) { diff --git a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java index 467797ba7..2ffb16910 100644 --- a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java @@ -9,12 +9,13 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.util.List; public class McnotifyCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { return true; } @@ -34,7 +35,7 @@ public class McnotifyCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { return ImmutableList.of(); } } diff --git a/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java b/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java index d731f2932..1afaa110e 100644 --- a/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java @@ -9,6 +9,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -17,7 +18,7 @@ public class McscoreboardCommand implements TabExecutor { private static final List FIRST_ARGS = ImmutableList.of("keep", "time", "clear"); @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { return true; } @@ -69,9 +70,9 @@ public class McscoreboardCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList(FIRST_ARGS.size())); + return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<>(FIRST_ARGS.size())); } return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java b/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java index 8e74a01ff..fea470d0e 100644 --- a/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java @@ -8,13 +8,14 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; public abstract class ToggleCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { switch (args.length) { case 0: if (CommandUtils.noConsoleUsage(sender)) { @@ -60,10 +61,10 @@ public abstract class ToggleCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); } return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java index 58e9d9993..1d7935549 100644 --- a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java @@ -16,6 +16,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -24,7 +25,7 @@ public class XprateCommand implements TabExecutor { private final double ORIGINAL_XP_RATE = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier(); @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { switch (args.length) { case 1: if (!args[0].equalsIgnoreCase("reset") && !args[0].equalsIgnoreCase("clear")) { @@ -116,16 +117,16 @@ public class XprateCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { switch (args.length) { case 1: if (StringUtils.isInt(args[0])) { return ImmutableList.of(); } - return StringUtil.copyPartialMatches(args[0], CommandUtils.RESET_OPTIONS, new ArrayList(CommandUtils.RESET_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[0], CommandUtils.RESET_OPTIONS, new ArrayList<>(CommandUtils.RESET_OPTIONS.size())); case 2: - return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java index bd78c7853..b5a5e22a8 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java @@ -5,13 +5,14 @@ import com.gmail.nossr50.util.Permissions; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; /** * @author Mark Vainomaa */ public final class McmmoReloadLocaleCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 0) { if (!Permissions.reloadlocale(sender)) { sender.sendMessage(command.getPermissionMessage()); diff --git a/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebugCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebugCommand.java index aa2726311..25a87ceb3 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebugCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebugCommand.java @@ -7,11 +7,12 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PlayerDebugCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if(sender instanceof Player) { McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender); mcMMOPlayer.toggleDebugMode(); //Toggle debug mode diff --git a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java index 0062f6645..559395e8e 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java @@ -16,6 +16,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -30,7 +31,7 @@ public abstract class ChatCommand implements TabExecutor { } @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { McMMOPlayer mcMMOPlayer; switch (args.length) { @@ -88,9 +89,9 @@ public abstract class ChatCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); } return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java b/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java index e1e205b01..327d7da8b 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java @@ -13,10 +13,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class ConvertDatabaseCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 2) { DatabaseType previousType = DatabaseType.getDatabaseType(args[1]); DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType(); diff --git a/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java index 4982f87bf..9bc472875 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java @@ -7,12 +7,13 @@ import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; +import org.jetbrains.annotations.NotNull; import java.util.List; public class McpurgeCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 0) { mcMMO.getDatabaseManager().purgePowerlessUsers(); @@ -27,7 +28,7 @@ public class McpurgeCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { return ImmutableList.of(); } } diff --git a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java index e2e6033fb..731a35524 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java @@ -10,6 +10,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -17,7 +18,7 @@ import java.util.UUID; public class McremoveCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 1) { String playerName = CommandUtils.getMatchedPlayerName(args[0]); @@ -43,10 +44,10 @@ public class McremoveCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); } return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java b/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java index 610f35592..aafae253e 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java @@ -7,12 +7,13 @@ import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; +import org.jetbrains.annotations.NotNull; import java.util.List; public class MmoshowdbCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 0) { Class clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass(); @@ -28,7 +29,7 @@ public class MmoshowdbCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { return ImmutableList.of(); } } diff --git a/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java index 156212d74..e15063ebf 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java @@ -10,12 +10,13 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.util.Locale; public class ConvertExperienceCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 2) { FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType(); FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase(Locale.ENGLISH)); diff --git a/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java index 42b2ec06b..e4886ae0f 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java @@ -14,6 +14,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -21,7 +22,7 @@ import java.util.UUID; public abstract class ExperienceCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { PrimarySkillType skill; switch (args.length) { @@ -119,13 +120,13 @@ public abstract class ExperienceCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { switch (args.length) { case 1: List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); case 2: - return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList(PrimarySkillType.SKILL_NAMES.size())); + return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java index 553ecee49..1132f7235 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java @@ -17,6 +17,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -28,7 +29,7 @@ import java.util.UUID; */ public class SkillresetCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { PrimarySkillType skill; switch (args.length) { case 1: @@ -103,13 +104,13 @@ public class SkillresetCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { switch (args.length) { case 1: List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); case 2: - return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList(PrimarySkillType.SKILL_NAMES.size())); + return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreModeCommand.java b/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreModeCommand.java index fea605da4..73da843a6 100644 --- a/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreModeCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/hardcore/HardcoreModeCommand.java @@ -9,6 +9,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.text.DecimalFormat; import java.util.ArrayList; @@ -18,7 +19,7 @@ public abstract class HardcoreModeCommand implements TabExecutor { protected final DecimalFormat percent = new DecimalFormat("##0.00%"); @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { switch (args.length) { case 0: if (!checkTogglePermissions(sender)) { @@ -108,13 +109,13 @@ public abstract class HardcoreModeCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { if (StringUtils.isDouble(args[0])) { return ImmutableList.of(); } - return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); } return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java index 06ab23d90..09cb1165e 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java @@ -8,10 +8,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyAcceptCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 1) { Player player = (Player) sender; diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java index 435d93035..a918a3ce9 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java @@ -11,10 +11,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyChangeOwnerCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 2) {//Check if player profile is loaded if (UserManager.getPlayer((Player) sender) == null) { sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java index dc641789b..b8d835ef3 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java @@ -7,10 +7,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyChangePasswordCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if(UserManager.getPlayer((Player) sender) == null) { sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java index 73638547c..7a8f99f9d 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -16,6 +16,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Arrays; @@ -28,7 +29,7 @@ public class PartyCommand implements TabExecutor { private static final List ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc"); static { - ArrayList subcommands = new ArrayList(); + ArrayList subcommands = new ArrayList<>(); for (PartySubcommandType subcommand : PartySubcommandType.values()) { subcommands.add(subcommand.toString()); @@ -58,7 +59,7 @@ public class PartyCommand implements TabExecutor { private final CommandExecutor partyAllianceCommand = new PartyAllianceCommand(); @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { return true; } @@ -171,10 +172,10 @@ public class PartyCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { switch (args.length) { case 1: - return StringUtil.copyPartialMatches(args[0], PARTY_SUBCOMMANDS, new ArrayList(PARTY_SUBCOMMANDS.size())); + return StringUtil.copyPartialMatches(args[0], PARTY_SUBCOMMANDS, new ArrayList<>(PARTY_SUBCOMMANDS.size())); case 2: PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]); @@ -188,18 +189,18 @@ public class PartyCommand implements TabExecutor { case KICK: case OWNER: List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size())); case XPSHARE: - return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList(XPSHARE_COMPLETIONS.size())); + return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<>(XPSHARE_COMPLETIONS.size())); case ITEMSHARE: - return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList(ITEMSHARE_COMPLETIONS.size())); + return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList<>(ITEMSHARE_COMPLETIONS.size())); case LOCK: case CHAT: - return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); case PASSWORD: - return StringUtil.copyPartialMatches(args[1], CommandUtils.RESET_OPTIONS, new ArrayList(CommandUtils.RESET_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[1], CommandUtils.RESET_OPTIONS, new ArrayList<>(CommandUtils.RESET_OPTIONS.size())); case TELEPORT: - List matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList(PtpCommand.TELEPORT_SUBCOMMANDS.size())); + List matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<>(PtpCommand.TELEPORT_SUBCOMMANDS.size())); if (matches.size() == 0) { Player player = (Player) sender; @@ -214,7 +215,7 @@ public class PartyCommand implements TabExecutor { Party party = UserManager.getPlayer(player).getParty(); playerNames = party.getOnlinePlayerNames(player); - return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size())); } return matches; @@ -223,7 +224,7 @@ public class PartyCommand implements TabExecutor { } case 3: if (PartySubcommandType.getSubcommand(args[0]) == PartySubcommandType.ITEMSHARE && isItemShareCategory(args[1])) { - return StringUtil.copyPartialMatches(args[2], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[2], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); } return ImmutableList.of(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java index ed5b95b72..34daed151 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java @@ -8,10 +8,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyCreateCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { switch (args.length) { case 2: case 3: diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java index dc46f242c..f4f8f3d2a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java @@ -9,10 +9,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyDisbandCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 1) { if (UserManager.getPlayer((Player) sender) == null) { sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java index 43fefa480..bbf906a06 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java @@ -4,11 +4,12 @@ import com.gmail.nossr50.locale.LocaleLoader; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; public class PartyHelpCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 1) { sender.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit")); sender.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java index 0a8ddda48..ec28ac529 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java @@ -13,13 +13,14 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; public class PartyInfoCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { switch (args.length) { case 0: case 1: @@ -60,8 +61,8 @@ public class PartyInfoCommand implements CommandExecutor { private void displayPartyFeatures(Player player, Party party) { player.sendMessage(LocaleLoader.getString("Commands.Party.Features.Header")); - List unlockedPartyFeatures = new ArrayList(); - List lockedPartyFeatures = new ArrayList(); + List unlockedPartyFeatures = new ArrayList<>(); + List lockedPartyFeatures = new ArrayList<>(); for (PartyFeature partyFeature : PartyFeature.values()) { if (!partyFeature.hasPermission(player)) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java index ffb1adee0..7d6c6a8ca 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java @@ -11,10 +11,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyInviteCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 2) { String targetName = CommandUtils.getMatchedPlayerName(args[1]); McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java index 15f18bf73..54a8af8fa 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java @@ -13,12 +13,13 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.util.Locale; public class PartyItemShareCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if(UserManager.getPlayer((Player) sender) == null) { sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java index b3d7e6afb..8971fc0ed 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java @@ -10,10 +10,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyJoinCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { switch (args.length) { case 2: case 3: diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java index eb5298ad5..fd6b3e495 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java @@ -12,10 +12,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyKickCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 2) { if (UserManager.getPlayer((Player) sender) == null) { sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java index ffaba4771..eb87e0843 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java @@ -9,10 +9,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyLockCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { switch (args.length) { case 1: if (args[0].equalsIgnoreCase("lock")) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java index 9fb080d44..c450a0757 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java @@ -10,10 +10,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyQuitCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 1) { Player player = (Player) sender; diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java index e7f50800b..2ab6f0621 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java @@ -10,10 +10,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyRenameCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 2) { if (UserManager.getPlayer((Player) sender) == null) { sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java index f90c7c21c..c1310cf0e 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java @@ -12,10 +12,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyXpShareCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if(UserManager.getPlayer((Player) sender) == null) { sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java index caa3a509d..1977ad67b 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java @@ -8,10 +8,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyAllianceAcceptCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 2) { if (UserManager.getPlayer((Player) sender) == null) { sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java index 5283137e3..d97edf3d7 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java @@ -16,6 +16,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -32,7 +33,7 @@ public class PartyAllianceCommand implements TabExecutor { private final CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand(); @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { return true; } @@ -108,13 +109,13 @@ public class PartyAllianceCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender commandSender, Command command, String label, String[] args) { + public List onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 1) { - List matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList(ALLIANCE_SUBCOMMANDS.size())); + List matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<>(ALLIANCE_SUBCOMMANDS.size())); if (matches.size() == 0) { List playerNames = CommandUtils.getOnlinePlayerNames(commandSender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); } return matches; diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java index e610c136e..c2cfa666c 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java @@ -9,10 +9,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyAllianceDisbandCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 2) { if (UserManager.getPlayer((Player) sender) == null) { sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java index 06694edd2..408c6136a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java @@ -10,10 +10,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PartyAllianceInviteCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 3) { String targetName = CommandUtils.getMatchedPlayerName(args[2]); McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java index a58044f26..9822860f6 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java @@ -7,10 +7,11 @@ import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; public class PtpAcceptAnyCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (!Permissions.partyTeleportAcceptAll(sender)) { sender.sendMessage(command.getPermissionMessage()); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java index a22200d23..86728e272 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java @@ -11,10 +11,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; public class PtpAcceptCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (!Permissions.partyTeleportAccept(sender)) { sender.sendMessage(command.getPermissionMessage()); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java index 4fec2eeb6..893164435 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java @@ -26,6 +26,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -38,7 +39,7 @@ public class PtpCommand implements TabExecutor { private final CommandExecutor ptpAcceptCommand = new PtpAcceptCommand(); @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { return true; } @@ -129,9 +130,9 @@ public class PtpCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { - List matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList(TELEPORT_SUBCOMMANDS.size())); + List matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<>(TELEPORT_SUBCOMMANDS.size())); if (matches.size() == 0) { if (UserManager.getPlayer((Player) sender) == null) { @@ -147,7 +148,7 @@ public class PtpCommand implements TabExecutor { } List playerNames = mcMMOPlayer.getParty().getOnlinePlayerNames(player); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); } return matches; diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java index 1a669cb5c..aad4df9b9 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java @@ -7,10 +7,11 @@ import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; public class PtpToggleCommand implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (!Permissions.partyTeleportToggle(sender)) { sender.sendMessage(command.getPermissionMessage()); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java index b3fb2ba17..3e54ffa8b 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java @@ -16,13 +16,14 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; public class InspectCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 1) { String playerName = CommandUtils.getMatchedPlayerName(args[0]); McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); @@ -91,10 +92,10 @@ public class InspectCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); } return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java index ab736762b..7cf6d7589 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java @@ -12,12 +12,13 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.util.List; public class MccooldownCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { return true; } @@ -67,7 +68,7 @@ public class MccooldownCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { return ImmutableList.of(); } } diff --git a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java index 20458624f..5a781cdfb 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -15,13 +15,14 @@ import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; public class McrankCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { switch (args.length) { case 0: if (CommandUtils.noConsoleUsage(sender)) { @@ -72,10 +73,10 @@ public class McrankCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { List playerNames = CommandUtils.getOnlinePlayerNames(sender); - return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList(playerNames.size())); + return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); } return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java index 2b623b0e4..87025fac5 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java @@ -10,12 +10,13 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.util.List; public class McstatsCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { return true; } @@ -61,7 +62,7 @@ public class McstatsCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { return ImmutableList.of(); } } diff --git a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java index a17224566..a50b51c20 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -17,13 +17,14 @@ import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; public class MctopCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { PrimarySkillType skill = null; switch (args.length) { @@ -66,9 +67,9 @@ public class MctopCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SKILL_NAMES, new ArrayList(PrimarySkillType.SKILL_NAMES.size())); + return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size())); } return ImmutableList.of(); } @@ -88,7 +89,7 @@ public class MctopCommand implements TabExecutor { long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750); if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) { - double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000; + double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000.0D; if (seconds < 1) { seconds = 1; } diff --git a/src/main/java/com/gmail/nossr50/commands/player/XPBarCommand.java b/src/main/java/com/gmail/nossr50/commands/player/XPBarCommand.java index 99b6a6afb..2c429ddd8 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/XPBarCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/XPBarCommand.java @@ -103,7 +103,7 @@ public class XPBarCommand implements TabExecutor { return StringUtil.copyPartialMatches(args[0], options, new ArrayList<>(ExperienceBarManager.XPBarSettingTarget.values().length)); case 2: if(!args[0].equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.RESET.toString())) - return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList(PrimarySkillType.SKILL_NAMES.size())); + return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/server/Mcmmoupgrade.java b/src/main/java/com/gmail/nossr50/commands/server/Mcmmoupgrade.java index 8fe4ef496..77b181e2a 100644 --- a/src/main/java/com/gmail/nossr50/commands/server/Mcmmoupgrade.java +++ b/src/main/java/com/gmail/nossr50/commands/server/Mcmmoupgrade.java @@ -3,13 +3,14 @@ package com.gmail.nossr50.commands.server; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; /** * This command facilitates switching the skill system scale between classic and modern scale */ public class Mcmmoupgrade implements CommandExecutor { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { return false; } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java index 247615acb..91e86ef0f 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java @@ -44,7 +44,7 @@ public class AcrobaticsCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canDodge) { messages.add(getStatMessage(SubSkillType.ACROBATICS_DODGE, dodgeChance) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java index 3c68c0af9..b8df20ad4 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java @@ -74,7 +74,7 @@ public class AlchemyCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canCatalysis) { messages.add(getStatMessage(SubSkillType.ALCHEMY_CATALYSIS, brewSpeed) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AprilCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AprilCommand.java index 8b29b3413..26c6441e5 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AprilCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AprilCommand.java @@ -10,6 +10,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.text.DecimalFormat; import java.util.ArrayList; @@ -22,7 +23,7 @@ public class AprilCommand implements TabExecutor { protected DecimalFormat decimal = new DecimalFormat("##0.00"); @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { return true; } @@ -98,7 +99,7 @@ public class AprilCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { return ImmutableList.of("?"); } @@ -106,7 +107,7 @@ public class AprilCommand implements TabExecutor { } private List effectsDisplay(FakeSkillType fakeSkillType) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); switch (fakeSkillType) { case MACHO: @@ -152,7 +153,7 @@ public class AprilCommand implements TabExecutor { } private List statsDisplay(FakeSkillType fakeSkillType) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); switch (fakeSkillType) { case MACHO: diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java index 42f4510f4..4deeb9262 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java @@ -59,7 +59,7 @@ public class ArcheryCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canRetrieve) { messages.add(getStatMessage(SubSkillType.ARCHERY_ARROW_RETRIEVAL, retrieveChance) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java index 1ca55780a..8454b4af3 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java @@ -72,7 +72,7 @@ public class AxesCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canImpact) { messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage))); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java index b047b117b..2f3d53a0f 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java @@ -43,7 +43,7 @@ public class ExcavationCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager(); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index c6c1b0e5b..2788b98d4 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -128,7 +128,7 @@ public class FishingCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canFishermansDiet) { messages.add(getStatMessage(false, true, SubSkillType.FISHING_FISHERMANS_DIET, String.valueOf(fishermansDietRank))); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java index 7b8609a75..9884ecba8 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java @@ -99,7 +99,7 @@ public class HerbalismCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canDoubleDrop) { messages.add(getStatMessage(SubSkillType.HERBALISM_DOUBLE_DROPS, doubleDropChance) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java index 7e7c5d5c6..27102d7b4 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java @@ -78,7 +78,7 @@ public class MiningCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canBiggerBombs) { messages.add(getStatMessage(true, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastRadiusIncrease))); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java index c1b5f2e0d..c23c7ac78 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java @@ -13,6 +13,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; import org.bukkit.util.StringUtil; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; @@ -23,7 +24,7 @@ import java.util.List; public class MmoInfoCommand implements TabExecutor { @Override - public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { + public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, String[] args) { /* * Only allow players to use this command */ @@ -61,9 +62,9 @@ public class MmoInfoCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SUBSKILL_NAMES, new ArrayList(PrimarySkillType.SUBSKILL_NAMES.size())); + return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SUBSKILL_NAMES, new ArrayList<>(PrimarySkillType.SUBSKILL_NAMES.size())); } return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index 1e590e644..a88a45bb6 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -91,7 +91,7 @@ public class RepairCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canArcaneForge) { RepairManager repairManager = UserManager.getPlayer(player).getRepairManager(); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java index 6d16655b7..9dc5263fe 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java @@ -36,7 +36,7 @@ public class SalvageCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager(); if (canScrapCollector) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index fe58a35fb..91c683a43 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -26,6 +26,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabExecutor; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.text.DecimalFormat; import java.util.ArrayList; @@ -49,7 +50,7 @@ public abstract class SkillCommand implements TabExecutor { } @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { return true; } @@ -161,31 +162,28 @@ public abstract class SkillCommand implements TabExecutor { Set parents = FamilyTree.getParents(skill); - ArrayList parentList = new ArrayList<>(); //TODO: Add JSON here - for (PrimarySkillType parent : parents) { - parentList.add(parent); - /*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/ - } + /*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/ + ArrayList parentList = new ArrayList<>(parents); - String parentMessage = ""; + StringBuilder parentMessage = new StringBuilder(); for(int i = 0; i < parentList.size(); i++) { if(i+1 < parentList.size()) { - parentMessage += LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i))); - parentMessage += ChatColor.GRAY+", "; + parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); + parentMessage.append(ChatColor.GRAY).append(", "); } else { - parentMessage += LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i))); + parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); } } //XP GAIN METHOD player.sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain.Child"))); - player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, parentMessage)); + player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, parentMessage.toString())); //LEVEL //player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, skillValue)); @@ -211,7 +209,7 @@ public abstract class SkillCommand implements TabExecutor { } @Override - public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { return ImmutableList.of("?"); } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java index 47d2667bb..60fc82184 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java @@ -6,6 +6,7 @@ import com.gmail.nossr50.util.StringUtils; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Arrays; @@ -22,7 +23,7 @@ public class SkillGuideCommand implements CommandExecutor { } @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { switch (args.length) { case 1: if (!args[0].equals("?")) { @@ -67,7 +68,7 @@ public class SkillGuideCommand implements CommandExecutor { private ArrayList grabPageContents(int page) { int pageIndexStart = 8 * (page - 1); // Determine what string to start at - ArrayList allStrings = new ArrayList(); + ArrayList allStrings = new ArrayList<>(); allStrings.add(header); @@ -86,7 +87,7 @@ public class SkillGuideCommand implements CommandExecutor { } private ArrayList getGuide(PrimarySkillType skill) { - ArrayList guide = new ArrayList(); + ArrayList guide = new ArrayList<>(); for (int i = 0; i < 10; i++) { String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skill.toString()) + ".Section." + i).split("\n"); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java index b688691c6..a3a5f5805 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java @@ -62,7 +62,7 @@ public class SmeltingCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); /*if (canFluxMine) { messages.add(getStatMessage(SubSkillType.SMELTING_FLUX_MINING, str_fluxMiningChance) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java index 0bdeaba9c..0933d6c79 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java @@ -68,7 +68,7 @@ public class SwordsCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); int ruptureTicks = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks(); double ruptureDamagePlayers = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamagePlayer() * 1.5D : AdvancedConfig.getInstance().getRuptureDamagePlayer(); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java index fb613544e..e54ce1505 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java @@ -56,7 +56,7 @@ public class TamingCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canEnvironmentallyAware) { messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1"))); diff --git a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java index d427ccb16..383b28318 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java @@ -84,7 +84,7 @@ public class UnarmedCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canDeflect) { messages.add(getStatMessage(SubSkillType.UNARMED_ARROW_DEFLECT, deflectChance) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java index 6fce8dc62..e96c7b07e 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java @@ -63,7 +63,7 @@ public class WoodcuttingCommand extends SkillCommand { @Override protected List statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) { - List messages = new ArrayList(); + List messages = new ArrayList<>(); if (canDoubleDrop) { messages.add(getStatMessage(SubSkillType.WOODCUTTING_HARVEST_LUMBER, doubleDropChance) diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index a90d81fef..16cb6f915 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -28,7 +28,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { @Override protected boolean validateKeys() { // Validate all the settings! - List reason = new ArrayList(); + List reason = new ArrayList<>(); /* GENERAL */ if (getAbilityLength() < 1) { diff --git a/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java b/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java index 439eef220..c43f14f81 100644 --- a/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/AutoUpdateConfigLoader.java @@ -28,10 +28,10 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader { boolean needSave = false; - Set oldKeys = new HashSet(configKeys); + Set oldKeys = new HashSet<>(configKeys); oldKeys.removeAll(internalConfigKeys); - Set newKeys = new HashSet(internalConfigKeys); + Set newKeys = new HashSet<>(internalConfigKeys); newKeys.removeAll(configKeys); // Don't need a re-save if we have old keys sticking around? @@ -66,17 +66,17 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader { try { // Read internal BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName))); - LinkedHashMap comments = new LinkedHashMap(); - String temp = ""; + LinkedHashMap comments = new LinkedHashMap<>(); + StringBuilder temp = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { if (line.contains("#")) { - temp += line + "\n"; + temp.append(line).append("\n"); } else if (line.contains(":")) { line = line.substring(0, line.indexOf(":") + 1); - if (!temp.isEmpty()) { + if (temp.length() > 0) { if(comments.containsKey(line)) { int index = 0; while(comments.containsKey(line + index)) { @@ -86,14 +86,14 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader { line = line + index; } - comments.put(line, temp); - temp = ""; + comments.put(line, temp.toString()); + temp = new StringBuilder(); } } } // Dump to the new one - HashMap indexed = new HashMap(); + HashMap indexed = new HashMap<>(); for (String key : comments.keySet()) { String actualkey = key.substring(0, key.indexOf(":") + 1); diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 1099cc4db..fa8c875dc 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -39,7 +39,7 @@ public class Config extends AutoUpdateConfigLoader { @Override protected boolean validateKeys() { // Validate all the settings! - List reason = new ArrayList(); + List reason = new ArrayList<>(); /* General Settings */ if (getSaveInterval() <= 0) { diff --git a/src/main/java/com/gmail/nossr50/config/RankConfig.java b/src/main/java/com/gmail/nossr50/config/RankConfig.java index 6beb13ec5..fb660e457 100644 --- a/src/main/java/com/gmail/nossr50/config/RankConfig.java +++ b/src/main/java/com/gmail/nossr50/config/RankConfig.java @@ -31,7 +31,7 @@ public class RankConfig extends AutoUpdateConfigLoader { @Override protected boolean validateKeys() { - List reason = new ArrayList(); + List reason = new ArrayList<>(); /* * In the future this method will check keys for all skills, but for now it only checks overhauled skills diff --git a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java index a18a8b870..68dcc8d1a 100644 --- a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java +++ b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java @@ -38,7 +38,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader { @Override protected boolean validateKeys() { - List reason = new ArrayList(); + List reason = new ArrayList<>(); /* * FORMULA SETTINGS diff --git a/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java index a32b497b5..76686f82d 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomArmorConfig.java @@ -15,12 +15,12 @@ import java.util.Set; public class CustomArmorConfig extends ConfigLoader { private boolean needsUpdate = false; - public List customBoots = new ArrayList(); - public List customChestplates = new ArrayList(); - public List customHelmets = new ArrayList(); - public List customLeggings = new ArrayList(); + public List customBoots = new ArrayList<>(); + public List customChestplates = new ArrayList<>(); + public List customHelmets = new ArrayList<>(); + public List customLeggings = new ArrayList<>(); - public List repairables = new ArrayList(); + public List repairables = new ArrayList<>(); protected CustomArmorConfig(String fileName) { super("mods", fileName); diff --git a/src/main/java/com/gmail/nossr50/config/mods/CustomEntityConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomEntityConfig.java index 95ef1e5d1..549836152 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomEntityConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomEntityConfig.java @@ -9,8 +9,8 @@ import org.bukkit.inventory.ItemStack; import java.util.HashMap; public class CustomEntityConfig extends ConfigLoader { - public HashMap customEntityClassMap = new HashMap(); - public HashMap customEntityTypeMap = new HashMap(); + public HashMap customEntityClassMap = new HashMap<>(); + public HashMap customEntityTypeMap = new HashMap<>(); protected CustomEntityConfig(String fileName) { super("mods", fileName); diff --git a/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java index dc47b6081..104fb3726 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomToolConfig.java @@ -17,16 +17,16 @@ import java.util.Set; public class CustomToolConfig extends ConfigLoader { private boolean needsUpdate = false; - public List customAxes = new ArrayList(); - public List customBows = new ArrayList(); - public List customHoes = new ArrayList(); - public List customPickaxes = new ArrayList(); - public List customShovels = new ArrayList(); - public List customSwords = new ArrayList(); + public List customAxes = new ArrayList<>(); + public List customBows = new ArrayList<>(); + public List customHoes = new ArrayList<>(); + public List customPickaxes = new ArrayList<>(); + public List customShovels = new ArrayList<>(); + public List customSwords = new ArrayList<>(); - public HashMap customToolMap = new HashMap(); + public HashMap customToolMap = new HashMap<>(); - public List repairables = new ArrayList(); + public List repairables = new ArrayList<>(); protected CustomToolConfig(String fileName) { super("mods", fileName); diff --git a/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java b/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java index 50af1065b..2af0cb727 100644 --- a/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java +++ b/src/main/java/com/gmail/nossr50/config/party/ItemWeightConfig.java @@ -27,7 +27,7 @@ public class ItemWeightConfig extends ConfigLoader { } public HashSet getMiscItems() { - HashSet miscItems = new HashSet(); + HashSet miscItems = new HashSet<>(); for (String item : config.getStringList("Party_Shareables.Misc_Items")) { Material material = Material.getMaterial(item.toUpperCase(Locale.ENGLISH)); diff --git a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java index bb479c931..bc2ae7417 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java @@ -18,16 +18,16 @@ import java.util.Map; public class PotionConfig extends ConfigLoader { private static PotionConfig instance; - private final List concoctionsIngredientsTierOne = new ArrayList(); - private final List concoctionsIngredientsTierTwo = new ArrayList(); - private final List concoctionsIngredientsTierThree = new ArrayList(); - private final List concoctionsIngredientsTierFour = new ArrayList(); - private final List concoctionsIngredientsTierFive = new ArrayList(); - private final List concoctionsIngredientsTierSix = new ArrayList(); - private final List concoctionsIngredientsTierSeven = new ArrayList(); - private final List concoctionsIngredientsTierEight = new ArrayList(); + private final List concoctionsIngredientsTierOne = new ArrayList<>(); + private final List concoctionsIngredientsTierTwo = new ArrayList<>(); + private final List concoctionsIngredientsTierThree = new ArrayList<>(); + private final List concoctionsIngredientsTierFour = new ArrayList<>(); + private final List concoctionsIngredientsTierFive = new ArrayList<>(); + private final List concoctionsIngredientsTierSix = new ArrayList<>(); + private final List concoctionsIngredientsTierSeven = new ArrayList<>(); + private final List concoctionsIngredientsTierEight = new ArrayList<>(); - private final Map potionMap = new HashMap(); + private final Map potionMap = new HashMap<>(); private PotionConfig() { super("potions.yml"); @@ -137,14 +137,14 @@ public class PotionConfig extends ConfigLoader { material = Material.valueOf(mat); } - List lore = new ArrayList(); + List lore = new ArrayList<>(); if (potion_section.contains("Lore")) { for (String line : potion_section.getStringList("Lore")) { lore.add(ChatColor.translateAlternateColorCodes('&', line)); } } - List effects = new ArrayList(); + List effects = new ArrayList<>(); if (potion_section.contains("Effects")) { for (String effect : potion_section.getStringList("Effects")) { String[] parts = effect.split(" "); @@ -162,7 +162,7 @@ public class PotionConfig extends ConfigLoader { } } - Color color = null; + Color color; if (potion_section.contains("Color")) { color = Color.fromRGB(potion_section.getInt("Color")); } @@ -170,7 +170,7 @@ public class PotionConfig extends ConfigLoader { color = this.generateColor(effects); } - Map children = new HashMap(); + Map children = new HashMap<>(); if (potion_section.contains("Children")) { for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) { ItemStack ingredient = loadIngredient(child); @@ -255,7 +255,7 @@ public class PotionConfig extends ConfigLoader { public Color generateColor(List effects) { if (effects != null && !effects.isEmpty()) { - List colors = new ArrayList(); + List colors = new ArrayList<>(); for (PotionEffect effect : effects) { if (effect.getType().getColor() != null) { colors.add(effect.getType().getColor()); diff --git a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java index 76ea32bbc..c5ff8846c 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfig.java @@ -25,7 +25,7 @@ public class RepairConfig extends ConfigLoader { @Override protected void loadKeys() { - repairables = new ArrayList(); + repairables = new ArrayList<>(); if (!config.isConfigurationSection("Repairables")) { mcMMO.p.getLogger().severe("Could not find Repairables section in " + fileName); @@ -42,7 +42,7 @@ public class RepairConfig extends ConfigLoader { } // Validate all the things! - List reason = new ArrayList(); + List reason = new ArrayList<>(); // Item Material Material itemMaterial = Material.matchMaterial(key); @@ -177,7 +177,7 @@ public class RepairConfig extends ConfigLoader { } protected List getLoadedRepairables() { - return repairables == null ? new ArrayList() : repairables; + return repairables == null ? new ArrayList<>() : repairables; } private boolean noErrorsInRepairable(List issues) { diff --git a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfigManager.java b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfigManager.java index 40dd249ba..da02f5fe2 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/skills/repair/RepairConfigManager.java @@ -11,7 +11,7 @@ import java.util.List; import java.util.regex.Pattern; public class RepairConfigManager { - private final List repairables = new ArrayList(); + private final List repairables = new ArrayList<>(); public RepairConfigManager(mcMMO plugin) { Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml"); diff --git a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java index a858c2890..f01f41940 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfig.java @@ -28,7 +28,7 @@ public class SalvageConfig extends ConfigLoader { @Override protected void loadKeys() { - salvageables = new ArrayList(); + salvageables = new ArrayList<>(); if (!config.isConfigurationSection("Salvageables")) { mcMMO.p.getLogger().severe("Could not find Salvageables section in " + fileName); @@ -59,7 +59,7 @@ public class SalvageConfig extends ConfigLoader { for (String key : keys) { // Validate all the things! - List reason = new ArrayList(); + List reason = new ArrayList<>(); // Item Material Material itemMaterial = Material.matchMaterial(key); @@ -195,7 +195,7 @@ public class SalvageConfig extends ConfigLoader { } protected List getLoadedSalvageables() { - return salvageables == null ? new ArrayList() : salvageables; + return salvageables == null ? new ArrayList<>() : salvageables; } private boolean noErrorsInSalvageable(List issues) { diff --git a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfigManager.java b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfigManager.java index 39ba3b463..21189ec0f 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/skills/salvage/SalvageConfigManager.java @@ -11,7 +11,7 @@ import java.util.List; import java.util.regex.Pattern; public class SalvageConfigManager { - private final List salvageables = new ArrayList(); + private final List salvageables = new ArrayList<>(); public SalvageConfigManager(mcMMO plugin) { Pattern pattern = Pattern.compile("salvage\\.(?:.+)\\.yml"); diff --git a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java index 3d6983b6d..2c0b3f795 100755 --- a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java @@ -24,13 +24,13 @@ public class TreasureConfig extends ConfigLoader { private static TreasureConfig instance; - public HashMap> excavationMap = new HashMap>(); + public HashMap> excavationMap = new HashMap<>(); - public HashMap> shakeMap = new HashMap>(); - public HashMap> hylianMap = new HashMap>(); + public HashMap> shakeMap = new HashMap<>(); + public HashMap> hylianMap = new HashMap<>(); - public HashMap> fishingRewards = new HashMap>(); - public HashMap> fishingEnchantments = new HashMap>(); + public HashMap> fishingRewards = new HashMap<>(); + public HashMap> fishingEnchantments = new HashMap<>(); private TreasureConfig() { super("treasures.yml"); @@ -49,7 +49,7 @@ public class TreasureConfig extends ConfigLoader { @Override protected boolean validateKeys() { // Validate all the settings! - List reason = new ArrayList(); + List reason = new ArrayList<>(); for (String tier : config.getConfigurationSection("Enchantment_Drop_Rates").getKeys(false)) { double totalEnchantDropRate = 0; double totalItemDropRate = 0; @@ -116,13 +116,13 @@ public class TreasureConfig extends ConfigLoader { // Initialize fishing HashMap for (Rarity rarity : Rarity.values()) { if (!fishingRewards.containsKey(rarity)) { - fishingRewards.put(rarity, (new ArrayList())); + fishingRewards.put(rarity, (new ArrayList<>())); } } for (String treasureName : treasureSection.getKeys(false)) { // Validate all the things! - List reason = new ArrayList(); + List reason = new ArrayList<>(); String[] treasureInfo = treasureName.split("[|]"); String materialName = treasureInfo[0]; @@ -135,7 +135,7 @@ public class TreasureConfig extends ConfigLoader { if (materialName.contains("INVENTORY")) { // Use magic material BEDROCK to know that we're grabbing something from the inventory and not a normal treasure if (!shakeMap.containsKey(EntityType.PLAYER)) - shakeMap.put(EntityType.PLAYER, new ArrayList()); + shakeMap.put(EntityType.PLAYER, new ArrayList<>()); shakeMap.get(EntityType.PLAYER).add(new ShakeTreasure(new ItemStack(Material.BEDROCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel())); continue; } else { @@ -218,7 +218,7 @@ public class TreasureConfig extends ConfigLoader { } if (config.contains(type + "." + treasureName + ".Lore")) { - List lore = new ArrayList(); + List lore = new ArrayList<>(); for (String s : config.getStringList(type + "." + treasureName + ".Lore")) { lore.add(ChatColor.translateAlternateColorCodes('&', s)); } @@ -237,7 +237,7 @@ public class TreasureConfig extends ConfigLoader { if (config.contains(type + "." + treasureName + ".Lore")) { ItemMeta itemMeta = item.getItemMeta(); - List lore = new ArrayList(); + List lore = new ArrayList<>(); for (String s : config.getStringList(type + "." + treasureName + ".Lore")) { lore.add(ChatColor.translateAlternateColorCodes('&', s)); } @@ -254,7 +254,7 @@ public class TreasureConfig extends ConfigLoader { EntityType entityType = EntityType.valueOf(type.substring(6)); if (!shakeMap.containsKey(entityType)) - shakeMap.put(entityType, new ArrayList()); + shakeMap.put(entityType, new ArrayList<>()); shakeMap.get(entityType).add(shakeTreasure); } else if (isExcavation) { ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel); @@ -262,7 +262,7 @@ public class TreasureConfig extends ConfigLoader { for (String blockType : dropList) { if (!excavationMap.containsKey(blockType)) - excavationMap.put(blockType, new ArrayList()); + excavationMap.put(blockType, new ArrayList<>()); excavationMap.get(blockType).add(excavationTreasure); } } else if (isHylian) { @@ -305,7 +305,7 @@ public class TreasureConfig extends ConfigLoader { private void AddHylianTreasure(String dropper, HylianTreasure treasure) { if (!hylianMap.containsKey(dropper)) - hylianMap.put(dropper, new ArrayList()); + hylianMap.put(dropper, new ArrayList<>()); hylianMap.get(dropper).add(treasure); } @@ -316,7 +316,7 @@ public class TreasureConfig extends ConfigLoader { } if (!fishingEnchantments.containsKey(rarity)) { - fishingEnchantments.put(rarity, (new ArrayList())); + fishingEnchantments.put(rarity, (new ArrayList<>())); } ConfigurationSection enchantmentSection = config.getConfigurationSection("Enchantments_Rarity." + rarity.toString()); diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index 138e4615c..75c4ff6ca 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java @@ -20,8 +20,8 @@ import java.io.*; import java.util.*; public final class FlatfileDatabaseManager implements DatabaseManager { - private final HashMap> playerStatHash = new HashMap>(); - private final List powerLevels = new ArrayList(); + private final HashMap> playerStatHash = new HashMap<>(); + private final List powerLevels = new ArrayList<>(); private long lastUpdate = 0; private final long UPDATE_WAIT_TIME = 600000L; // 10 minutes @@ -374,7 +374,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { public Map readRank(String playerName) { updateLeaderboards(); - Map skills = new HashMap(); + Map skills = new HashMap<>(); for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) { skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill))); @@ -662,7 +662,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } character[UUID_INDEX] = fetchedUUIDs.remove(character[USERNAME]).toString(); - line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString(); + line = org.apache.commons.lang.StringUtils.join(character, ":") + ":"; } i++; @@ -700,7 +700,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } public List getStoredUsers() { - ArrayList users = new ArrayList(); + ArrayList users = new ArrayList<>(); BufferedReader in = null; String usersFilePath = mcMMO.getUsersFilePath(); @@ -746,19 +746,19 @@ public final class FlatfileDatabaseManager implements DatabaseManager { powerLevels.clear(); // Clear old values from the power levels // Initialize lists - List mining = new ArrayList(); - List woodcutting = new ArrayList(); - List herbalism = new ArrayList(); - List excavation = new ArrayList(); - List acrobatics = new ArrayList(); - List repair = new ArrayList(); - List swords = new ArrayList(); - List axes = new ArrayList(); - List archery = new ArrayList(); - List unarmed = new ArrayList(); - List taming = new ArrayList(); - List fishing = new ArrayList(); - List alchemy = new ArrayList(); + List mining = new ArrayList<>(); + List woodcutting = new ArrayList<>(); + List herbalism = new ArrayList<>(); + List excavation = new ArrayList<>(); + List acrobatics = new ArrayList<>(); + List repair = new ArrayList<>(); + List swords = new ArrayList<>(); + List axes = new ArrayList<>(); + List archery = new ArrayList<>(); + List unarmed = new ArrayList<>(); + List taming = new ArrayList<>(); + List fishing = new ArrayList<>(); + List alchemy = new ArrayList<>(); BufferedReader in = null; String playerName = null; @@ -853,8 +853,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager { in = new BufferedReader(new FileReader(usersFilePath)); StringBuilder writer = new StringBuilder(); String line; - HashSet usernames = new HashSet(); - HashSet players = new HashSet(); + HashSet usernames = new HashSet<>(); + HashSet players = new HashSet<>(); while ((line = in.readLine()) != null) { // Remove empty lines from the file @@ -909,7 +909,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { continue; } int cap = Config.getInstance().getLevelCap(skill); - if (Integer.valueOf(character[index]) > cap) { + if (Integer.parseInt(character[index]) > cap) { mcMMO.p.getLogger().warning("Truncating " + skill.getName() + " to configured max level for player " + character[USERNAME]); character[index] = cap + ""; updated = true; @@ -1053,7 +1053,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } if (updated) { - line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString(); + line = org.apache.commons.lang.StringUtils.join(character, ":") + ":"; } writer.append(line).append("\r\n"); @@ -1130,7 +1130,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { return statValue; } - private class SkillComparator implements Comparator { + private static class SkillComparator implements Comparator { @Override public int compare(PlayerStat o1, PlayerStat o2) { return (o2.statVal - o1.statVal); @@ -1139,27 +1139,27 @@ public final class FlatfileDatabaseManager implements DatabaseManager { private PlayerProfile loadFromLine(String[] character) { Map skills = getSkillMapFromLine(character); // Skill levels - Map skillsXp = new EnumMap(PrimarySkillType.class); // Skill & XP - Map skillsDATS = new EnumMap(SuperAbilityType.class); // Ability & Cooldown - Map uniquePlayerDataMap = new EnumMap(UniqueDataType.class); + Map skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP + Map skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown + Map uniquePlayerDataMap = new EnumMap<>(UniqueDataType.class); MobHealthbarType mobHealthbarType; int scoreboardTipsShown; // TODO on updates, put new values in a try{} ? - skillsXp.put(PrimarySkillType.TAMING, (float) Integer.valueOf(character[EXP_TAMING])); - skillsXp.put(PrimarySkillType.MINING, (float) Integer.valueOf(character[EXP_MINING])); - skillsXp.put(PrimarySkillType.REPAIR, (float) Integer.valueOf(character[EXP_REPAIR])); - skillsXp.put(PrimarySkillType.WOODCUTTING, (float) Integer.valueOf(character[EXP_WOODCUTTING])); - skillsXp.put(PrimarySkillType.UNARMED, (float) Integer.valueOf(character[EXP_UNARMED])); - skillsXp.put(PrimarySkillType.HERBALISM, (float) Integer.valueOf(character[EXP_HERBALISM])); - skillsXp.put(PrimarySkillType.EXCAVATION, (float) Integer.valueOf(character[EXP_EXCAVATION])); - skillsXp.put(PrimarySkillType.ARCHERY, (float) Integer.valueOf(character[EXP_ARCHERY])); - skillsXp.put(PrimarySkillType.SWORDS, (float) Integer.valueOf(character[EXP_SWORDS])); - skillsXp.put(PrimarySkillType.AXES, (float) Integer.valueOf(character[EXP_AXES])); - skillsXp.put(PrimarySkillType.ACROBATICS, (float) Integer.valueOf(character[EXP_ACROBATICS])); - skillsXp.put(PrimarySkillType.FISHING, (float) Integer.valueOf(character[EXP_FISHING])); - skillsXp.put(PrimarySkillType.ALCHEMY, (float) Integer.valueOf(character[EXP_ALCHEMY])); + skillsXp.put(PrimarySkillType.TAMING, (float) Integer.parseInt(character[EXP_TAMING])); + skillsXp.put(PrimarySkillType.MINING, (float) Integer.parseInt(character[EXP_MINING])); + skillsXp.put(PrimarySkillType.REPAIR, (float) Integer.parseInt(character[EXP_REPAIR])); + skillsXp.put(PrimarySkillType.WOODCUTTING, (float) Integer.parseInt(character[EXP_WOODCUTTING])); + skillsXp.put(PrimarySkillType.UNARMED, (float) Integer.parseInt(character[EXP_UNARMED])); + skillsXp.put(PrimarySkillType.HERBALISM, (float) Integer.parseInt(character[EXP_HERBALISM])); + skillsXp.put(PrimarySkillType.EXCAVATION, (float) Integer.parseInt(character[EXP_EXCAVATION])); + skillsXp.put(PrimarySkillType.ARCHERY, (float) Integer.parseInt(character[EXP_ARCHERY])); + skillsXp.put(PrimarySkillType.SWORDS, (float) Integer.parseInt(character[EXP_SWORDS])); + skillsXp.put(PrimarySkillType.AXES, (float) Integer.parseInt(character[EXP_AXES])); + skillsXp.put(PrimarySkillType.ACROBATICS, (float) Integer.parseInt(character[EXP_ACROBATICS])); + skillsXp.put(PrimarySkillType.FISHING, (float) Integer.parseInt(character[EXP_FISHING])); + skillsXp.put(PrimarySkillType.ALCHEMY, (float) Integer.parseInt(character[EXP_ALCHEMY])); // Taming - Unused skillsDATS.put(SuperAbilityType.SUPER_BREAKER, Integer.valueOf(character[COOLDOWN_SUPER_BREAKER])); @@ -1190,7 +1190,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } try { - scoreboardTipsShown = Integer.valueOf(character[SCOREBOARD_TIPS]); + scoreboardTipsShown = Integer.parseInt(character[SCOREBOARD_TIPS]); } catch (Exception e) { scoreboardTipsShown = 0; @@ -1207,7 +1207,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } private Map getSkillMapFromLine(String[] character) { - Map skills = new EnumMap(PrimarySkillType.class); // Skill & Level + Map skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level skills.put(PrimarySkillType.TAMING, Integer.valueOf(character[SKILLS_TAMING])); skills.put(PrimarySkillType.MINING, Integer.valueOf(character[SKILLS_MINING])); @@ -1328,7 +1328,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { character[HEALTHBAR] = Config.getInstance().getMobHealthbarDefault().toString(); - line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString(); + line = org.apache.commons.lang.StringUtils.join(character, ":") + ":"; writer.append(line).append("\r\n"); } diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index be165b87b..7830362c4 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -25,7 +25,7 @@ public final class SQLDatabaseManager implements DatabaseManager { private static final String ALL_QUERY_VERSION = "total"; private final String tablePrefix = Config.getInstance().getMySQLTablePrefix(); - private final Map cachedUserIDs = new HashMap(); + private final Map cachedUserIDs = new HashMap<>(); private DataSource miscPool; private DataSource loadPool; @@ -214,8 +214,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } public void cleanupUser(UUID uuid) { - if(cachedUserIDs.containsKey(uuid)) - cachedUserIDs.remove(uuid); + cachedUserIDs.remove(uuid); } public boolean saveUser(PlayerProfile profile) { @@ -345,7 +344,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } public List readLeaderboard(PrimarySkillType skill, int pageNumber, int statsPerPage) { - List stats = new ArrayList(); + List stats = new ArrayList<>(); String query = skill == null ? ALL_QUERY_VERSION : skill.name().toLowerCase(Locale.ENGLISH); ResultSet resultSet = null; @@ -360,13 +359,13 @@ public final class SQLDatabaseManager implements DatabaseManager { resultSet = statement.executeQuery(); while (resultSet.next()) { - ArrayList column = new ArrayList(); + ArrayList column = new ArrayList<>(); for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) { column.add(resultSet.getString(i)); } - stats.add(new PlayerStat(column.get(1), Integer.valueOf(column.get(0)))); + stats.add(new PlayerStat(column.get(1), Integer.parseInt(column.get(0)))); } } catch (SQLException ex) { @@ -382,7 +381,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } public Map readRank(String playerName) { - Map skills = new HashMap(); + Map skills = new HashMap<>(); ResultSet resultSet = null; PreparedStatement statement = null; @@ -752,7 +751,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } public List getStoredUsers() { - ArrayList users = new ArrayList(); + ArrayList users = new ArrayList<>(); Statement statement = null; Connection connection = null; @@ -1070,10 +1069,10 @@ public final class SQLDatabaseManager implements DatabaseManager { } private PlayerProfile loadFromResult(String playerName, ResultSet result) throws SQLException { - Map skills = new EnumMap(PrimarySkillType.class); // Skill & Level - Map skillsXp = new EnumMap(PrimarySkillType.class); // Skill & XP - Map skillsDATS = new EnumMap(SuperAbilityType.class); // Ability & Cooldown - Map uniqueData = new EnumMap(UniqueDataType.class); //Chimaera wing cooldown and other misc info + Map skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level + Map skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP + Map skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown + Map uniqueData = new EnumMap<>(UniqueDataType.class); //Chimaera wing cooldown and other misc info MobHealthbarType mobHealthbarType; UUID uuid; int scoreboardTipsShown; @@ -1316,7 +1315,7 @@ public final class SQLDatabaseManager implements DatabaseManager { private class GetUUIDUpdatesRequired extends BukkitRunnable { public void run() { massUpdateLock.lock(); - List names = new ArrayList(); + List names = new ArrayList<>(); Connection connection = null; Statement statement = null; ResultSet resultSet = null; diff --git a/src/main/java/com/gmail/nossr50/datatypes/experience/SkillXpGain.java b/src/main/java/com/gmail/nossr50/datatypes/experience/SkillXpGain.java index a6d645f39..3ffb1cd94 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/experience/SkillXpGain.java +++ b/src/main/java/com/gmail/nossr50/datatypes/experience/SkillXpGain.java @@ -2,6 +2,7 @@ package com.gmail.nossr50.datatypes.experience; import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import org.jetbrains.annotations.NotNull; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; @@ -40,7 +41,7 @@ public class SkillXpGain implements Delayed { } @Override - public int compareTo(Delayed other) { + public int compareTo(@NotNull Delayed other) { if (other instanceof SkillXpGain) { // Use more efficient method if possible (private fields) return this.compareTo((SkillXpGain) other); diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java index 6629adc2d..c4b6e42ca 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -31,8 +31,8 @@ public class Party { // private static final String OFFLINE_PLAYER_PREFIX = "☆"; private static final String OFFLINE_PLAYER_PREFIX = "○"; // private static final String OFFLINE_PLAYER_PREFIX = "⭕" + ChatColor.RESET; - private final LinkedHashMap members = new LinkedHashMap(); - private final List onlineMembers = new ArrayList(); + private final LinkedHashMap members = new LinkedHashMap<>(); + private final List onlineMembers = new ArrayList<>(); private PartyLeader leader; private String name; @@ -101,7 +101,7 @@ public class Party { public List getOnlinePlayerNames(CommandSender sender) { Player player = sender instanceof Player ? (Player) sender : null; - List onlinePlayerNames = new ArrayList(); + List onlinePlayerNames = new ArrayList<>(); for (Player onlinePlayer : getOnlineMembers()) { if (player != null && player.canSee(onlinePlayer)) { @@ -141,7 +141,7 @@ public class Party { } public List getItemShareCategories() { - List shareCategories = new ArrayList(); + List shareCategories = new ArrayList<>(); for (ItemShareType shareType : ItemShareType.values()) { if (sharingDrops(shareType)) { @@ -323,16 +323,15 @@ public class Party { break; default: - return; } } public boolean hasMember(String memberName) { - return this.getMembers().values().contains(memberName); + return this.getMembers().containsValue(memberName); } public boolean hasMember(UUID uuid) { - return this.getMembers().keySet().contains(uuid); + return this.getMembers().containsKey(uuid); } /** @@ -361,7 +360,8 @@ public class Party { { Player onlinePlayer = Bukkit.getPlayer(onlineMember); - if(!isNotSamePerson(player.getUniqueId(), onlineMember) || player.canSee(onlinePlayer)) + if(!isNotSamePerson(player.getUniqueId(), onlineMember) + || onlinePlayer != null && player.canSee(onlinePlayer)) { visiblePartyList.add(onlineMember); } else { @@ -515,7 +515,7 @@ public class Party { * @return the near party members */ public List getNearMembers(McMMOPlayer mcMMOPlayer) { - List nearMembers = new ArrayList(); + List nearMembers = new ArrayList<>(); Party party = mcMMOPlayer.getParty(); if (party != null) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 214081384..3f469a0b3 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -45,7 +45,6 @@ import com.gmail.nossr50.util.experience.ExperienceBarManager; import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; -import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.SkillUtils; @@ -68,7 +67,7 @@ public class McMMOPlayer { private final Player player; private final PlayerProfile profile; - private final Map skillManagers = new HashMap(); + private final Map skillManagers = new HashMap<>(); private final ExperienceBarManager experienceBarManager; private Party party; @@ -87,10 +86,10 @@ public class McMMOPlayer { private boolean godMode; private boolean chatSpy = false; //Off by default - private final Map abilityMode = new HashMap(); - private final Map abilityInformed = new HashMap(); + private final Map abilityMode = new HashMap<>(); + private final Map abilityInformed = new HashMap<>(); - private final Map toolMode = new HashMap(); + private final Map toolMode = new HashMap<>(); private int recentlyHurt; private int respawnATS; @@ -766,7 +765,6 @@ public class McMMOPlayer { return; default: - return; } } @@ -783,7 +781,6 @@ public class McMMOPlayer { return; default: - return; } } @@ -801,7 +798,6 @@ public class McMMOPlayer { return; default: - return; } } @@ -906,9 +902,6 @@ public class McMMOPlayer { ticks = PerksUtils.handleActivationPerks(player, 2 + (getSkillLevel(skill) / abilityLengthVar), ability.getMaxLength()); } - // Notify people that ability has been activated - ParticleEffectUtils.playAbilityEnabledEffect(player); - if (useChatNotifications()) { NotificationManager.sendPlayerInformation(player, NotificationType.SUPER_ABILITY, ability.getAbilityOn()); //player.sendMessage(ability.getAbilityOn()); @@ -919,7 +912,6 @@ public class McMMOPlayer { //Sounds SoundManager.worldSendSound(player.getWorld(), player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC); - // Enable the ability profile.setAbilityDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR)); setAbilityMode(ability, true); diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index f8463aa02..49fc3d6f7 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -32,14 +32,14 @@ public class PlayerProfile { private int saveAttempts = 0; /* Skill Data */ - private final Map skills = new HashMap(); // Skill & Level - private final Map skillsXp = new HashMap(); // Skill & XP - private final Map abilityDATS = new HashMap(); // Ability & Cooldown + private final Map skills = new HashMap<>(); // Skill & Level + private final Map skillsXp = new HashMap<>(); // Skill & XP + private final Map abilityDATS = new HashMap<>(); // Ability & Cooldown private final Map uniquePlayerData = new HashMap<>(); //Misc data that doesn't fit into other categories (chimaera wing, etc..) // Store previous XP gains for diminished returns - private final DelayQueue gainedSkillsXp = new DelayQueue(); - private final HashMap rollingSkillsXp = new HashMap(); + private final DelayQueue gainedSkillsXp = new DelayQueue<>(); + private final HashMap rollingSkillsXp = new HashMap<>(); @Deprecated public PlayerProfile(String playerName) { @@ -136,7 +136,6 @@ public class PlayerProfile { else scheduleAsyncSaveDelay(); - return; } else { mcMMO.p.getLogger().severe("mcMMO has failed to save the profile for " +getPlayerName()+" numerous times." + diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java index fd9f89639..2ed443878 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java @@ -82,9 +82,9 @@ public enum PrimarySkillType { public static final List MISC_SKILLS = ImmutableList.of(ACROBATICS, ALCHEMY, REPAIR, SALVAGE, SMELTING); static { - List childSkills = new ArrayList(); - List nonChildSkills = new ArrayList(); - ArrayList names = new ArrayList(); + List childSkills = new ArrayList<>(); + List nonChildSkills = new ArrayList<>(); + ArrayList names = new ArrayList<>(); ArrayList subSkillNames = new ArrayList<>(); for (PrimarySkillType skill : values()) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java index f72ede1bd..6dfcd383f 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java @@ -180,7 +180,7 @@ public enum SubSkillType { /* * Find where to begin our substring (after the prefix) */ - String endResult = ""; + StringBuilder endResult = new StringBuilder(); int subStringIndex = getSubStringIndex(subSkillName); /* @@ -193,20 +193,20 @@ public enum SubSkillType { for(String string : splitStrings) { - endResult += StringUtils.getCapitalized(string); + endResult.append(StringUtils.getCapitalized(string)); } } else { - endResult += StringUtils.getCapitalized(subskillNameWithoutPrefix); + endResult.append(StringUtils.getCapitalized(subskillNameWithoutPrefix)); } - return endResult; + return endResult.toString(); } public String getWikiName(String subSkillName) { /* * Find where to begin our substring (after the prefix) */ - String endResult = ""; + StringBuilder endResult = new StringBuilder(); int subStringIndex = getSubStringIndex(subSkillName); /* @@ -220,17 +220,17 @@ public enum SubSkillType { for(int i = 0; i < splitStrings.length; i++) { if(i+1 >= splitStrings.length) - endResult+=StringUtils.getCapitalized(splitStrings[i]); + endResult.append(StringUtils.getCapitalized(splitStrings[i])); else { - endResult += StringUtils.getCapitalized(splitStrings[i]); - endResult += "_"; + endResult.append(StringUtils.getCapitalized(splitStrings[i])); + endResult.append("_"); } } } else { - endResult += StringUtils.getCapitalized(subskillNameWithoutPrefix); + endResult.append(StringUtils.getCapitalized(subskillNameWithoutPrefix)); } - return endResult; + return endResult.toString(); } /** diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/interfaces/Rank.java b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/interfaces/Rank.java index 7e6267f18..4729ae454 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/interfaces/Rank.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/interfaces/Rank.java @@ -13,9 +13,9 @@ public interface Rank { */ boolean hasRanks(); - /** - * An sequential collection of rank level requirements - * @return level requirements + /* + An sequential collection of rank level requirements + @return level requirements */ //Collection getUnlockLevels(); } diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java index 3dee6a384..33b049ee3 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java @@ -4,6 +4,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; public abstract class McMMOChatEvent extends Event implements Cancellable { private boolean cancelled; @@ -84,7 +85,7 @@ public abstract class McMMOChatEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerExperienceEvent.java b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerExperienceEvent.java index 78592b03b..73829b7a0 100644 --- a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerExperienceEvent.java +++ b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerExperienceEvent.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; +import org.jetbrains.annotations.NotNull; /** * Generic event for mcMMO experience events. @@ -67,7 +68,7 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelDownEvent.java b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelDownEvent.java index 3834726f8..6e512b338 100644 --- a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelDownEvent.java +++ b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelDownEvent.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a user loses levels in a skill @@ -50,7 +51,7 @@ public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelUpEvent.java b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelUpEvent.java index 062dd4a2a..20badcf7c 100644 --- a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelUpEvent.java +++ b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerLevelUpEvent.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a user levels up in a skill @@ -50,7 +51,7 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerXpGainEvent.java b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerXpGainEvent.java index d789fde70..5cd0c73fa 100644 --- a/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerXpGainEvent.java +++ b/src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerXpGainEvent.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * Called when a player gains XP in a skill @@ -55,7 +56,7 @@ public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java index 840f039f6..3458ab5c8 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageByEntityEvent.java @@ -23,7 +23,7 @@ public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent { } public static EnumMap> getFunctionModifiers(Map modifiers) { - EnumMap> modifierFunctions = new EnumMap>(DamageModifier.class); + EnumMap> modifierFunctions = new EnumMap<>(DamageModifier.class); Function ZERO = Functions.constant(-0.0); for (DamageModifier modifier : modifiers.keySet()) { diff --git a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java index 0ec008672..34eab80bd 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeEntityDamageEvent.java @@ -23,7 +23,7 @@ public class FakeEntityDamageEvent extends EntityDamageEvent { } public static EnumMap> getFunctionModifiers(Map modifiers) { - EnumMap> modifierFunctions = new EnumMap>(DamageModifier.class); + EnumMap> modifierFunctions = new EnumMap<>(DamageModifier.class); Function ZERO = Functions.constant(-0.0); for (DamageModifier modifier : modifiers.keySet()) { diff --git a/src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerDeathPenaltyEvent.java b/src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerDeathPenaltyEvent.java index bf723375a..7c4d3f08a 100644 --- a/src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerDeathPenaltyEvent.java +++ b/src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerDeathPenaltyEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; +import org.jetbrains.annotations.NotNull; import java.util.HashMap; @@ -57,7 +58,7 @@ public class McMMOPlayerDeathPenaltyEvent extends PlayerEvent implements Cancell private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerPreDeathPenaltyEvent.java b/src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerPreDeathPenaltyEvent.java index b831f0426..7bf355da0 100644 --- a/src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerPreDeathPenaltyEvent.java +++ b/src/main/java/com/gmail/nossr50/events/hardcore/McMMOPlayerPreDeathPenaltyEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; +import org.jetbrains.annotations.NotNull; public class McMMOPlayerPreDeathPenaltyEvent extends PlayerEvent implements Cancellable { private boolean cancelled; @@ -28,7 +29,7 @@ public class McMMOPlayerPreDeathPenaltyEvent extends PlayerEvent implements Canc private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/items/McMMOItemSpawnEvent.java b/src/main/java/com/gmail/nossr50/events/items/McMMOItemSpawnEvent.java index b6d7dcb94..3bfb95532 100644 --- a/src/main/java/com/gmail/nossr50/events/items/McMMOItemSpawnEvent.java +++ b/src/main/java/com/gmail/nossr50/events/items/McMMOItemSpawnEvent.java @@ -5,6 +5,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; /** * Called when mcMMO is preparing to drop an item. @@ -63,7 +64,7 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyAllianceChangeEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyAllianceChangeEvent.java index f902561a2..68fc2db6f 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyAllianceChangeEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyAllianceChangeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; +import org.jetbrains.annotations.NotNull; public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancellable { private final String oldAlly; @@ -80,7 +81,7 @@ public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancel private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java index bac977001..365236d91 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyChangeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; +import org.jetbrains.annotations.NotNull; /** * Called when a player attempts to join, leave, or change parties. @@ -93,7 +94,7 @@ public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyLevelUpEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyLevelUpEvent.java index b6790dd48..ed42bf028 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyLevelUpEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyLevelUpEvent.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class McMMOPartyLevelUpEvent extends Event implements Cancellable { private final Party party; @@ -43,7 +44,7 @@ public class McMMOPartyLevelUpEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java index 88a5f666b..322833de1 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyTeleportEvent.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.events.party; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerTeleportEvent; +import org.jetbrains.annotations.NotNull; /** * Called just before a player teleports using the /ptp command. @@ -35,11 +36,11 @@ public class McMMOPartyTeleportEvent extends PlayerTeleportEvent { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } - public static HandlerList getHandlerList() { + public static @NotNull HandlerList getHandlerList() { return handlers; } } diff --git a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyXpGainEvent.java b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyXpGainEvent.java index 1b001f3b8..926588dcc 100644 --- a/src/main/java/com/gmail/nossr50/events/party/McMMOPartyXpGainEvent.java +++ b/src/main/java/com/gmail/nossr50/events/party/McMMOPartyXpGainEvent.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class McMMOPartyXpGainEvent extends Event implements Cancellable { private final Party party; @@ -65,7 +66,7 @@ public class McMMOPartyXpGainEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/players/McMMOPlayerProfileLoadEvent.java b/src/main/java/com/gmail/nossr50/events/players/McMMOPlayerProfileLoadEvent.java index e8a517754..c16a520a8 100644 --- a/src/main/java/com/gmail/nossr50/events/players/McMMOPlayerProfileLoadEvent.java +++ b/src/main/java/com/gmail/nossr50/events/players/McMMOPlayerProfileLoadEvent.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; public class McMMOPlayerProfileLoadEvent extends Event implements Cancellable { private boolean cancelled; @@ -32,7 +33,7 @@ public class McMMOPlayerProfileLoadEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/scoreboard/McMMOScoreboardEvent.java b/src/main/java/com/gmail/nossr50/events/scoreboard/McMMOScoreboardEvent.java index 44a22538b..e03a8a4f7 100644 --- a/src/main/java/com/gmail/nossr50/events/scoreboard/McMMOScoreboardEvent.java +++ b/src/main/java/com/gmail/nossr50/events/scoreboard/McMMOScoreboardEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.scoreboard.Scoreboard; +import org.jetbrains.annotations.NotNull; /** * The parent class of all mcMMO scoreboard events @@ -25,7 +26,7 @@ abstract public class McMMOScoreboardEvent extends Event { this.targetPlayer = targetPlayer; } - /** GETTER & SETTER BOILERPLATE **/ + /* GETTER & SETTER BOILERPLATE **/ /** * This is the scoreboard the player will be assigned to after this event @@ -80,7 +81,7 @@ abstract public class McMMOScoreboardEvent extends Event { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java index 05ed0f510..08de8fc99 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerNotificationEvent.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; /** * This event is sent for when mcMMO informs a player about various important information @@ -76,7 +77,7 @@ public class McMMOPlayerNotificationEvent extends Event implements Cancellable { */ @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerSkillEvent.java b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerSkillEvent.java index b9a5af433..e899ea528 100644 --- a/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerSkillEvent.java +++ b/src/main/java/com/gmail/nossr50/events/skills/McMMOPlayerSkillEvent.java @@ -5,6 +5,7 @@ import com.gmail.nossr50.util.player.UserManager; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; +import org.jetbrains.annotations.NotNull; /** * Generic event for mcMMO skill handling. @@ -37,7 +38,7 @@ public abstract class McMMOPlayerSkillEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); @Override - public HandlerList getHandlers() { + public @NotNull HandlerList getHandlers() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index c73e64f6a..7f751502e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -126,8 +126,7 @@ public class BlockListener implements Listener { } BlockFace direction = event.getDirection(); - Block movedBlock = event.getBlock(); - movedBlock = movedBlock.getRelative(direction, 2); + Block movedBlock; for (Block b : event.getBlocks()) { if (BlockUtils.shouldBeWatched(b.getState())) { diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 7a6ff5bc0..275c52155 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -195,7 +195,6 @@ public class EntityListener implements Listener { mcMMO.getPlaceStore().setTrue(block); } } else if ((block.getType() == Material.REDSTONE_ORE)) { - return; } else { if (mcMMO.getPlaceStore().isTrue(block)) { @@ -263,13 +262,15 @@ public class EntityListener implements Listener { Projectile projectile = (Projectile) event.getCombuster(); if(projectile.getShooter() instanceof Player) { Player attacker = (Player) projectile.getShooter(); - if(checkParties(event, defender, attacker)) - return; + if(checkParties(event, defender, attacker)) { + event.setCancelled(true); + } } } else if(event.getCombuster() instanceof Player) { Player attacker = (Player) event.getCombuster(); - if(checkParties(event, defender, attacker)) - return; + if(checkParties(event, defender, attacker)) { + event.setCancelled(true); + } } } } @@ -636,7 +637,6 @@ public class EntityListener implements Listener { return; default: - return; } } } @@ -728,7 +728,6 @@ public class EntityListener implements Listener { return; default: - return; } } @@ -960,7 +959,6 @@ public class EntityListener implements Listener { return; default: - return; } } diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 823b1528f..bc21c4b69 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -280,7 +280,6 @@ public class InventoryListener implements Listener { AlchemyPotionBrewer.scheduleCheck(player, stand); return; default: - return; } } else if (slot == InventoryType.SlotType.FUEL) { diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 4d00d009d..436e6cbc4 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -288,21 +288,23 @@ public class PlayerListener implements Listener { switch (event.getState()) { case CAUGHT_FISH: - //TODO Update to new API once available! Waiting for case CAUGHT_TREASURE: - Item fishingCatch = (Item) event.getCaught(); + //TODO Update to new API once available! Waiting for case CAUGHT_TREASURE + if(event.getCaught() != null) { + Item fishingCatch = (Item) event.getCaught(); - if (Config.getInstance(). getFishingOverrideTreasures() && - fishingCatch.getItemStack().getType() != Material.SALMON && - fishingCatch.getItemStack().getType() != Material.COD && - fishingCatch.getItemStack().getType() != Material.TROPICAL_FISH && - fishingCatch.getItemStack().getType() != Material.PUFFERFISH) { - fishingCatch.setItemStack(new ItemStack(Material.SALMON, 1)); - } + if (Config.getInstance(). getFishingOverrideTreasures() && + fishingCatch.getItemStack().getType() != Material.SALMON && + fishingCatch.getItemStack().getType() != Material.COD && + fishingCatch.getItemStack().getType() != Material.TROPICAL_FISH && + fishingCatch.getItemStack().getType() != Material.PUFFERFISH) { + fishingCatch.setItemStack(new ItemStack(Material.SALMON, 1)); + } - if (Permissions.vanillaXpBoost(player, PrimarySkillType.FISHING)) { - //Don't modify XP below vanilla values - if(fishingManager.handleVanillaXpBoost(event.getExpToDrop()) > 1) - event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop())); + if (Permissions.vanillaXpBoost(player, PrimarySkillType.FISHING)) { + //Don't modify XP below vanilla values + if(fishingManager.handleVanillaXpBoost(event.getExpToDrop()) > 1) + event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop())); + } } return; @@ -318,7 +320,6 @@ public class PlayerListener implements Listener { return; default: - return; } } @@ -397,19 +398,21 @@ public class PlayerListener implements Listener { case CAUGHT_FISH: if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) { - if(fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) - { - player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", 3)); - event.setExpToDrop(0); - Item caughtItem = (Item) caught; - caughtItem.remove(); - return; + if(caught instanceof Item) { + if(fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) + { + player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", 3)); + event.setExpToDrop(0); + Item caughtItem = (Item) caught; + caughtItem.remove(); + + return; + } + + fishingManager.handleFishing((Item) caught); + fishingManager.setFishingTarget(); } } - - fishingManager.handleFishing((Item) caught); - fishingManager.setFishingTarget(); - //fishingManager.setFishHookReference(null); return; case CAUGHT_ENTITY: if (fishingManager.canShake(caught)) { @@ -418,7 +421,6 @@ public class PlayerListener implements Listener { } return; default: - return; } } @@ -480,7 +482,6 @@ public class PlayerListener implements Listener { if (event.isCancelled()) { SoundManager.sendSound(player, player.getLocation(), SoundType.POP); - return; } } @@ -597,20 +598,18 @@ public class PlayerListener implements Listener { return; } + if(event.getClickedBlock() == null) + return; + Block clickedBlock = event.getClickedBlock(); - if(clickedBlock != null) { - Material clickedBlockType = clickedBlock.getType(); - //The blacklist contains interactable blocks so its a convenient filter - if(clickedBlockType == Repair.anvilMaterial || clickedBlockType == Salvage.anvilMaterial) { - event.setUseItemInHand(Event.Result.ALLOW); + Material clickedBlockType = clickedBlock.getType(); + //The blacklist contains interactable blocks so its a convenient filter + if(clickedBlockType == Repair.anvilMaterial || clickedBlockType == Salvage.anvilMaterial) { + event.setUseItemInHand(Event.Result.ALLOW); - if(mcMMO.getMaterialMapStore().isToolActivationBlackListed(clickedBlockType)) { - event.setUseInteractedBlock(Event.Result.DENY); - } + if(mcMMO.getMaterialMapStore().isToolActivationBlackListed(clickedBlockType)) { + event.setUseInteractedBlock(Event.Result.DENY); } - - //Cancel the event to prevent vanilla functionality - //Only cancel if item in hand has durability } if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) { @@ -763,7 +762,11 @@ public class PlayerListener implements Listener { if(player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) { break; } - + + //Hmm + if(event.getClickedBlock() == null) + return; + Block block = event.getClickedBlock(); BlockState blockState = block.getState(); diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index 1d20e2f7d..892359505 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -49,7 +49,6 @@ public class SelfListener implements Listener { ScoreboardManager.handleLevelUp(player, skill); if (!Config.getInstance().getLevelUpEffectsEnabled()) { - return; } /*if ((event.getSkillLevel() % Config.getInstance().getLevelUpEffectsTier()) == 0) { diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 98b19710a..90e16ea7b 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -62,7 +62,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; @@ -280,8 +279,8 @@ public class mcMMO extends JavaPlugin { private void checkForOutdatedAPI() { try { Class checkForClass = Class.forName("org.bukkit.event.block.BlockDropItemEvent"); - Method newerAPIMethod = checkForClass.getMethod("getItems"); - Class checkForClassBaseComponent = Class.forName("net.md_5.bungee.api.chat.BaseComponent"); + checkForClass.getMethod("getItems"); + Class.forName("net.md_5.bungee.api.chat.BaseComponent"); } catch (ClassNotFoundException | NoSuchMethodException e) { serverAPIOutdated = true; String software = platformManager.getServerSoftwareStr(); @@ -505,7 +504,7 @@ public class mcMMO extends JavaPlugin { new ChildConfig(); - List repairables = new ArrayList(); + List repairables = new ArrayList<>(); if (Config.getInstance().getToolModsEnabled()) { new ToolConfigManager(this); @@ -531,7 +530,7 @@ public class mcMMO extends JavaPlugin { // Load salvage configs, make manager and register them at this time SalvageConfigManager sManager = new SalvageConfigManager(this); - List salvageables = new ArrayList(sManager.getLoadedSalvageables()); + List salvageables = new ArrayList<>(sManager.getLoadedSalvageables()); salvageableManager = new SimpleSalvageableManager(salvageables.size()); salvageableManager.registerSalvageables(salvageables); } @@ -587,7 +586,7 @@ public class mcMMO extends JavaPlugin { new CleanBackupsTask().runTaskAsynchronously(mcMMO.p); // Bleed timer (Runs every 0.5 seconds) - new BleedTimerTask().runTaskTimer(this, 1 * Misc.TICK_CONVERSION_FACTOR, 1 * (Misc.TICK_CONVERSION_FACTOR / 2)); + new BleedTimerTask().runTaskTimer(this, Misc.TICK_CONVERSION_FACTOR, (Misc.TICK_CONVERSION_FACTOR / 2)); // Old & Powerless User remover long purgeIntervalTicks = Config.getInstance().getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR; @@ -613,7 +612,7 @@ public class mcMMO extends JavaPlugin { new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR); if (getHolidayManager().nearingAprilFirst()) { - new CheckDateTask().runTaskTimer(this, 10L * Misc.TICK_CONVERSION_FACTOR, 1L * 60L * 60L * Misc.TICK_CONVERSION_FACTOR); + new CheckDateTask().runTaskTimer(this, 10L * Misc.TICK_CONVERSION_FACTOR, 60L * 60L * Misc.TICK_CONVERSION_FACTOR); } // Clear the registered XP data so players can earn XP again diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 2074fc4bb..11989ff04 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -34,7 +34,7 @@ import java.util.UUID; public final class PartyManager { private static final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml"; - private static final List parties = new ArrayList(); + private static final List parties = new ArrayList<>(); private static final File partyFile = new File(partiesFilePath); private PartyManager() {} @@ -150,7 +150,7 @@ public final class PartyManager { * @return the near party members */ public static List getNearMembers(McMMOPlayer mcMMOPlayer) { - List nearMembers = new ArrayList(); + List nearMembers = new ArrayList<>(); Party party = mcMMOPlayer.getParty(); if (party != null) { @@ -168,7 +168,7 @@ public final class PartyManager { } public static List getNearVisibleMembers(McMMOPlayer mcMMOPlayer) { - List nearMembers = new ArrayList(); + List nearMembers = new ArrayList<>(); Party party = mcMMOPlayer.getParty(); if (party != null) { @@ -197,7 +197,7 @@ public final class PartyManager { public static LinkedHashMap getAllMembers(Player player) { Party party = getParty(player); - return party == null ? new LinkedHashMap() : party.getMembers(); + return party == null ? new LinkedHashMap<>() : party.getMembers(); } /** @@ -221,7 +221,7 @@ public final class PartyManager { } private static List getOnlineMembers(Party party) { - return party == null ? new ArrayList() : party.getOnlineMembers(); + return party == null ? new ArrayList<>() : party.getOnlineMembers(); } /** @@ -249,7 +249,7 @@ public final class PartyManager { @Deprecated public static Party getPlayerParty(String playerName) { for (Party party : parties) { - if (party.getMembers().keySet().contains(playerName)) { + if (party.getMembers().containsKey(playerName)) { return party; } } @@ -266,7 +266,7 @@ public final class PartyManager { public static Party getPlayerParty(String playerName, UUID uuid) { for (Party party : parties) { LinkedHashMap members = party.getMembers(); - if (members.keySet().contains(uuid) || members.values().contains(playerName)) { + if (members.containsKey(uuid) || members.containsValue(playerName)) { // Name changes if (members.get(uuid) == null || !members.get(uuid).equals(playerName)) { @@ -595,7 +595,7 @@ public final class PartyManager { YamlConfiguration partiesFile; partiesFile = YamlConfiguration.loadConfiguration(partyFile); - ArrayList hasAlly = new ArrayList(); + ArrayList hasAlly = new ArrayList<>(); for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { Party party = new Party(partyName); @@ -671,7 +671,7 @@ public final class PartyManager { partiesFile.set(partyName + ".ItemShareType." + itemShareType.toString(), party.sharingDrops(itemShareType)); } - List members = new ArrayList(); + List members = new ArrayList<>(); for (Entry memberEntry : party.getMembers().entrySet()) { String memberUniqueId = memberEntry.getKey() == null ? "" : memberEntry.getKey().toString(); @@ -701,7 +701,7 @@ public final class PartyManager { return; } - ArrayList hasAlly = new ArrayList(); + ArrayList hasAlly = new ArrayList<>(); for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) { Party party = new Party(partyName); diff --git a/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java b/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java index 0b296b4bd..b11b73d45 100644 --- a/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/CheckDateTask.java @@ -14,7 +14,7 @@ public class CheckDateTask extends BukkitRunnable { } // Set up jokes - new AprilTask().runTaskTimer(mcMMO.p, 1L * 60L * Misc.TICK_CONVERSION_FACTOR, 10L * 60L * Misc.TICK_CONVERSION_FACTOR); + new AprilTask().runTaskTimer(mcMMO.p, 60L * Misc.TICK_CONVERSION_FACTOR, 10L * 60L * Misc.TICK_CONVERSION_FACTOR); mcMMO.getHolidayManager().registerAprilCommand(); // Jokes deployed. diff --git a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java index d0c333592..114211c80 100644 --- a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java @@ -16,9 +16,9 @@ public class CleanBackupsTask extends BukkitRunnable { @Override public void run() { - List savedDays = new ArrayList(); - HashMap> savedYearsWeeks = new HashMap>(); - List toDelete = new ArrayList(); + List savedDays = new ArrayList<>(); + HashMap> savedYearsWeeks = new HashMap<>(); + List toDelete = new ArrayList<>(); int amountTotal = 0; int amountDeleted = 0; @@ -58,7 +58,7 @@ public class CleanBackupsTask extends BukkitRunnable { continue; } else { - List savedWeeks = savedYearsWeeks.computeIfAbsent(year, k -> new ArrayList()); + List savedWeeks = savedYearsWeeks.computeIfAbsent(year, k -> new ArrayList<>()); if (!savedWeeks.contains(weekOfYear) && Config.getInstance().getKeepWeeklyPastMonth()) { // Keep one backup of each week diff --git a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java index 987d1893f..31d961bf6 100644 --- a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java @@ -18,8 +18,8 @@ public class PartyAutoKickTask extends BukkitRunnable { @Override public void run() { - HashMap toRemove = new HashMap(); - List processedPlayers = new ArrayList(); + HashMap toRemove = new HashMap<>(); + List processedPlayers = new ArrayList<>(); long currentTime = System.currentTimeMillis(); diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java index bd255dcb5..b97818ebf 100644 --- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java @@ -96,7 +96,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable { if (Config.getInstance().getShowStatsAfterLogin()) { ScoreboardManager.enablePlayerStatsScoreboard(player); - new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, 1 * Misc.TICK_CONVERSION_FACTOR); + new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, Misc.TICK_CONVERSION_FACTOR); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index e471ba1e3..de303c957 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.Map.Entry; public class BleedTimerTask extends BukkitRunnable { - private static final Map bleedList = new HashMap(); + private static final Map bleedList = new HashMap<>(); private static boolean isIterating = false; @Override @@ -71,8 +71,7 @@ public class BleedTimerTask extends BukkitRunnable { //Count Armor for(ItemStack armorPiece : ((Player) target).getInventory().getArmorContents()) { - if(armorPiece != null) - armorCount++; + armorCount++; } } else { diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java b/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java index 55fc91767..1d460060f 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/DelayedCropReplant.java @@ -98,7 +98,7 @@ public class DelayedCropReplant extends BukkitRunnable { } - private class markPlantAsOld extends BukkitRunnable { + private static class markPlantAsOld extends BukkitRunnable { private final Location cropLoc; diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java b/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java index 025f54563..58ac14bee 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/Alchemy.java @@ -54,7 +54,7 @@ public final class Alchemy { public static double catalysisMinSpeed = AdvancedConfig.getInstance().getCatalysisMinSpeed(); public static double catalysisMaxSpeed = AdvancedConfig.getInstance().getCatalysisMaxSpeed(); - public static Map brewingStandMap = new HashMap(); + public static Map brewingStandMap = new HashMap<>(); private Alchemy() {} @@ -64,7 +64,7 @@ public final class Alchemy { public static void finishAllBrews() { mcMMO.p.debug("Completing " + brewingStandMap.size() + " unfinished Alchemy brews."); - List toFinish = new ArrayList(brewingStandMap.values()); + List toFinish = new ArrayList<>(brewingStandMap.values()); for (AlchemyBrewTask alchemyBrewTask : toFinish) { alchemyBrewTask.finishImmediately(); diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java index f6b42c285..30f93ebd6 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -56,19 +56,19 @@ public final class AlchemyPotionBrewer { } private static void removeIngredient(BrewerInventory inventory, Player player) { - ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone(); + if(inventory.getIngredient() == null) + return; - if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) { - return; - } - else if (ingredient.getAmount() <= 1) { - inventory.setIngredient(null); - return; - } - else { - ingredient.setAmount(ingredient.getAmount() - 1); - inventory.setIngredient(ingredient); - return; + ItemStack ingredient = inventory.getIngredient().clone(); + + if (isEmpty(ingredient) && !isValidIngredient(player, ingredient)) { + if (ingredient.getAmount() <= 1) { + inventory.setIngredient(null); + } + else { + ingredient.setAmount(ingredient.getAmount() - 1); + inventory.setIngredient(ingredient); + } } } @@ -113,7 +113,7 @@ public final class AlchemyPotionBrewer { return; } - List inputList = new ArrayList(); + List inputList = new ArrayList<>(); for (int i = 0; i < 3; i++) { ItemStack item = inventory.getItem(i); diff --git a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java index d40c1c9fd..4194a2baa 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java @@ -15,7 +15,7 @@ import java.util.Iterator; import java.util.List; public class Archery { - private static final List trackedEntities = new ArrayList(); + private static final List trackedEntities = new ArrayList<>(); public static double skillShotMaxBonusDamage = AdvancedConfig.getInstance().getSkillShotDamageMax(); diff --git a/src/main/java/com/gmail/nossr50/skills/axes/Axes.java b/src/main/java/com/gmail/nossr50/skills/axes/Axes.java index 939d175bd..753d55971 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/Axes.java @@ -23,8 +23,11 @@ public class Axes { public static double skullSplitterModifier = AdvancedConfig.getInstance().getSkullSplitterModifier(); protected static boolean hasArmor(LivingEntity target) { + if(target.getEquipment() == null) + return false; + for (ItemStack itemStack : target.getEquipment().getArmorContents()) { - if (itemStack != null && ItemUtils.isArmor(itemStack)) { + if (ItemUtils.isArmor(itemStack)) { return true; } } diff --git a/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java b/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java index 5e4437358..af0fbf95e 100644 --- a/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java +++ b/src/main/java/com/gmail/nossr50/skills/child/FamilyTree.java @@ -8,7 +8,7 @@ import java.util.HashMap; import java.util.Set; public class FamilyTree { - private static final HashMap> tree = new HashMap>(); + private static final HashMap> tree = new HashMap<>(); public static Set getParents(PrimarySkillType childSkill) { enforceChildSkill(childSkill); diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java index 86580a944..ea2db8613 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java @@ -22,7 +22,7 @@ public class Excavation { String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData()); if (TreasureConfig.getInstance().excavationMap.containsKey(friendly)) return TreasureConfig.getInstance().excavationMap.get(friendly); - return new ArrayList(); + return new ArrayList<>(); } protected static int getBlockXP(BlockState blockState) { diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java index 994d84866..e2d259310 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java @@ -61,7 +61,7 @@ public class ExcavationManager extends SkillManager { } public int getExperienceOrbsReward() { - return 1 * getArchaeologyRank(); + return getArchaeologyRank(); } public double getArchaelogyExperienceOrbChance() { diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index 8b52bf894..c5b7ef833 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -16,7 +16,7 @@ import java.util.Set; public final class Fishing { - protected static final HashMap> ENCHANTABLE_CACHE = new HashMap>(); + protected static final HashMap> ENCHANTABLE_CACHE = new HashMap<>(); public static Set masterAnglerBiomes = BiomeAdapter.WATER_BIOMES; public static Set iceFishingBiomes = BiomeAdapter.ICE_BIOMES; diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index add636f12..5c3de0452 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -89,7 +89,7 @@ public class FishingManager extends SkillManager { fishingRod.setDurability((short) (fishingRod.getDurability() + 5)); getPlayer().updateInventory(); - if(lastWarnedExhaust + (1000 * 1) < currentTime) + if(lastWarnedExhaust + (1000) < currentTime) { getPlayer().sendMessage(LocaleLoader.getString("Fishing.Exhausting")); lastWarnedExhaust = currentTime; @@ -118,7 +118,7 @@ public class FishingManager extends SkillManager { long fishHookSpawnCD = fishHookSpawnTimestamp + 1000; boolean hasFished = (currentTime < fishHookSpawnCD); - if(hasFished && (lastWarned + (1000 * 1) < currentTime)) + if(hasFished && (lastWarned + (1000) < currentTime)) { getPlayer().sendMessage(LocaleLoader.getString("Fishing.Scared")); lastWarned = System.currentTimeMillis(); @@ -286,7 +286,7 @@ public class FishingManager extends SkillManager { if (treasure != null) { ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay? - Map enchants = new HashMap(); + Map enchants = new HashMap<>(); if (isMagicHunterEnabled() && ItemUtils.isEnchantable(treasureDrop)) { @@ -505,7 +505,7 @@ public class FishingManager extends SkillManager { * @return true if the item has been enchanted */ private Map handleMagicHunter(ItemStack treasureDrop) { - Map enchants = new HashMap(); + Map enchants = new HashMap<>(); List fishingEnchantments = null; double diceRoll = Misc.getRandom().nextDouble() * 100; @@ -535,7 +535,7 @@ public class FishingManager extends SkillManager { } List validEnchantments = getPossibleEnchantments(treasureDrop); - List possibleEnchants = new ArrayList(); + List possibleEnchants = new ArrayList<>(); for (EnchantmentTreasure enchantmentTreasure : fishingEnchantments) { if (validEnchantments.contains(enchantmentTreasure.getEnchantment())) { @@ -574,7 +574,7 @@ public class FishingManager extends SkillManager { return Fishing.ENCHANTABLE_CACHE.get(dropType); } - List possibleEnchantments = new ArrayList(); + List possibleEnchantments = new ArrayList<>(); for (Enchantment enchantment : Enchantment.values()) { if (enchantment.canEnchantItem(treasureDrop)) { diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index 5e668a3db..c93c2adc9 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -701,7 +701,7 @@ public class HerbalismManager extends SkillManager { Player player = getPlayer(); PlayerInventory playerInventory = player.getInventory(); - Material seed = null; + Material seed; switch (blockState.getType()) { case CARROTS: @@ -761,7 +761,7 @@ public class HerbalismManager extends SkillManager { return false; } - int finalAge = 0; + int finalAge; int greenThumbStage = getGreenThumbStage(greenTerra); //Immature plants will start over at 0 diff --git a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java index a299bb0be..4ca7756d2 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java @@ -99,7 +99,7 @@ public class BlastMining { // We can make this assumption because we (should) be the only ones using this exact metadata Player player = mcMMO.p.getServer().getPlayerExact(tnt.getMetadata(mcMMO.tntMetadataKey).get(0).asString()); - if (!player.equals(defender)) { + if (!(player != null && player.equals(defender))) { return false; } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index c72811472..329335af5 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -159,7 +159,7 @@ public class MiningManager extends SkillManager { public void blastMiningDropProcessing(float yield, EntityExplodeEvent event) { //Strip out only stuff that gives mining XP - List ores = new ArrayList(); + List ores = new ArrayList<>(); List notOres = new ArrayList<>(); for (Block targetBlock : event.blockList()) { diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java index ce1d1775d..ab4a98fbe 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -214,10 +214,10 @@ public class RepairManager extends SkillManager { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChance(getArcaneForgingRank()); } - /** - * Gets chance of keeping enchantment during repair. - * - * @return The chance of keeping the enchantment + /* + Gets chance of keeping enchantment during repair. + + @return The chance of keeping the enchantment */ /*public double getKeepEnchantChance() { int skillLevel = getSkillLevel(); @@ -231,10 +231,10 @@ public class RepairManager extends SkillManager { return 0; }*/ - /** - * Gets chance of enchantment being downgraded during repair. - * - * @return The chance of the enchantment being downgraded + /* + Gets chance of enchantment being downgraded during repair. + + @return The chance of the enchantment being downgraded */ /*public double getDowngradeEnchantChance() { int skillLevel = getSkillLevel(); diff --git a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairableManager.java b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairableManager.java index 05edc0d67..dd7a74f36 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairableManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/repairables/SimpleRepairableManager.java @@ -14,7 +14,7 @@ public class SimpleRepairableManager implements RepairableManager { } public SimpleRepairableManager(int repairablesSize) { - this.repairables = new HashMap(repairablesSize); + this.repairables = new HashMap<>(repairablesSize); } @Override diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageableManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageableManager.java index 6a9a41f9c..db886c189 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageableManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/salvageables/SimpleSalvageableManager.java @@ -15,7 +15,7 @@ public class SimpleSalvageableManager implements SalvageableManager { } public SimpleSalvageableManager(int salvageablesSize) { - this.salvageables = new HashMap(salvageablesSize); + this.salvageables = new HashMap<>(salvageablesSize); } @Override diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java index e36df9787..9d622ea62 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/SmeltingManager.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.skills.smelting; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainSource; import com.gmail.nossr50.datatypes.player.McMMOPlayer; @@ -10,7 +11,6 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.SkillActivationType; -import org.bukkit.block.BlockState; import org.bukkit.event.inventory.FurnaceBurnEvent; import org.bukkit.inventory.ItemStack; @@ -31,10 +31,10 @@ public class SmeltingManager extends SkillManager { && RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SMELTING_SECOND_SMELT, getPlayer()); } - /** - * Process the Flux Mining ability. - * - * @param blockState The {@link BlockState} to check ability activation for + /* + Process the Flux Mining ability. + + @param blockState The {@link BlockState} to check ability activation for * @return true if the ability was successful, false otherwise */ /*public boolean processFluxMining(BlockState blockState) { @@ -109,9 +109,11 @@ public class SmeltingManager extends SkillManager { } public ItemStack smeltProcessing(ItemStack smelting, ItemStack result) { + applyXpGain(Smelting.getResourceXp(smelting), XPGainReason.PVE, XPGainSource.PASSIVE); - if (isSecondSmeltSuccessful()) { + if (Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.SMELTING, result.getType()) + && isSecondSmeltSuccessful()) { ItemStack newResult = result.clone(); newResult.setAmount(result.getAmount() + 1); diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index ef9167659..2627b93c4 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -64,7 +64,7 @@ public class TamingManager extends SkillManager { playerSummonedEntities = new HashMap<>(); for(CallOfTheWildType callOfTheWildType : CallOfTheWildType.values()) { - playerSummonedEntities.put(callOfTheWildType, new ArrayList()); + playerSummonedEntities.put(callOfTheWildType, new ArrayList<>()); } } @@ -524,8 +524,7 @@ public class TamingManager extends SkillManager { //TODO: The way this tracker was written is garbo, I should just rewrite it, I'll save that for a future update public void removeFromTracker(TrackedTamingEntity trackedEntity) { - if(playerSummonedEntities.get(trackedEntity.getCallOfTheWildType()).contains(trackedEntity)) - playerSummonedEntities.get(trackedEntity.getCallOfTheWildType()).remove(trackedEntity); + playerSummonedEntities.get(trackedEntity.getCallOfTheWildType()).remove(trackedEntity); NotificationManager.sendPlayerInformationChatOnly(getPlayer(), "Taming.Summon.COTW.TimeExpired", StringUtils.getPrettyEntityTypeString(trackedEntity.getLivingEntity().getType())); } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index 8c6ce621e..07c47a1f3 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -99,7 +99,7 @@ public class WoodcuttingManager extends SkillManager { */ public void processTreeFeller(BlockState blockState) { Player player = getPlayer(); - Set treeFellerBlocks = new HashSet(); + Set treeFellerBlocks = new HashSet<>(); treeFellerReachedThreshold = false; @@ -160,7 +160,7 @@ public class WoodcuttingManager extends SkillManager { * before taking measurements). */ private void processTree(BlockState blockState, Set treeFellerBlocks) { - List futureCenterBlocks = new ArrayList(); + List futureCenterBlocks = new ArrayList<>(); // Check the block up and take different behavior (smaller search) if it's a log if (processTreeFellerTargetBlock(blockState.getBlock().getRelative(BlockFace.UP).getState(), futureCenterBlocks, treeFellerBlocks)) { diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index ef6b3df76..4750785fe 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -250,7 +250,7 @@ public final class BlockUtils { * @return HashSet with the IDs of every transparent block */ public static HashSet getTransparentBlocks() { - HashSet transparentBlocks = new HashSet(); + HashSet transparentBlocks = new HashSet<>(); for (Material material : Material.values()) { if (material.isTransparent()) { diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index c1a82f9af..c1bccbca2 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -152,9 +152,10 @@ public final class ChimaeraWing { ItemStack itemStack = new ItemStack(Config.getInstance().getChimaeraItem(), amount); ItemMeta itemMeta = itemStack.getItemMeta(); + //noinspection ConstantConditions itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name")); - List itemLore = new ArrayList(); + List itemLore = new ArrayList<>(); itemLore.add("mcMMO Item"); itemLore.add(LocaleLoader.getString("Item.ChimaeraWing.Lore")); itemMeta.setLore(itemLore); diff --git a/src/main/java/com/gmail/nossr50/util/EnchantmentUtils.java b/src/main/java/com/gmail/nossr50/util/EnchantmentUtils.java index ad71ea747..6aab49b3d 100644 --- a/src/main/java/com/gmail/nossr50/util/EnchantmentUtils.java +++ b/src/main/java/com/gmail/nossr50/util/EnchantmentUtils.java @@ -6,7 +6,7 @@ import java.util.HashMap; public class EnchantmentUtils { - private static final HashMap enchants = new HashMap(); + private static final HashMap enchants = new HashMap<>(); static { enchants.put("SHARPNESS", Enchantment.DAMAGE_ALL); diff --git a/src/main/java/com/gmail/nossr50/util/HardcoreManager.java b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java index ee2ad8092..9956a614d 100644 --- a/src/main/java/com/gmail/nossr50/util/HardcoreManager.java +++ b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java @@ -31,8 +31,8 @@ public final class HardcoreManager { PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile(); int totalLevelsLost = 0; - HashMap levelChanged = new HashMap(); - HashMap experienceChanged = new HashMap(); + HashMap levelChanged = new HashMap<>(); + HashMap experienceChanged = new HashMap<>(); for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { if (!primarySkillType.getHardcoreStatLossEnabled()) { @@ -83,8 +83,8 @@ public final class HardcoreManager { PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile(); int totalLevelsStolen = 0; - HashMap levelChanged = new HashMap(); - HashMap experienceChanged = new HashMap(); + HashMap levelChanged = new HashMap<>(); + HashMap experienceChanged = new HashMap<>(); for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { if (!primarySkillType.getHardcoreVampirismEnabled()) { diff --git a/src/main/java/com/gmail/nossr50/util/HolidayManager.java b/src/main/java/com/gmail/nossr50/util/HolidayManager.java index 903db4e16..bf312524b 100644 --- a/src/main/java/com/gmail/nossr50/util/HolidayManager.java +++ b/src/main/java/com/gmail/nossr50/util/HolidayManager.java @@ -96,9 +96,9 @@ public final class HolidayManager { Statistic.PIG_ONE_CM); static { - List colors = new ArrayList(); - List chatColors = new ArrayList(); - List chatFormats = new ArrayList(); + List colors = new ArrayList<>(); + List chatColors = new ArrayList<>(); + List chatFormats = new ArrayList<>(); for (ChatColor color : ChatColor.values()) { if (color.isColor()) { @@ -137,7 +137,7 @@ public final class HolidayManager { } } - hasCelebrated = new ArrayList(); + hasCelebrated = new ArrayList<>(); try { hasCelebrated.clear(); @@ -161,7 +161,7 @@ public final class HolidayManager { private void cleanupFiles() { File FlatFileDir = new File(mcMMO.getFlatFileDirectory()); File legacy = new File(FlatFileDir, "anniversary.yml"); - List toDelete = new ArrayList(); + List toDelete = new ArrayList<>(); if (legacy.exists()) { toDelete.add(legacy); diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index a0bfd5dee..f7dea6a38 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -459,7 +459,12 @@ public final class ItemUtils { } ItemMeta itemMeta = item.getItemMeta(); - return itemMeta.hasLore() && itemMeta.getLore().contains("mcMMO Item"); + + if(itemMeta == null) + return false; + + return itemMeta.getLore() != null + && itemMeta.getLore().contains("mcMMO Item"); } public static boolean isChimaeraWing(ItemStack item) { @@ -468,6 +473,10 @@ public final class ItemUtils { } ItemMeta itemMeta = item.getItemMeta(); + + if(itemMeta == null) + return false; + return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name")); } } diff --git a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java index 4bd676b1e..c31e51424 100644 --- a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java +++ b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java @@ -138,19 +138,19 @@ public final class MobHealthbarUtils { int coloredDisplay = (int) Math.ceil(fullDisplay * (healthPercentage / 100.0D)); int grayDisplay = fullDisplay - coloredDisplay; - String healthbar = color + ""; + StringBuilder healthbar = new StringBuilder(color + ""); for (int i = 0; i < coloredDisplay; i++) { - healthbar += symbol; + healthbar.append(symbol); } - healthbar += ChatColor.GRAY; + healthbar.append(ChatColor.GRAY); for (int i = 0; i < grayDisplay; i++) { - healthbar += symbol; + healthbar.append(symbol); } - return healthbar; + return healthbar.toString(); } /** diff --git a/src/main/java/com/gmail/nossr50/util/ModManager.java b/src/main/java/com/gmail/nossr50/util/ModManager.java index 1cf04b98f..b61f98048 100644 --- a/src/main/java/com/gmail/nossr50/util/ModManager.java +++ b/src/main/java/com/gmail/nossr50/util/ModManager.java @@ -22,36 +22,36 @@ import java.util.HashMap; import java.util.List; public class ModManager { - private final List repairables = new ArrayList(); + private final List repairables = new ArrayList<>(); // Armor Mods - private final List customBoots = new ArrayList(); - private final List customChestplates = new ArrayList(); - private final List customHelmets = new ArrayList(); - private final List customLeggings = new ArrayList(); + private final List customBoots = new ArrayList<>(); + private final List customChestplates = new ArrayList<>(); + private final List customHelmets = new ArrayList<>(); + private final List customLeggings = new ArrayList<>(); // Block Mods - private final List customExcavationBlocks = new ArrayList(); - private final List customHerbalismBlocks = new ArrayList(); - private final List customMiningBlocks = new ArrayList(); - private final List customOres = new ArrayList(); - private final List customLogs = new ArrayList(); - private final List customLeaves = new ArrayList(); - private final List customAbilityBlocks = new ArrayList(); + private final List customExcavationBlocks = new ArrayList<>(); + private final List customHerbalismBlocks = new ArrayList<>(); + private final List customMiningBlocks = new ArrayList<>(); + private final List customOres = new ArrayList<>(); + private final List customLogs = new ArrayList<>(); + private final List customLeaves = new ArrayList<>(); + private final List customAbilityBlocks = new ArrayList<>(); private final HashMap customBlockMap = new HashMap<>(); // Entity Mods - private final HashMap customEntityClassMap = new HashMap(); - private final HashMap customEntityTypeMap = new HashMap(); + private final HashMap customEntityClassMap = new HashMap<>(); + private final HashMap customEntityTypeMap = new HashMap<>(); // Tool Mods - private final List customAxes = new ArrayList(); - private final List customBows = new ArrayList(); - private final List customHoes = new ArrayList(); - private final List customPickaxes = new ArrayList(); - private final List customShovels = new ArrayList(); - private final List customSwords = new ArrayList(); - private final HashMap customToolMap = new HashMap(); + private final List customAxes = new ArrayList<>(); + private final List customBows = new ArrayList<>(); + private final List customHoes = new ArrayList<>(); + private final List customPickaxes = new ArrayList<>(); + private final List customShovels = new ArrayList<>(); + private final List customSwords = new ArrayList<>(); + private final HashMap customToolMap = new HashMap<>(); public void registerCustomArmor(CustomArmorConfig config) { customBoots.addAll(config.customBoots); diff --git a/src/main/java/com/gmail/nossr50/util/adapter/BiomeAdapter.java b/src/main/java/com/gmail/nossr50/util/adapter/BiomeAdapter.java index 2de65c9fc..b9d19e6eb 100644 --- a/src/main/java/com/gmail/nossr50/util/adapter/BiomeAdapter.java +++ b/src/main/java/com/gmail/nossr50/util/adapter/BiomeAdapter.java @@ -10,8 +10,8 @@ public class BiomeAdapter { static { List allBiomes = Arrays.asList(Biome.values()); - List waterBiomes = new ArrayList(); - List iceBiomes = new ArrayList(); + List waterBiomes = new ArrayList<>(); + List iceBiomes = new ArrayList<>(); for (Biome biome : allBiomes) { if (isWater(biome.name()) && !isCold(biome.name())) { waterBiomes.add(biome); diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java index 0302f5de3..c2fc23faf 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java @@ -8,7 +8,7 @@ import java.io.*; import java.util.HashMap; public class HashChunkletManager implements ChunkletManager { - public HashMap store = new HashMap(); + public HashMap store = new HashMap<>(); @Override public void loadChunklet(int cx, int cy, int cz, World world) { diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/NullChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/NullChunkletManager.java index 89bd46967..304ef8780 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/NullChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/NullChunkletManager.java @@ -11,57 +11,46 @@ import org.bukkit.block.Block; public class NullChunkletManager implements ChunkletManager { @Override public void loadChunklet(int cx, int cy, int cz, World world) { - return; } @Override public void unloadChunklet(int cx, int cy, int cz, World world) { - return; } @Override public void loadChunk(int cx, int cz, World world) { - return; } @Override public void unloadChunk(int cx, int cz, World world) { - return; } @Override public void chunkLoaded(int cx, int cz, World world) { - return; } @Override public void chunkUnloaded(int cx, int cz, World world) { - return; } @Override public void saveWorld(World world) { - return; } @Override public void unloadWorld(World world) { - return; } @Override public void loadWorld(World world) { - return; } @Override public void saveAll() { - return; } @Override public void unloadAll() { - return; } @Override @@ -76,26 +65,21 @@ public class NullChunkletManager implements ChunkletManager { @Override public void setTrue(int x, int y, int z, World world) { - return; } @Override public void setTrue(Block block) { - return; } @Override public void setFalse(int x, int y, int z, World world) { - return; } @Override public void setFalse(Block block) { - return; } @Override public void cleanUp() { - return; } } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java index 13e93ebd3..05153816f 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java @@ -11,10 +11,10 @@ import java.io.*; import java.util.*; public class HashChunkManager implements ChunkManager { - private final HashMap> regionFiles = new HashMap>(); - public HashMap store = new HashMap(); - public ArrayList converters = new ArrayList(); - private final HashMap oldData = new HashMap(); + private final HashMap> regionFiles = new HashMap<>(); + public HashMap store = new HashMap<>(); + public ArrayList converters = new ArrayList<>(); + private final HashMap oldData = new HashMap<>(); @Override public synchronized void closeAll() { @@ -38,31 +38,19 @@ public class HashChunkManager implements ChunkManager { if (in == null) { return null; } - ObjectInputStream objectStream = new ObjectInputStream(in); - try { + try (ObjectInputStream objectStream = new ObjectInputStream(in)) { Object o = objectStream.readObject(); if (o instanceof ChunkStore) { return (ChunkStore) o; } throw new RuntimeException("Wrong class type read for chunk meta data for " + x + ", " + z); - } - catch (IOException e) { + } catch (IOException | ClassNotFoundException e) { e.printStackTrace(); // Assume the format changed return null; //throw new RuntimeException("Unable to process chunk meta data for " + x + ", " + z, e); } - catch (ClassNotFoundException e) { - e.printStackTrace(); - // Assume the format changed - //System.out.println("[SpoutPlugin] is Unable to find serialized class for " + x + ", " + z + ", " + e.getMessage()); - return null; - //throw new RuntimeException("Unable to find serialized class for " + x + ", " + z, e); - } - finally { - objectStream.close(); - } } @Override @@ -98,7 +86,7 @@ public class HashChunkManager implements ChunkManager { UUID key = world.getUID(); - HashMap worldRegions = regionFiles.computeIfAbsent(key, k -> new HashMap()); + HashMap worldRegions = regionFiles.computeIfAbsent(key, k -> new HashMap<>()); int rx = x >> 5; int rz = z >> 5; @@ -217,7 +205,7 @@ public class HashChunkManager implements ChunkManager { closeAll(); String worldName = world.getName(); - List keys = new ArrayList(store.keySet()); + List keys = new ArrayList<>(store.keySet()); for (String key : keys) { String[] info = key.split(","); if (worldName.equals(info[0])) { @@ -239,7 +227,7 @@ public class HashChunkManager implements ChunkManager { String worldName = world.getName(); - List keys = new ArrayList(store.keySet()); + List keys = new ArrayList<>(store.keySet()); for (String key : keys) { String[] info = key.split(","); if (worldName.equals(info[0])) { diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java index b3646e5fb..2193417d8 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/McMMOSimpleRegionFile.java @@ -29,7 +29,7 @@ public class McMMOSimpleRegionFile { private final int[] dataStart = new int[1024]; private final int[] dataActualLength = new int[1024]; private final int[] dataLength = new int[1024]; - private final ArrayList inuse = new ArrayList(); + private final ArrayList inuse = new ArrayList<>(); private int segmentSize; private int segmentMask; private final int rx; diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java index 96b2f6b16..9dcb20c2a 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java @@ -28,7 +28,6 @@ public class BlockStoreConversionMain implements Runnable { } this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); - return; } @Override @@ -87,6 +86,5 @@ public class BlockStoreConversionMain implements Runnable { this.world = null; this.scheduler = null; this.converters = null; - return; } } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java index c05beb8ab..a64eec843 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java @@ -29,7 +29,6 @@ public class BlockStoreConversionXDirectory implements Runnable { } this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); - return; } @Override diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java index 5c182b55b..4a32a679c 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java @@ -42,7 +42,6 @@ public class BlockStoreConversionZDirectory implements Runnable { } this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); - return; } @Override diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java index 744ca5aae..125c6abba 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java @@ -199,7 +199,7 @@ public final class CommandRegistrationManager { } private static void registerXprateCommand() { - List aliasList = new ArrayList(); + List aliasList = new ArrayList<>(); aliasList.add("mcxprate"); PluginCommand command = mcMMO.p.getCommand("xprate"); diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java index ab938f20e..84d96680d 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java @@ -106,7 +106,7 @@ public final class CommandUtils { } public static boolean hasPlayerDataKey(CommandSender sender) { - if (sender == null || !(sender instanceof Player)) { + if (!(sender instanceof Player)) { return false; } @@ -221,7 +221,7 @@ public final class CommandUtils { PlayerProfile profile = UserManager.getPlayer(inspect).getProfile(); - List displayData = new ArrayList(); + List displayData = new ArrayList<>(); displayData.add(header); for (PrimarySkillType skill : skillGroup) { @@ -239,7 +239,7 @@ public final class CommandUtils { public static List getOnlinePlayerNames(CommandSender sender) { Player player = sender instanceof Player ? (Player) sender : null; - List onlinePlayerNames = new ArrayList(); + List onlinePlayerNames = new ArrayList<>(); for (Player onlinePlayer : mcMMO.p.getServer().getOnlinePlayers()) { if (player != null && player.canSee(onlinePlayer)) { @@ -286,7 +286,7 @@ public final class CommandUtils { * @return List of all possible names */ private static List matchPlayer(String partialName) { - List matchedPlayers = new ArrayList(); + List matchedPlayers = new ArrayList<>(); for (OfflinePlayer offlinePlayer : mcMMO.p.getServer().getOfflinePlayers()) { String playerName = offlinePlayer.getName(); diff --git a/src/main/java/com/gmail/nossr50/util/compat/layers/DummyPlayerAttackCooldownExploitPreventionLayer.java b/src/main/java/com/gmail/nossr50/util/compat/layers/DummyPlayerAttackCooldownExploitPreventionLayer.java index cf9e3ee7f..79b67138f 100644 --- a/src/main/java/com/gmail/nossr50/util/compat/layers/DummyPlayerAttackCooldownExploitPreventionLayer.java +++ b/src/main/java/com/gmail/nossr50/util/compat/layers/DummyPlayerAttackCooldownExploitPreventionLayer.java @@ -28,6 +28,5 @@ public class DummyPlayerAttackCooldownExploitPreventionLayer extends PlayerAttac @Override public void resetAttackStrength(Player player) throws InvocationTargetException, IllegalAccessException { //Do nothing - return; } } diff --git a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java index 3926ff9ad..3c7ff308f 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java @@ -116,9 +116,9 @@ public class FormulaManager { * @return amount of experience needed to reach next level */ public int getXPtoNextLevel(int level, FormulaType formulaType) { - /** - * Retro mode XP requirements are the default requirements - * Standard mode XP requirements are multiplied by a factor of 10 + /* + Retro mode XP requirements are the default requirements + Standard mode XP requirements are multiplied by a factor of 10 */ //TODO: When the heck is Unknown used? diff --git a/src/main/java/com/gmail/nossr50/util/player/UserManager.java b/src/main/java/com/gmail/nossr50/util/player/UserManager.java index 396770c58..4ef9606b6 100644 --- a/src/main/java/com/gmail/nossr50/util/player/UserManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/UserManager.java @@ -33,7 +33,7 @@ public final class UserManager { } public static void cleanupPlayer(McMMOPlayer mcMMOPlayer) { - if(playerDataSet != null && playerDataSet.contains(mcMMOPlayer)) + if(playerDataSet != null) playerDataSet.remove(mcMMOPlayer); } @@ -47,7 +47,7 @@ public final class UserManager { mcMMOPlayer.cleanup(); player.removeMetadata(mcMMO.playerDataKey, mcMMO.p); - if(playerDataSet != null && playerDataSet.contains(mcMMOPlayer)) { + if(playerDataSet != null) { playerDataSet.remove(mcMMOPlayer); //Clear sync save tracking } } @@ -91,7 +91,7 @@ public final class UserManager { } public static Collection getPlayers() { - Collection playerCollection = new ArrayList(); + Collection playerCollection = new ArrayList<>(); for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { if (hasPlayerDataKey(player)) { diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java index d07a8ef08..7e5aa65b5 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -25,7 +25,7 @@ import java.util.*; * Manages the Scoreboards used to display a variety of mcMMO related information to the player */ public class ScoreboardManager { - static final Map PLAYER_SCOREBOARDS = new HashMap(); + static final Map PLAYER_SCOREBOARDS = new HashMap<>(); // do not localize; these are internal identifiers static final String SIDEBAR_OBJECTIVE = "mcmmo_sidebar"; @@ -130,7 +130,7 @@ public class ScoreboardManager { abilityLabelsSkill = abilityLabelSkillBuilder.build(); } - private static final List dirtyPowerLevels = new ArrayList(); + private static final List dirtyPowerLevels = new ArrayList<>(); public enum SidebarType { NONE, diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java index 5223bbce1..9d675e71b 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java @@ -235,8 +235,8 @@ public class ScoreboardWrapper { if (oldBoard != null) { if (player.getScoreboard() == scoreboard) { - /** - * Call the revert scoreboard custom event + /* + Call the revert scoreboard custom event */ McMMOScoreboardRevertEvent event = new McMMOScoreboardRevertEvent(oldBoard, player.getScoreboard(), player, ScoreboardEventReason.REVERTING_BOARD); player.getServer().getPluginManager().callEvent(event); diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 7f38a45ae..07f0c392d 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -866,7 +866,7 @@ public final class CombatUtils { @Deprecated public static double getFakeDamageFinalResult(Entity attacker, Entity target, double damage) { - return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap(ImmutableMap.of(DamageModifier.BASE, damage))); + return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage))); } @Deprecated @@ -912,7 +912,7 @@ public final class CombatUtils { } private static Map getModifiers(EntityDamageEvent event) { - Map modifiers = new HashMap(); + Map modifiers = new HashMap<>(); for (DamageModifier modifier : DamageModifier.values()) { modifiers.put(modifier, event.getDamage(modifier)); } @@ -921,7 +921,7 @@ public final class CombatUtils { } private static Map getScaledModifiers(double damage, Map modifiers) { - Map scaledModifiers = new HashMap(); + Map scaledModifiers = new HashMap<>(); for (DamageModifier modifier : modifiers.keySet()) { if (modifier == DamageModifier.BASE) { diff --git a/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java index 807b6fb5c..40fad662b 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/ParticleEffectUtils.java @@ -85,19 +85,8 @@ public final class ParticleEffectUtils { livingEntity.getWorld().playEffect(livingEntity.getEyeLocation(), Effect.MOBSPAWNER_FLAMES, 1); } - public static void playAbilityEnabledEffect(Player player) { - if (!Config.getInstance().getAbilityActivationEffectEnabled()) { - return; - } - - /* if (hasHeadRoom(player)) { - fireworkParticleShower(player, Color.GREEN); - }*/ - } - public static void playAbilityDisabledEffect(Player player) { if (!Config.getInstance().getAbilityDeactivationEffectEnabled()) { - return; } /*if (hasHeadRoom(player)) { diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index a539c8bae..35e0dca39 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -142,7 +142,7 @@ public class SkillUtils { int efficiencyLevel = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED); ItemMeta itemMeta = heldItem.getItemMeta(); - List itemLore = new ArrayList(); + List itemLore = new ArrayList<>(); if (itemMeta.hasLore()) { itemLore = itemMeta.getLore(); diff --git a/src/main/java/com/gmail/nossr50/worldguard/WorldGuardManager.java b/src/main/java/com/gmail/nossr50/worldguard/WorldGuardManager.java index 51ccc8605..3e4ea3386 100644 --- a/src/main/java/com/gmail/nossr50/worldguard/WorldGuardManager.java +++ b/src/main/java/com/gmail/nossr50/worldguard/WorldGuardManager.java @@ -76,7 +76,7 @@ public class WorldGuardManager { Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard"); // WorldGuard may not be loaded - if (plugin == null || !(plugin instanceof WorldGuardPlugin)) { + if (!(plugin instanceof WorldGuardPlugin)) { return null; // Maybe you want throw an exception instead } diff --git a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java index 67e797ef0..e60c8554b 100644 --- a/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java +++ b/src/main/java/net/shatteredlands/shatt/backup/ZipLibrary.java @@ -47,7 +47,7 @@ public class ZipLibrary { File fileZip = new File(BACKUP_DIRECTORY + File.separator + dateFormat.format(date) + ".zip"); // Create the Source List, and add directories/etc to the file. - List sources = new ArrayList(); + List sources = new ArrayList<>(); sources.add(FLAT_FILE_DIRECTORY); sources.add(CONFIG_FILE); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4fe07127c..5ac02a3c4 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -536,6 +536,16 @@ Bonus_Drops: Jungle_Log: true Spruce_Wood: true Spruce_Log: true + Smelting: + Iron_Ingot: true + Gold_Ingot: true + Emerald: true + Diamond: true + Lapis_Lazuli: true + Coal: true + Nether_Quartz: true + Quartz: true + Redstone: true # # Settings for commands From f6c7049cac76a1c68348e9e570a7617c45747af0 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 13 Jul 2020 13:16:47 -0700 Subject: [PATCH 06/15] Furnaces can now change owners during server lifespan for Smelting XP --- Changelog.txt | 17 +- .../nossr50/listeners/InventoryListener.java | 180 +++++++++++------- 2 files changed, 127 insertions(+), 70 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 0fcacba94..fbb3d3b22 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,7 +1,9 @@ Version 2.1.134 - Minor code cleanup + Smelting furnaces are now more flexible about who they consider their owner (see notes) Smelting now has a Bonus Drops section in config.yml - Smelting now only doubles smelting results for items which have bonus drop entries in the config + Smelting now only doubles smelting results for items which have bonus drop entries in config.yml + Minor code cleanup + Changed the UUID updater task to not catastrophically fail when requests failed Fixed a bug where players could set each other on fire when partied or when PVP was disabled Fixed a NPE that could happen with thrown potions Fixed a potential NPE when damaging player armor with Axes @@ -13,7 +15,16 @@ Version 2.1.134 Fixed a potential NPE when players right click blocks Fixed a locale mistake in locale hu_HU Fixed a locale mistake in locale ru - Changed the UUID updater task to not catastrophically fail when requests failed + + NOTES: + Furnaces give XP to their owner while smelting + You become the owner of a Furnace by doing one of the following + 1) Opening an empty furnace + 2) Interacting with a furnace + + It used to be that Furnaces would assign an owner and that would be their owner until the server shutdown, now owners will change based on who last had their hands on the furnace. + + You won't become the owner if you are not allowed to view the inventory of a furnace Version 2.1.133 A fix for an 'array out of bounds' error related to players clicking outside the inventory windows has been fixed diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index bc21c4b69..0cc7fd227 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -29,6 +29,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.inventory.*; import org.bukkit.inventory.*; import org.bukkit.metadata.MetadataValue; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -45,26 +46,57 @@ public class InventoryListener implements Listener { if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) return; - Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory()); - - if (furnaceBlock == null) { - return; - } - - HumanEntity player = event.getPlayer(); - - if (!UserManager.hasPlayerDataKey(player)) { - return; - } + HumanEntity humanEntity = event.getPlayer(); + Player player = (Player) humanEntity; //Profile not loaded - if(UserManager.getPlayer((Player) player) == null) + if(UserManager.getPlayer(player) == null) { return; } - if(!furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() == 0) - furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer((Player) player).getPlayerMetadata()); + if(event.getInventory() instanceof Furnace) { + + } + Furnace furnace = getFurnace(event.getInventory()); + + if (furnace != null) { + if(isFurnaceAvailable(furnace, player)) { + assignFurnace(furnace, player); + } + } + } + + public boolean isFurnaceAvailable(Furnace furnace, Player player) { + if(!furnace.hasMetadata(mcMMO.furnaceMetadataKey) + && furnace.getMetadata(mcMMO.furnaceMetadataKey).size() == 0) { + return true; + } else { + if(player != getPlayerFromFurnace(furnace)) { + + if(isFurnaceResultEmpty(furnace)) { + return true; + } else { + return false; + } + } + } + + return false; + } + + public boolean isFurnaceResultEmpty(Furnace furnace) { + return furnace.getInventory().getResult() == null; + } + + public void assignFurnace(Furnace furnace, Player player) { + + if(furnace.hasMetadata(mcMMO.furnaceMetadataKey)) { + furnace.removeMetadata(mcMMO.furnaceMetadataKey, mcMMO.p); + } + + furnace.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer(player).getPlayerMetadata()); + } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -73,19 +105,15 @@ public class InventoryListener implements Listener { if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) return; - Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory()); + if(event.getInventory() instanceof FurnaceInventory) { + if(getFurnace(event.getInventory()) != null) { + Furnace furnace = getFurnace(event.getInventory()); - if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) { - return; + if(isFurnaceOwned(furnace) && isFurnaceResultEmpty(furnace)) { + removeFurnaceOwner(furnace); + } + } } - - HumanEntity player = event.getPlayer(); - - if (!UserManager.hasPlayerDataKey(player)) { - return; - } - - furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, plugin); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -102,7 +130,9 @@ public class InventoryListener implements Listener { return; } - Player player = getPlayerFromFurnace(furnaceBlock); + Furnace furnace = (Furnace) furnaceState; + + Player player = getPlayerFromFurnace(furnace); /* WORLD GUARD MAIN FLAG CHECK */ if(WorldGuardUtils.isWorldGuardLoaded()) @@ -137,26 +167,29 @@ public class InventoryListener implements Listener { return; } - Player player = getPlayerFromFurnace(furnaceBlock); - - /* WORLD GUARD MAIN FLAG CHECK */ - if(WorldGuardUtils.isWorldGuardLoaded()) + if(furnaceBlock instanceof Furnace) { - if(!WorldGuardManager.getInstance().hasMainFlag(player)) + Player player = getPlayerFromFurnace((Furnace) furnaceBlock); + + /* WORLD GUARD MAIN FLAG CHECK */ + if(WorldGuardUtils.isWorldGuardLoaded()) + { + if(!WorldGuardManager.getInstance().hasMainFlag(player)) + return; + } + + if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.SMELTING.getPermissions(player)) { return; - } + } - if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.SMELTING.getPermissions(player)) { - return; - } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } - //Profile not loaded - if(UserManager.getPlayer(player) == null) - { - return; + event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(smelting, event.getResult())); } - - event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(smelting, event.getResult())); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -171,28 +204,31 @@ public class InventoryListener implements Listener { return; } - Player player = getPlayerFromFurnace(furnaceBlock); + if(furnaceBlock instanceof Furnace) { + Furnace furnace = (Furnace) furnaceBlock; + Player player = getPlayerFromFurnace(furnace); - /* WORLD GUARD MAIN FLAG CHECK */ - if(WorldGuardUtils.isWorldGuardLoaded()) - { - if(!WorldGuardManager.getInstance().hasMainFlag(player)) + /* WORLD GUARD MAIN FLAG CHECK */ + if(WorldGuardUtils.isWorldGuardLoaded()) + { + if(!WorldGuardManager.getInstance().hasMainFlag(player)) + return; + } + + if (!UserManager.hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, PrimarySkillType.SMELTING)) { return; - } + } - if (!UserManager.hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, PrimarySkillType.SMELTING)) { - return; - } + //Profile not loaded + if(UserManager.getPlayer(player) == null) + { + return; + } - //Profile not loaded - if(UserManager.getPlayer(player) == null) - { - return; + int xpToDrop = event.getExpToDrop(); + int exp = UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(xpToDrop); + event.setExpToDrop(exp); } - - int xpToDrop = event.getExpToDrop(); - int exp = UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(xpToDrop); - event.setExpToDrop(exp); } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @@ -206,12 +242,13 @@ public class InventoryListener implements Listener { if(event.getWhoClicked() instanceof Player) { Player player = ((Player) event.getWhoClicked()).getPlayer(); - Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory()); + Furnace furnace = getFurnace(event.getInventory()); - if (furnaceBlock != null) + if (furnace != null) { - if (furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() > 0) - furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, mcMMO.p); + if (isFurnaceOwned(furnace)) { + removeFurnaceOwner(furnace); + } //Profile not loaded if(UserManager.getPlayer(player) == null) @@ -219,7 +256,7 @@ public class InventoryListener implements Listener { return; } - furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer(player).getPlayerMetadata()); + assignFurnace(furnace, player); } } @@ -325,6 +362,14 @@ public class InventoryListener implements Listener { } } + public boolean isFurnaceOwned(Furnace furnace) { + return furnace.getMetadata(mcMMO.furnaceMetadataKey).size() > 0; + } + + public void removeFurnaceOwner(Furnace furnace) { + furnace.removeMetadata(mcMMO.furnaceMetadataKey, mcMMO.p); + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onInventoryDragEvent(InventoryDragEvent event) { /* WORLD BLACKLIST CHECK */ @@ -480,7 +525,7 @@ public class InventoryListener implements Listener { new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0); } - private Block processInventoryOpenOrCloseEvent(Inventory inventory) { + private Furnace getFurnace(Inventory inventory) { if (!(inventory instanceof FurnaceInventory)) { return null; } @@ -491,11 +536,12 @@ public class InventoryListener implements Listener { return null; } - return furnace.getBlock(); + return furnace; } - private Player getPlayerFromFurnace(Block furnaceBlock) { - List metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey); + @Nullable + private Player getPlayerFromFurnace(Furnace furnace) { + List metadata = furnace.getMetadata(mcMMO.furnaceMetadataKey); if (metadata.isEmpty()) { return null; From 16d7b51497334f5a263f494682c7f05ebab429aa Mon Sep 17 00:00:00 2001 From: Ulrich Fink Date: Tue, 21 Jul 2020 22:49:32 +0200 Subject: [PATCH 07/15] Fix brewing stand not consuming items Fixes #4225 Negation in commit fdd951f1f1890d4bcb62fb6d44fd576df63ad8f is faulty. --- .../com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java index 30f93ebd6..f42584b25 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -61,7 +61,7 @@ public final class AlchemyPotionBrewer { ItemStack ingredient = inventory.getIngredient().clone(); - if (isEmpty(ingredient) && !isValidIngredient(player, ingredient)) { + if (!isEmpty(ingredient) && isValidIngredient(player, ingredient)) { if (ingredient.getAmount() <= 1) { inventory.setIngredient(null); } From 35cde870ffd33151b2d469451731feb7c2f1b0d2 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 23 Jul 2020 20:59:34 -0700 Subject: [PATCH 08/15] Reworked a lot of stuff to do with Smelting --- Changelog.txt | 10 +- .../nossr50/listeners/BlockListener.java | 16 +- .../nossr50/listeners/InventoryListener.java | 218 ++++-------------- src/main/java/com/gmail/nossr50/mcMMO.java | 10 +- .../runnables/skills/FurnaceCleanupTask.java | 22 ++ .../nossr50/skills/smelting/Smelting.java | 20 +- .../nossr50/util/skills/SmeltingTracker.java | 65 ++++++ 7 files changed, 165 insertions(+), 196 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/runnables/skills/FurnaceCleanupTask.java create mode 100644 src/main/java/com/gmail/nossr50/util/skills/SmeltingTracker.java diff --git a/Changelog.txt b/Changelog.txt index fbb3d3b22..9aa772a11 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,5 @@ Version 2.1.134 - Smelting furnaces are now more flexible about who they consider their owner (see notes) + Furnaces now change ownership to the last player who clicks in their inventory and is legally allowed to break the furnace Smelting now has a Bonus Drops section in config.yml Smelting now only doubles smelting results for items which have bonus drop entries in config.yml Minor code cleanup @@ -17,14 +17,8 @@ Version 2.1.134 Fixed a locale mistake in locale ru NOTES: - Furnaces give XP to their owner while smelting - You become the owner of a Furnace by doing one of the following - 1) Opening an empty furnace - 2) Interacting with a furnace - It used to be that Furnaces would assign an owner and that would be their owner until the server shutdown, now owners will change based on who last had their hands on the furnace. - - You won't become the owner if you are not allowed to view the inventory of a furnace + You won't become the owner if you are not allowed to view the inventory of a furnace, or break the furnace, or interact with the contents of the furnace Version 2.1.133 A fix for an 'array out of bounds' error related to players clicking outside the inventory windows has been fixed diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 7f751502e..6fee064e9 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -18,6 +18,7 @@ import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.salvage.Salvage; +import com.gmail.nossr50.skills.smelting.Smelting; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.EventUtils; @@ -535,16 +536,6 @@ public class BlockListener implements Listener { } } - private Player getPlayerFromFurnace(Block furnaceBlock) { - List metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey); - - if (metadata.isEmpty()) { - return null; - } - - return plugin.getServer().getPlayerExact(metadata.get(0).asString()); - } - /** * Handle BlockDamage events where the event is modified. * @@ -628,7 +619,6 @@ public class BlockListener implements Listener { return; } - BlockState blockState = event.getBlock().getState(); ItemStack heldItem = player.getInventory().getItemInMainHand(); @@ -673,10 +663,10 @@ public class BlockListener implements Listener { if(blockState instanceof Furnace) { Furnace furnace = (Furnace) blockState; - if(furnace.hasMetadata(mcMMO.furnaceMetadataKey)) + if(mcMMO.getSmeltingTracker().isFurnaceOwned(furnace)) { player.sendMessage("[mcMMO DEBUG] This furnace has a registered owner"); - Player furnacePlayer = getPlayerFromFurnace(furnace.getBlock()); + OfflinePlayer furnacePlayer = mcMMO.getSmeltingTracker().getPlayerFromFurnace(furnace); if(furnacePlayer != null) { player.sendMessage("[mcMMO DEBUG] This furnace is owned by player "+furnacePlayer.getName()); diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 0cc7fd227..196131717 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -2,11 +2,13 @@ package com.gmail.nossr50.listeners; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.WorldBlacklist; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.events.fake.FakeBrewEvent; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask; +import com.gmail.nossr50.runnables.skills.FurnaceCleanupTask; import com.gmail.nossr50.skills.alchemy.Alchemy; import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer; import com.gmail.nossr50.util.ItemUtils; @@ -15,8 +17,10 @@ import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.BrewingStand; @@ -28,10 +32,6 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.inventory.*; import org.bukkit.inventory.*; -import org.bukkit.metadata.MetadataValue; -import org.jetbrains.annotations.Nullable; - -import java.util.List; public class InventoryListener implements Listener { private final mcMMO plugin; @@ -40,82 +40,6 @@ public class InventoryListener implements Listener { this.plugin = plugin; } - @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void onInventoryOpen(InventoryOpenEvent event) { - /* WORLD BLACKLIST CHECK */ - if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) - return; - - HumanEntity humanEntity = event.getPlayer(); - Player player = (Player) humanEntity; - - //Profile not loaded - if(UserManager.getPlayer(player) == null) - { - return; - } - - if(event.getInventory() instanceof Furnace) { - - } - Furnace furnace = getFurnace(event.getInventory()); - - if (furnace != null) { - if(isFurnaceAvailable(furnace, player)) { - assignFurnace(furnace, player); - } - } - } - - public boolean isFurnaceAvailable(Furnace furnace, Player player) { - if(!furnace.hasMetadata(mcMMO.furnaceMetadataKey) - && furnace.getMetadata(mcMMO.furnaceMetadataKey).size() == 0) { - return true; - } else { - if(player != getPlayerFromFurnace(furnace)) { - - if(isFurnaceResultEmpty(furnace)) { - return true; - } else { - return false; - } - } - } - - return false; - } - - public boolean isFurnaceResultEmpty(Furnace furnace) { - return furnace.getInventory().getResult() == null; - } - - public void assignFurnace(Furnace furnace, Player player) { - - if(furnace.hasMetadata(mcMMO.furnaceMetadataKey)) { - furnace.removeMetadata(mcMMO.furnaceMetadataKey, mcMMO.p); - } - - furnace.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer(player).getPlayerMetadata()); - - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onInventoryClose(InventoryCloseEvent event) { - /* WORLD BLACKLIST CHECK */ - if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) - return; - - if(event.getInventory() instanceof FurnaceInventory) { - if(getFurnace(event.getInventory()) != null) { - Furnace furnace = getFurnace(event.getInventory()); - - if(isFurnaceOwned(furnace) && isFurnaceResultEmpty(furnace)) { - removeFurnaceOwner(furnace); - } - } - } - } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFurnaceBurnEvent(FurnaceBurnEvent event) { /* WORLD BLACKLIST CHECK */ @@ -132,26 +56,27 @@ public class InventoryListener implements Listener { Furnace furnace = (Furnace) furnaceState; - Player player = getPlayerFromFurnace(furnace); + OfflinePlayer offlinePlayer = mcMMO.getSmeltingTracker().getPlayerFromFurnace(furnace); - /* WORLD GUARD MAIN FLAG CHECK */ - if(WorldGuardUtils.isWorldGuardLoaded()) - { - if(!WorldGuardManager.getInstance().hasMainFlag(player)) - return; + if(offlinePlayer != null && offlinePlayer.isOnline()) { + + Player player = Bukkit.getPlayer(offlinePlayer.getUniqueId()); + + if(player != null) { + if (!Permissions.isSubSkillEnabled(player, SubSkillType.SMELTING_FUEL_EFFICIENCY)) { + return; + } + + //Profile doesn't exist + if(UserManager.getOfflinePlayer(offlinePlayer) == null) + { + return; + } + + event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime())); + } } - if (!UserManager.hasPlayerDataKey(player) || !Permissions.isSubSkillEnabled(player, SubSkillType.SMELTING_FUEL_EFFICIENCY)) { - return; - } - - //Profile not loaded - if(UserManager.getPlayer(player) == null) - { - return; - } - - event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime())); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -160,35 +85,28 @@ public class InventoryListener implements Listener { if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) return; - Block furnaceBlock = event.getBlock(); + BlockState blockState = event.getBlock().getState(); //Furnaces can only be cast from a BlockState not a Block ItemStack smelting = event.getSource(); if (!ItemUtils.isSmeltable(smelting)) { return; } - if(furnaceBlock instanceof Furnace) - { - Player player = getPlayerFromFurnace((Furnace) furnaceBlock); + if(blockState instanceof Furnace) { + Furnace furnace = (Furnace) blockState; + OfflinePlayer offlinePlayer = mcMMO.getSmeltingTracker().getPlayerFromFurnace(furnace); - /* WORLD GUARD MAIN FLAG CHECK */ - if(WorldGuardUtils.isWorldGuardLoaded()) - { - if(!WorldGuardManager.getInstance().hasMainFlag(player)) - return; + if(offlinePlayer != null) { + + McMMOPlayer offlineProfile = UserManager.getOfflinePlayer(offlinePlayer); + + //Profile doesn't exist + if(offlineProfile != null) { + event.setResult(offlineProfile.getSmeltingManager().smeltProcessing(smelting, event.getResult())); + } } - if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.SMELTING.getPermissions(player)) { - return; - } - - //Profile not loaded - if(UserManager.getPlayer(player) == null) - { - return; - } - - event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(smelting, event.getResult())); + new FurnaceCleanupTask(furnace).runTaskLater(mcMMO.p, 1); } } @@ -198,16 +116,15 @@ public class InventoryListener implements Listener { if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) return; - Block furnaceBlock = event.getBlock(); + BlockState furnaceBlock = event.getBlock().getState(); if (!ItemUtils.isSmelted(new ItemStack(event.getItemType(), event.getItemAmount()))) { return; } - if(furnaceBlock instanceof Furnace) { - Furnace furnace = (Furnace) furnaceBlock; - Player player = getPlayerFromFurnace(furnace); + Player player = event.getPlayer(); + if(furnaceBlock instanceof Furnace) { /* WORLD GUARD MAIN FLAG CHECK */ if(WorldGuardUtils.isWorldGuardLoaded()) { @@ -237,26 +154,22 @@ public class InventoryListener implements Listener { if(WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld())) return; + //We should never care to do processing if the player clicks outside the window +// if(isOutsideWindowClick(event)) +// return; + Inventory inventory = event.getInventory(); - if(event.getWhoClicked() instanceof Player) + Player player = ((Player) event.getWhoClicked()).getPlayer(); + + if(event.getInventory() instanceof FurnaceInventory) { - Player player = ((Player) event.getWhoClicked()).getPlayer(); - Furnace furnace = getFurnace(event.getInventory()); + Furnace furnace = mcMMO.getSmeltingTracker().getFurnaceFromInventory(event.getInventory()); if (furnace != null) { - if (isFurnaceOwned(furnace)) { - removeFurnaceOwner(furnace); - } - - //Profile not loaded - if(UserManager.getPlayer(player) == null) - { - return; - } - - assignFurnace(furnace, player); + //Switch owners + mcMMO.getSmeltingTracker().processFurnaceOwnership(furnace, player); } } @@ -276,8 +189,6 @@ public class InventoryListener implements Listener { return; } - Player player = (Player) whoClicked; - /* WORLD GUARD MAIN FLAG CHECK */ if(WorldGuardUtils.isWorldGuardLoaded()) { @@ -362,13 +273,10 @@ public class InventoryListener implements Listener { } } - public boolean isFurnaceOwned(Furnace furnace) { - return furnace.getMetadata(mcMMO.furnaceMetadataKey).size() > 0; + public boolean isOutsideWindowClick(InventoryClickEvent event) { + return event.getHotbarButton() == -1; } - public void removeFurnaceOwner(Furnace furnace) { - furnace.removeMetadata(mcMMO.furnaceMetadataKey, mcMMO.p); - } @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onInventoryDragEvent(InventoryDragEvent event) { @@ -480,7 +388,7 @@ public class InventoryListener implements Listener { public void onInventoryClickEvent(InventoryClickEvent event) { SkillUtils.removeAbilityBuff(event.getCurrentItem()); if (event.getAction() == InventoryAction.HOTBAR_SWAP) { - if(event.getHotbarButton() == -1) + if(isOutsideWindowClick(event)) return; PlayerInventory playerInventory = event.getWhoClicked().getInventory(); @@ -525,28 +433,4 @@ public class InventoryListener implements Listener { new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0); } - private Furnace getFurnace(Inventory inventory) { - if (!(inventory instanceof FurnaceInventory)) { - return null; - } - - Furnace furnace = (Furnace) inventory.getHolder(); - - if (furnace == null) { - return null; - } - - return furnace; - } - - @Nullable - private Player getPlayerFromFurnace(Furnace furnace) { - List metadata = furnace.getMetadata(mcMMO.furnaceMetadataKey); - - if (metadata.isEmpty()) { - return null; - } - - return plugin.getServer().getPlayerExact(metadata.get(0).asString()); - } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 90e16ea7b..697e91439 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -46,6 +46,7 @@ import com.gmail.nossr50.util.player.PlayerLevelUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.skills.RankUtils; +import com.gmail.nossr50.util.skills.SmeltingTracker; import com.gmail.nossr50.util.upgrade.UpgradeManager; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.google.common.base.Charsets; @@ -78,6 +79,7 @@ public class mcMMO extends JavaPlugin { private static UpgradeManager upgradeManager; private static MaterialMapStore materialMapStore; private static PlayerLevelUtils playerLevelUtils; + private static SmeltingTracker smeltingTracker; /* Blacklist */ private static WorldBlacklist worldBlacklist; @@ -116,7 +118,6 @@ public class mcMMO extends JavaPlugin { public static final String COTW_TEMPORARY_SUMMON = "mcMMO: COTW Entity"; public final static String entityMetadataKey = "mcMMO: Spawned Entity"; public final static String blockMetadataKey = "mcMMO: Piston Tracking"; - public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace"; public final static String tntMetadataKey = "mcMMO: Tracked TNT"; public final static String funfettiMetadataKey = "mcMMO: Funfetti"; public final static String customNameKey = "mcMMO: Custom Name"; @@ -266,6 +267,9 @@ public class mcMMO extends JavaPlugin { //Init the blacklist worldBlacklist = new WorldBlacklist(this); + + //Init smelting tracker + smeltingTracker = new SmeltingTracker(); } public static PlayerLevelUtils getPlayerLevelUtils() { @@ -670,4 +674,8 @@ public class mcMMO extends JavaPlugin { public static PlatformManager getPlatformManager() { return platformManager; } + + public static SmeltingTracker getSmeltingTracker() { + return smeltingTracker; + } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/FurnaceCleanupTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/FurnaceCleanupTask.java new file mode 100644 index 000000000..341a51ac4 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/runnables/skills/FurnaceCleanupTask.java @@ -0,0 +1,22 @@ +package com.gmail.nossr50.runnables.skills; + +import com.gmail.nossr50.mcMMO; +import org.bukkit.block.Furnace; +import org.bukkit.scheduler.BukkitRunnable; + +public class FurnaceCleanupTask extends BukkitRunnable { + + private final Furnace furnace; + + public FurnaceCleanupTask(Furnace furnace) { + this.furnace = furnace; + } + + @Override + public void run() { + if(furnace != null && furnace.getInventory().getResult() == null) { + //Furnace is empty so stop tracking it + mcMMO.getSmeltingTracker().untrackFurnace(furnace); + } + } +} diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java b/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java index 11b43d7d8..e196eb4ef 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java @@ -4,19 +4,25 @@ import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.util.EventUtils; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.RankUtils; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.block.Furnace; import org.bukkit.entity.Player; +import org.bukkit.inventory.FurnaceInventory; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.metadata.MetadataValue; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.List; public class Smelting { - public static int getRank(Player player) - { - return RankUtils.getRank(player, SubSkillType.SMELTING_UNDERSTANDING_THE_ART); - } - - //public static int fluxMiningUnlockLevel = RankUtils.getUnlockLevel(SubSkillType.SMELTING_FLUX_MINING); - protected static int getResourceXp(ItemStack smelting) { return mcMMO.getModManager().isCustomOre(smelting.getType()) ? mcMMO.getModManager().getBlock(smelting.getType()).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(PrimarySkillType.SMELTING, smelting.getType()); } diff --git a/src/main/java/com/gmail/nossr50/util/skills/SmeltingTracker.java b/src/main/java/com/gmail/nossr50/util/skills/SmeltingTracker.java new file mode 100644 index 000000000..eb8fa5261 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/util/skills/SmeltingTracker.java @@ -0,0 +1,65 @@ +package com.gmail.nossr50.util.skills; + +import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.skills.smelting.Smelting; +import com.gmail.nossr50.util.EventUtils; +import com.gmail.nossr50.util.Permissions; +import org.bukkit.Bukkit; +import org.bukkit.OfflinePlayer; +import org.bukkit.block.Furnace; +import org.bukkit.entity.Player; +import org.bukkit.inventory.FurnaceInventory; +import org.bukkit.inventory.Inventory; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; + +public class SmeltingTracker { + + private HashMap furnaceOwners; + + public SmeltingTracker() { + furnaceOwners = new HashMap<>(); + } + + private void changeFurnaceOwnership(Furnace furnace, Player player) { + furnaceOwners.put(furnace, player); + } + + @Nullable + public Furnace getFurnaceFromInventory(Inventory inventory) { + if (!(inventory instanceof FurnaceInventory)) { + return null; + } + + return (Furnace) inventory.getHolder(); + } + + @Nullable + public OfflinePlayer getPlayerFromFurnace(Furnace furnace) { + return furnaceOwners.get(furnace); + } + + public boolean isFurnaceOwned(Furnace furnace) { + return furnaceOwners.get(furnace) != null; + } + + public void removeFurnaceOwner(Furnace furnace) { + furnaceOwners.remove(furnace); + } + + public void processFurnaceOwnership(Furnace furnace, Player player) { + if(!Permissions.skillEnabled(player, PrimarySkillType.SMELTING)) + return; + + //If the player is legally allowed to break the block then they can steal ownership + if(EventUtils.simulateBlockBreak(furnace.getBlock(), player, true)) { + changeFurnaceOwnership(furnace, player); + } + } + + public void untrackFurnace(Furnace furnace) { + furnaceOwners.remove(furnace); + } +} From 2910240942ea1af500cb8880ea5acf821f86e400 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Thu, 23 Jul 2020 21:16:58 -0700 Subject: [PATCH 09/15] 2.1.134 --- Changelog.txt | 4 +++- pom.xml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 9aa772a11..b200d4846 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -2,7 +2,8 @@ Version 2.1.134 Furnaces now change ownership to the last player who clicks in their inventory and is legally allowed to break the furnace Smelting now has a Bonus Drops section in config.yml Smelting now only doubles smelting results for items which have bonus drop entries in config.yml - Minor code cleanup + Smelting XP can now be gained offline, but all other benefits from Smelting don't happen unless you're online + Fix brewing stand not consuming items (thanks Durburz) Changed the UUID updater task to not catastrophically fail when requests failed Fixed a bug where players could set each other on fire when partied or when PVP was disabled Fixed a NPE that could happen with thrown potions @@ -15,6 +16,7 @@ Version 2.1.134 Fixed a potential NPE when players right click blocks Fixed a locale mistake in locale hu_HU Fixed a locale mistake in locale ru + Minor code cleanup NOTES: It used to be that Furnaces would assign an owner and that would be their owner until the server shutdown, now owners will change based on who last had their hands on the furnace. diff --git a/pom.xml b/pom.xml index cea247bd0..01eac409c 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.134-SNAPSHOT + 2.1.134 mcMMO https://github.com/mcMMO-Dev/mcMMO From 054c023330b6ced49090ac17ab16cebb54aea547 Mon Sep 17 00:00:00 2001 From: Ineusia Date: Sat, 25 Jul 2020 10:36:34 -0500 Subject: [PATCH 10/15] Handle Fishing Event even if FishingExploitFix is set to false --- .../gmail/nossr50/listeners/PlayerListener.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 436e6cbc4..dc6423a57 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -396,11 +396,9 @@ public class PlayerListener implements Listener { } return; case CAUGHT_FISH: - if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) - { - if(caught instanceof Item) { - if(fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) - { + if(caught instanceof Item) { + if(ExperienceConfig.getInstance().isFishingExploitingPrevented()) { + if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) { player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", 3)); event.setExpToDrop(0); Item caughtItem = (Item) caught; @@ -408,10 +406,10 @@ public class PlayerListener implements Listener { return; } - - fishingManager.handleFishing((Item) caught); - fishingManager.setFishingTarget(); } + + fishingManager.handleFishing((Item) caught); + fishingManager.setFishingTarget(); } return; case CAUGHT_ENTITY: From 3ae1b5e987c1657acf5631464bd3195753605760 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 25 Jul 2020 08:37:19 -0700 Subject: [PATCH 11/15] Don't simulate block breaks when assigning furnace ownership --- Changelog.txt | 3 +++ pom.xml | 2 +- .../java/com/gmail/nossr50/util/skills/SmeltingTracker.java | 5 +---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index b200d4846..8444ee66b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.1.135 + Furnaces no longer simulate block break checks when assigning ownership as it caused some unwanted plugin conflicts + Version 2.1.134 Furnaces now change ownership to the last player who clicks in their inventory and is legally allowed to break the furnace Smelting now has a Bonus Drops section in config.yml diff --git a/pom.xml b/pom.xml index 01eac409c..51f339764 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.134 + 2.1.135-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/util/skills/SmeltingTracker.java b/src/main/java/com/gmail/nossr50/util/skills/SmeltingTracker.java index eb8fa5261..6fa99bed8 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SmeltingTracker.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SmeltingTracker.java @@ -53,10 +53,7 @@ public class SmeltingTracker { if(!Permissions.skillEnabled(player, PrimarySkillType.SMELTING)) return; - //If the player is legally allowed to break the block then they can steal ownership - if(EventUtils.simulateBlockBreak(furnace.getBlock(), player, true)) { - changeFurnaceOwnership(furnace, player); - } + changeFurnaceOwnership(furnace, player); } public void untrackFurnace(Furnace furnace) { From 36af6d247843a5edde38d4d8d70330442dc3a215 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 25 Jul 2020 08:40:20 -0700 Subject: [PATCH 12/15] update changes --- Changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.txt b/Changelog.txt index 8444ee66b..76d7a784c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,5 @@ Version 2.1.135 + Fixed an issue where Fishing would break if exploit protection was turned off for Fishing (Thanks Ineusia) Furnaces no longer simulate block break checks when assigning ownership as it caused some unwanted plugin conflicts Version 2.1.134 From 5298472c902cc8259eebd4805fc64df1602957f0 Mon Sep 17 00:00:00 2001 From: Ineusia Date: Sat, 25 Jul 2020 11:10:01 -0500 Subject: [PATCH 13/15] Add option to disable other-player ability notifications --- src/main/java/com/gmail/nossr50/config/AdvancedConfig.java | 5 +++++ .../com/gmail/nossr50/datatypes/player/McMMOPlayer.java | 4 +++- .../gmail/nossr50/runnables/skills/AbilityDisableTask.java | 6 ++++-- src/main/resources/advanced.yml | 3 +++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 16cb6f915..615488646 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -718,6 +718,11 @@ public class AdvancedConfig extends AutoUpdateConfigLoader { return config.getBoolean("Feedback.Events.XP.SendTitles", true); } + public boolean sendAbilityNotificationToOtherPlayers() + { + return config.getBoolean("Feedback.Events.AbilityActivation.SendNotificationToOtherPlayers", true); + } + /* * JSON Style Settings */ diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 3f469a0b3..7b3504265 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -907,7 +907,9 @@ public class McMMOPlayer { //player.sendMessage(ability.getAbilityOn()); } - SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayer()); + if (AdvancedConfig.getInstance().sendAbilityNotificationToOtherPlayers()) { + SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayer()); + } //Sounds SoundManager.worldSendSound(player.getWorld(), player.getLocation(), SoundType.ABILITY_ACTIVATED_GENERIC); diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java index 53f05f594..76dd5a401 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.runnables.skills; +import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; @@ -61,8 +62,9 @@ public class AbilityDisableTask extends BukkitRunnable { NotificationManager.sendPlayerInformation(player, NotificationType.ABILITY_OFF, ability.getAbilityOff()); } - - SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff()); + if (AdvancedConfig.getInstance().sendAbilityNotificationToOtherPlayers()) { + SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff()); + } new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR); } diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 6648a3dc7..211ac13cd 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -24,6 +24,9 @@ Feedback: Events: XP: SendTitles: true + # Send notifications to the chat or actionbar of other nearby players when a user activates an ability + AbilityActivation: + SendNotificationToOtherPlayers: true #The actionbar is the message location right above the health bar ## If you disable the action bar messages, mcMMO will send the message to the chat system instead ActionBarNotifications: From 353fb80957b2b6a1d6a7cc361c628413e3085433 Mon Sep 17 00:00:00 2001 From: Ineusia Date: Sat, 25 Jul 2020 12:13:54 -0500 Subject: [PATCH 14/15] Use localized names for SuperAbility names --- .../commands/player/MccooldownCommand.java | 4 +-- .../datatypes/skills/SuperAbilityType.java | 33 ++++++++++++++----- .../util/scoreboards/ScoreboardManager.java | 10 +++--- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java index 7cf6d7589..74011a39c 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java @@ -56,9 +56,9 @@ public class MccooldownCommand implements TabExecutor { int seconds = mcMMOPlayer.calculateTimeRemaining(ability); if (seconds <= 0) { - player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName())); + player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getLocalizedName())); } else { - player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds)); + player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getLocalizedName(), seconds)); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java index cb4b0b10e..66c4957a9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.datatypes.skills; import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.Permissions; @@ -15,49 +16,56 @@ public enum SuperAbilityType { "Unarmed.Skills.Berserk.Off", "Unarmed.Skills.Berserk.Other.On", "Unarmed.Skills.Berserk.Refresh", - "Unarmed.Skills.Berserk.Other.Off"), + "Unarmed.Skills.Berserk.Other.Off", + "Unarmed.SubSkill.Berserk.Name"), SUPER_BREAKER( "Mining.Skills.SuperBreaker.On", "Mining.Skills.SuperBreaker.Off", "Mining.Skills.SuperBreaker.Other.On", "Mining.Skills.SuperBreaker.Refresh", - "Mining.Skills.SuperBreaker.Other.Off"), + "Mining.Skills.SuperBreaker.Other.Off", + "Mining.SubSkill.SuperBreaker.Name"), GIGA_DRILL_BREAKER( "Excavation.Skills.GigaDrillBreaker.On", "Excavation.Skills.GigaDrillBreaker.Off", "Excavation.Skills.GigaDrillBreaker.Other.On", "Excavation.Skills.GigaDrillBreaker.Refresh", - "Excavation.Skills.GigaDrillBreaker.Other.Off"), + "Excavation.Skills.GigaDrillBreaker.Other.Off", + "Excavation.SubSkill.GigaDrillBreaker.Name"), GREEN_TERRA( "Herbalism.Skills.GTe.On", "Herbalism.Skills.GTe.Off", "Herbalism.Skills.GTe.Other.On", "Herbalism.Skills.GTe.Refresh", - "Herbalism.Skills.GTe.Other.Off"), + "Herbalism.Skills.GTe.Other.Off", + "Herbalism.SubSkill.GreenTerra.Name"), SKULL_SPLITTER( "Axes.Skills.SS.On", "Axes.Skills.SS.Off", "Axes.Skills.SS.Other.On", "Axes.Skills.SS.Refresh", - "Axes.Skills.SS.Other.Off"), + "Axes.Skills.SS.Other.Off", + "Axes.SubSkill.SkullSplitter.Name"), TREE_FELLER( "Woodcutting.Skills.TreeFeller.On", "Woodcutting.Skills.TreeFeller.Off", "Woodcutting.Skills.TreeFeller.Other.On", "Woodcutting.Skills.TreeFeller.Refresh", - "Woodcutting.Skills.TreeFeller.Other.Off"), + "Woodcutting.Skills.TreeFeller.Other.Off", + "Woodcutting.SubSkill.TreeFeller.Name"), SERRATED_STRIKES( "Swords.Skills.SS.On", "Swords.Skills.SS.Off", "Swords.Skills.SS.Other.On", "Swords.Skills.SS.Refresh", - "Swords.Skills.SS.Other.Off"), + "Swords.Skills.SS.Other.Off", + "Swords.SubSkill.SerratedStrikes.Name"), /** * Has cooldown - but has to share a skill with Super Breaker, so needs special treatment @@ -67,7 +75,8 @@ public enum SuperAbilityType { null, "Mining.Blast.Other.On", "Mining.Blast.Refresh", - null), + null, + "Mining.SubSkill.BlastMining.Name"), ; /* @@ -91,13 +100,15 @@ public enum SuperAbilityType { private final String abilityRefresh; private final String abilityPlayerOff; private SubSkillType subSkillTypeDefinition; + private final String localizedName; - SuperAbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) { + SuperAbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff, String localizedName) { this.abilityOn = abilityOn; this.abilityOff = abilityOff; this.abilityPlayer = abilityPlayer; this.abilityRefresh = abilityRefresh; this.abilityPlayerOff = abilityPlayerOff; + this.localizedName = localizedName; } public int getCooldown() { @@ -132,6 +143,10 @@ public enum SuperAbilityType { return StringUtils.getPrettyAbilityString(this); } + public String getLocalizedName() { + return LocaleLoader.getString(localizedName); + } + @Override public String toString() { String baseString = name(); diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java index 7e5aa65b5..0bce7f5b5 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -90,10 +90,10 @@ public class ScoreboardManager { skillLabelBuilder.put(type, getShortenedName(colors.get(i) + type.getName(), false)); if (type.getAbility() != null) { - abilityLabelBuilder.put(type.getAbility(), getShortenedName(colors.get(i) + type.getAbility().getName())); + abilityLabelBuilder.put(type.getAbility(), getShortenedName(colors.get(i) + type.getAbility().getLocalizedName())); if (type == PrimarySkillType.MINING) { - abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, getShortenedName(colors.get(i) + SuperAbilityType.BLAST_MINING.getName())); + abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, getShortenedName(colors.get(i) + SuperAbilityType.BLAST_MINING.getLocalizedName())); } } @@ -112,17 +112,17 @@ public class ScoreboardManager { skillLabelBuilder.put(type, getShortenedName(ChatColor.GREEN + type.getName())); if (type.getAbility() != null) { - abilityLabelBuilder.put(type.getAbility(), formatAbility(type.getAbility().getName())); + abilityLabelBuilder.put(type.getAbility(), formatAbility(type.getAbility().getLocalizedName())); if (type == PrimarySkillType.MINING) { - abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, formatAbility(SuperAbilityType.BLAST_MINING.getName())); + abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, formatAbility(SuperAbilityType.BLAST_MINING.getLocalizedName())); } } } } for (SuperAbilityType type : SuperAbilityType.values()) { - abilityLabelSkillBuilder.put(type, formatAbility((type == SuperAbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA), type.getName())); + abilityLabelSkillBuilder.put(type, formatAbility((type == SuperAbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA), type.getLocalizedName())); } skillLabels = skillLabelBuilder.build(); From a28d1cd537caddb07a27ba2b7dd0ed7a37b39a48 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 25 Jul 2020 14:27:31 -0700 Subject: [PATCH 15/15] 2.1.135 --- Changelog.txt | 4 +++- pom.xml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 76d7a784c..81c782d36 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,8 @@ Version 2.1.135 - Fixed an issue where Fishing would break if exploit protection was turned off for Fishing (Thanks Ineusia) Furnaces no longer simulate block break checks when assigning ownership as it caused some unwanted plugin conflicts + Fixed an issue where Fishing would break if exploit protection was turned off for Fishing (Thanks Ineusia) + Fixed Super abilities not being translated on scoreboards (Thanks Ineusia) + Added option in advanced.yml to squelch ability activation messages being sent to other players via action bar (Thanks Ineusia) Version 2.1.134 Furnaces now change ownership to the last player who clicks in their inventory and is legally allowed to break the furnace diff --git a/pom.xml b/pom.xml index 51f339764..e61fe114b 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.135-SNAPSHOT + 2.1.135 mcMMO https://github.com/mcMMO-Dev/mcMMO