diff --git a/Changelog.txt b/Changelog.txt
index 3a34a0329..0fc14f093 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,4 +1,4 @@
-Version 2.1.134
+Version 2.2.000
New Skill - Tridents
New Skill - Crossbows
@@ -49,6 +49,37 @@ Version 2.1.134
Notes:
These are the first new skills that I've written for mcMMO in about 9 years, I'll be listening closely to feedback and tweaking them often.
+Version 2.1.135
+ 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
+ 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
+ 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
+ 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
+ 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.
+ 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
+>>>>>>> a28d1cd537caddb07a27ba2b7dd0ed7a37b39a48
+
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/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/pom.xml b/pom.xml
index cea247bd0..9e00cf6cc 100755
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.gmail.nossr50.mcMMO
mcMMO
- 2.1.134-SNAPSHOT
+ 2.2.000-ALPHA-SNAPSHOT
mcMMO
https://github.com/mcMMO-Dev/mcMMO
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 7c953a88a..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,15 +18,12 @@ public class McImportCommand implements CommandExecutor {
int fileAmount;
@Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- switch (args.length) {
- case 0:
- importModConfig();
- return true;
-
- default:
- return false;
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
+ if (args.length == 0) {
+ importModConfig();
+ return true;
}
+ return false;
}
public boolean importModConfig() {
@@ -34,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;
@@ -66,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) {
@@ -94,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);
@@ -170,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++;
}
@@ -202,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)) {
@@ -221,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);
@@ -241,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)) {
@@ -266,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);
@@ -281,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)) {
@@ -300,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);
@@ -326,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 e104b61d2..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;
@@ -22,12 +23,12 @@ 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();
- ArrayList databaseTypes = new ArrayList();
+ ArrayList formulaTypes = new ArrayList<>();
+ ArrayList databaseTypes = new ArrayList<>();
for (FormulaType type : FormulaType.values()) {
formulaTypes.add(type.toString());
@@ -53,34 +54,31 @@ 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);
- }
+ 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);
+ } 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
- 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 ac90ce9ab..2ffb16910 100644
--- a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java
+++ b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java
@@ -9,35 +9,33 @@ 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;
}
- 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
- 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 305aae98e..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,13 +70,11 @@ 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();
+ 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 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..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,14 +61,12 @@ 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();
+ 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 ImmutableList.of();
}
protected abstract boolean hasOtherPermission(CommandSender sender);
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 da15b8297..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,26 +5,25 @@ 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) {
- switch (args.length) {
- case 0:
- if (!Permissions.reloadlocale(sender)) {
- sender.sendMessage(command.getPermissionMessage());
- return true;
- }
-
- LocaleLoader.reloadLocale();
- sender.sendMessage(LocaleLoader.getString("Locale.Reloaded"));
-
+ 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());
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/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 b1d93685a..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,12 +16,13 @@ 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 abstract class ChatCommand implements TabExecutor {
- private ChatMode chatMode;
+ private final ChatMode chatMode;
protected ChatManager chatManager;
public ChatCommand(ChatMode chatMode) {
@@ -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,13 +89,11 @@ 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();
+ 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 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..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,62 +13,59 @@ 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) {
- switch (args.length) {
- case 2:
- DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
- DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
+ 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();
- 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 extends DatabaseManager>) 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 extends DatabaseManager>) 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..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,30 +7,28 @@ 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) {
- switch (args.length) {
- case 0:
- mcMMO.getDatabaseManager().purgePowerlessUsers();
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
+ 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
- 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 ba02d762c..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,43 +18,37 @@ 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.
- }
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
+ 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();
+ 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 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..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,31 +7,29 @@ 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) {
- switch (args.length) {
- case 0:
- Class> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
+ 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
- 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 147212bd0..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,42 +10,40 @@ 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) {
- 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
- }
+ 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));
+ 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/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 2a59a45b4..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,17 +109,15 @@ 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:
+ 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 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..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,40 +8,37 @@ 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) {
- switch (args.length) {
- case 1:
- Player player = (Player) sender;
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
+ 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..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,34 +11,30 @@ 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) {
- 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);
+ 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"));
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/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 b1471d9a0..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());
@@ -38,27 +39,27 @@ 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) {
+ 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 8e10e1719..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,35 +9,32 @@ 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) {
- switch (args.length) {
- case 1:
- if(UserManager.getPlayer((Player) sender) == null)
- {
- sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
+ 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"));
+ 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..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,27 +4,25 @@ 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) {
- 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;
+ 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"));
+ 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/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 588feb3d7..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,64 +11,60 @@ 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) {
- switch (args.length) {
- case 2:
- String targetName = CommandUtils.getMatchedPlayerName(args[1]);
- McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
+ 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);
- 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/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 ed0adde76..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,46 +12,43 @@ 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) {
- switch (args.length) {
- case 2:
- if(UserManager.getPlayer((Player) sender) == null)
- {
- sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
+ 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"));
+ 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..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")) {
@@ -67,7 +68,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..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,34 +10,31 @@ 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) {
- switch (args.length) {
- case 1:
- Player player = (Player) sender;
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
+ 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..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,57 +10,54 @@ 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) {
- 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));
+ 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"));
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..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"));
@@ -29,24 +30,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..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,36 +8,33 @@ 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) {
- 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);
+ 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"));
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..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;
@@ -27,12 +28,12 @@ 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) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
@@ -108,20 +109,18 @@ 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()));
+ 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()));
- 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..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,32 +9,29 @@ 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) {
- 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());
+ 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"));
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..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,68 +10,65 @@ 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) {
- switch (args.length) {
- case 3:
- String targetName = CommandUtils.getMatchedPlayerName(args[2]);
- McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
+ 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);
- 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/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 8d046c8fb..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;
@@ -33,12 +34,12 @@ 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) {
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
@@ -80,85 +81,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()));
+ 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()));
- 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/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 89560bb0f..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,93 +16,87 @@ 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) {
- switch (args.length) {
- case 1:
- String playerName = CommandUtils.getMatchedPlayerName(args[0]);
- McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
+ 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);
- // 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();
+ 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 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..74011a39c 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;
}
@@ -26,53 +27,48 @@ 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.getLocalizedName()));
+ } else {
+ player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getLocalizedName(), seconds));
+ }
+ }
+
+ return true;
}
+ return false;
}
@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 c973b0608..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,14 +73,12 @@ 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();
+ 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 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..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;
}
@@ -24,49 +25,44 @@ 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
- 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 dc9acb3b5..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,13 +67,11 @@ 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();
+ 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 ImmutableList.of();
}
private void display(int page, PrimarySkillType skill, CommandSender sender, Command command) {
@@ -90,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 1588cbd77..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)
@@ -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/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 294839b9e..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,51 +23,48 @@ 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;
}
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) {
@@ -101,17 +99,15 @@ 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();
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
+ if (args.length == 1) {
+ return ImmutableList.of("?");
}
+ return ImmutableList.of();
}
private List effectsDisplay(FakeSkillType fakeSkillType) {
- List messages = new ArrayList();
+ List messages = new ArrayList<>();
switch (fakeSkillType) {
case MACHO:
@@ -157,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 2d9093311..2f3d53a0f 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];
}
@@ -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 caff87ad5..9884ecba8 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];
}
@@ -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 95dc29458..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,13 +62,11 @@ 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();
+ 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 ImmutableList.of();
}
private void displayInfo(Player player, String subSkillName)
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 1241b9e11..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;
@@ -35,12 +36,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;
@@ -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;
}
@@ -64,64 +65,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) {
@@ -165,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));
@@ -215,13 +209,11 @@ 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();
+ public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
+ 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..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,15 +6,16 @@ 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;
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());
@@ -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