Remove Static Abuse - Scoreboards... (Yuck)

This commit is contained in:
nossr50 2019-07-02 21:12:50 -07:00
parent e7b80cbce5
commit 5ec59536c7
103 changed files with 696 additions and 699 deletions

View File

@ -12,35 +12,35 @@
// }
//
// public static boolean berserkEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.BERSERK);
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.BERSERK);
// }
//
// public static boolean gigaDrillBreakerEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER);
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER);
// }
//
// public static boolean greenTerraEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.GREEN_TERRA);
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.GREEN_TERRA);
// }
//
// public static boolean serratedStrikesEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SERRATED_STRIKES);
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.SERRATED_STRIKES);
// }
//
// public static boolean skullSplitterEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SKULL_SPLITTER);
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.SKULL_SPLITTER);
// }
//
// public static boolean superBreakerEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SUPER_BREAKER);
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.SUPER_BREAKER);
// }
//
// public static boolean treeFellerEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.TREE_FELLER);
// return pluginRef.getUserManager().getPlayer(player).getAbilityMode(SuperAbilityType.TREE_FELLER);
// }
//
// public static boolean isAnyAbilityEnabled(Player player) {
// McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
// McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
//
// for (SuperAbilityType ability : SuperAbilityType.values()) {
// if (mcMMOPlayer.getAbilityMode(ability)) {
@ -52,35 +52,35 @@
// }
//
// public static void resetCooldowns(Player player) {
// UserManager.getPlayer(player).resetCooldowns();
// pluginRef.getUserManager().getPlayer(player).resetCooldowns();
// }
//
// public static void setBerserkCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.BERSERK, cooldown);
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.BERSERK, cooldown);
// }
//
// public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown);
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown);
// }
//
// public static void setGreenTerraCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown);
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown);
// }
//
// public static void setSerratedStrikesCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown);
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown);
// }
//
// public static void setSkullSplitterCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown);
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown);
// }
//
// public static void setSuperBreakerCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown);
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown);
// }
//
// public static void setTreeFellerCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown);
// pluginRef.getUserManager().getPlayer(player).setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown);
// }
//
// public static boolean isBleeding(LivingEntity entity) {

View File

@ -76,7 +76,7 @@
// * @return true if the player is using party chat, false otherwise
// */
// public static boolean isUsingPartyChat(Player player) {
// return UserManager.getPlayer(player).isChatEnabled(ChatMode.PARTY);
// return pluginRef.getUserManager().getPlayer(player).isChatEnabled(ChatMode.PARTY);
// }
//
// /**
@ -86,7 +86,7 @@
// * @return true if the player is using party chat, false otherwise
// */
// public static boolean isUsingPartyChat(String playerName) {
// return UserManager.getPlayer(playerName).isChatEnabled(ChatMode.PARTY);
// return pluginRef.getUserManager().getPlayer(playerName).isChatEnabled(ChatMode.PARTY);
// }
//
// /**
@ -96,7 +96,7 @@
// * @return true if the player is using admin chat, false otherwise
// */
// public static boolean isUsingAdminChat(Player player) {
// return UserManager.getPlayer(player).isChatEnabled(ChatMode.ADMIN);
// return pluginRef.getUserManager().getPlayer(player).isChatEnabled(ChatMode.ADMIN);
// }
//
// /**
@ -106,7 +106,7 @@
// * @return true if the player is using admin chat, false otherwise
// */
// public static boolean isUsingAdminChat(String playerName) {
// return UserManager.getPlayer(playerName).isChatEnabled(ChatMode.ADMIN);
// return pluginRef.getUserManager().getPlayer(playerName).isChatEnabled(ChatMode.ADMIN);
// }
//
// /**
@ -115,7 +115,7 @@
// * @param player The player to toggle party chat on.
// */
// public static void togglePartyChat(Player player) {
// UserManager.getPlayer(player).toggleChat(ChatMode.PARTY);
// pluginRef.getUserManager().getPlayer(player).toggleChat(ChatMode.PARTY);
// }
//
// /**
@ -124,7 +124,7 @@
// * @param playerName The name of the player to toggle party chat on.
// */
// public static void togglePartyChat(String playerName) {
// UserManager.getPlayer(playerName).toggleChat(ChatMode.PARTY);
// pluginRef.getUserManager().getPlayer(playerName).toggleChat(ChatMode.PARTY);
// }
//
// /**
@ -133,7 +133,7 @@
// * @param player The player to toggle admin chat on.
// */
// public static void toggleAdminChat(Player player) {
// UserManager.getPlayer(player).toggleChat(ChatMode.ADMIN);
// pluginRef.getUserManager().getPlayer(player).toggleChat(ChatMode.ADMIN);
// }
//
// /**
@ -142,7 +142,7 @@
// * @param playerName The name of the player to toggle party chat on.
// */
// public static void toggleAdminChat(String playerName) {
// UserManager.getPlayer(playerName).toggleChat(ChatMode.ADMIN);
// pluginRef.getUserManager().getPlayer(playerName).toggleChat(ChatMode.ADMIN);
// }
//
// private static ChatManager getPartyChatManager(Plugin plugin, String party) {

View File

@ -1143,10 +1143,10 @@
// */
// @Deprecated
// private static McMMOPlayer getPlayer(Player player) throws McMMOPlayerNotFoundException {
// if (!UserManager.hasPlayerDataKey(player)) {
// if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
// throw new McMMOPlayerNotFoundException(player);
// }
//
// return UserManager.getPlayer(player);
// return pluginRef.getUserManager().getPlayer(player);
// }
//}

View File

@ -28,7 +28,7 @@
// return null;
// }
//
// return UserManager.getPlayer(player).getParty().getName();
// return pluginRef.getUserManager().getPlayer(player).getParty().getName();
// }
//
// /**
@ -40,10 +40,10 @@
// * @return true if the player is in a party, false otherwise
// */
// public static boolean inParty(Player player) {
// if (UserManager.getPlayer(player) == null)
// if (pluginRef.getUserManager().getPlayer(player) == null)
// return false;
//
// return UserManager.getPlayer(player).inParty();
// return pluginRef.getUserManager().getPlayer(player).inParty();
// }
//
// /**
@ -82,7 +82,7 @@
// @Deprecated
// public static void addToParty(Player player, String partyName) {
// //Check if player profile is loaded
// if (UserManager.getPlayer(player) == null)
// if (pluginRef.getUserManager().getPlayer(player) == null)
// return;
//
// Party party = pluginRef.getPartyManager().getParty(partyName);
@ -96,7 +96,7 @@
// }
// }
//
// pluginRef.getPartyManager().addToParty(UserManager.getPlayer(player), party);
// pluginRef.getPartyManager().addToParty(pluginRef.getUserManager().getPlayer(player), party);
// }
//
// /**
@ -130,7 +130,7 @@
// //TODO: bypasslimit not used?
// public static void addToParty(Player player, String partyName, boolean bypassLimit) {
// //Check if player profile is loaded
// if (UserManager.getPlayer(player) == null)
// if (pluginRef.getUserManager().getPlayer(player) == null)
// return;
//
// Party party = pluginRef.getPartyManager().getParty(partyName);
@ -139,7 +139,7 @@
// party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
// }
//
// pluginRef.getPartyManager().addToParty(UserManager.getPlayer(player), party);
// pluginRef.getPartyManager().addToParty(pluginRef.getUserManager().getPlayer(player), party);
// }
//
// /**
@ -151,10 +151,10 @@
// */
// public static void removeFromParty(Player player) {
// //Check if player profile is loaded
// if (UserManager.getPlayer(player) == null)
// if (pluginRef.getUserManager().getPlayer(player) == null)
// return;
//
// pluginRef.getPartyManager().removeFromParty(UserManager.getPlayer(player));
// pluginRef.getPartyManager().removeFromParty(pluginRef.getUserManager().getPlayer(player));
// }
//
// /**

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -85,7 +84,7 @@ public class ChatManager {
/*
* Party Chat Spying
*/
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
for (McMMOPlayer mcMMOPlayer : pluginRef.getUserManager().getPlayers()) {
Player player = mcMMOPlayer.getPlayer();
//Check for toggled players

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -23,7 +22,7 @@ public class ChatNotificationToggleCommand implements TabExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer((Player) sender);
//Not Loaded yet
if (mcMMOPlayer == null)

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.commands.database.ConvertDatabaseCommand;
import com.gmail.nossr50.commands.experience.ConvertExperienceCommand;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.mcMMO;

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.database.FlatFileDatabaseManager;
import com.gmail.nossr50.database.SQLDatabaseManager;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -25,7 +24,7 @@ public class ResetUserHealthBarSettingsCommand implements TabExecutor {
if (pluginRef.getDatabaseManager() instanceof SQLDatabaseManager) {
SQLDatabaseManager sqlDatabaseManager = (SQLDatabaseManager) pluginRef.getDatabaseManager();
sqlDatabaseManager.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
for (McMMOPlayer player : pluginRef.getUserManager().getPlayers()) {
player.getProfile().setMobHealthbarType(pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType());
}
sender.sendMessage("Mob health reset");
@ -34,7 +33,7 @@ public class ResetUserHealthBarSettingsCommand implements TabExecutor {
if (pluginRef.getDatabaseManager() instanceof FlatFileDatabaseManager) {
FlatFileDatabaseManager flatFileDatabaseManager = (FlatFileDatabaseManager) pluginRef.getDatabaseManager();
flatFileDatabaseManager.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
for (McMMOPlayer player : pluginRef.getUserManager().getPlayers()) {
player.getProfile().setMobHealthbarType(pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType());
}
sender.sendMessage("Mob health reset");

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -30,7 +29,7 @@ public class ScoreboardCommand implements TabExecutor {
switch (args.length) {
case 1:
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
ScoreboardManager.clearBoard(sender.getName());
pluginRef.getScoreboardManager().clearBoard(sender.getName());
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Clear"));
return true;
}
@ -41,12 +40,12 @@ public class ScoreboardCommand implements TabExecutor {
return true;
}
if (!ScoreboardManager.isBoardShown(sender.getName())) {
if (!pluginRef.getScoreboardManager().isBoardShown(sender.getName())) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.NoBoard"));
return true;
}
ScoreboardManager.keepBoard(sender.getName());
pluginRef.getScoreboardManager().keepBoard(sender.getName());
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Keep"));
return true;
}
@ -61,7 +60,7 @@ public class ScoreboardCommand implements TabExecutor {
int time = Math.abs(Integer.parseInt(args[1]));
ScoreboardManager.setRevertTimer(sender.getName(), time);
pluginRef.getScoreboardManager().setRevertTimer(sender.getName(), time);
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Timer", time));
return true;
}

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -37,7 +36,7 @@ public abstract class ToggleCommand implements TabExecutor {
return true;
}
applyCommandAction(UserManager.getPlayer(sender.getName()));
applyCommandAction(pluginRef.getUserManager().getPlayer(sender.getName()));
return true;
case 1:
@ -47,7 +46,7 @@ public abstract class ToggleCommand implements TabExecutor {
}
String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(playerName);
if (!pluginRef.getCommandTools().checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
return true;

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -39,7 +38,7 @@ public abstract class ChatCommand implements TabExecutor {
return true;
}
mcMMOPlayer = UserManager.getPlayer(sender.getName());
mcMMOPlayer = pluginRef.getUserManager().getPlayer(sender.getName());
if (mcMMOPlayer.isChatEnabled(chatMode)) {
disableChatMode(mcMMOPlayer, sender);
@ -58,7 +57,7 @@ public abstract class ChatCommand implements TabExecutor {
return true;
}
enableChatMode(UserManager.getPlayer(sender.getName()), sender);
enableChatMode(pluginRef.getUserManager().getPlayer(sender.getName()), sender);
return true;
}
@ -70,7 +69,7 @@ public abstract class ChatCommand implements TabExecutor {
return true;
}
disableChatMode(UserManager.getPlayer(sender.getName()), sender);
disableChatMode(pluginRef.getUserManager().getPlayer(sender.getName()), sender);
return true;
}

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -20,10 +19,10 @@ public class PartyChatCommand extends ChatCommand {
if (sender instanceof Player) {
//Check if player profile is loaded
if (UserManager.getPlayer((Player) sender) == null)
if (pluginRef.getUserManager().getPlayer((Player) sender) == null)
return;
party = UserManager.getPlayer((Player) sender).getParty();
party = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
if (party == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None"));

View File

@ -1,13 +1,11 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.database.DatabaseConversionTask;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -56,8 +54,8 @@ public class ConvertDatabaseCommand implements CommandExecutor {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString()));
UserManager.saveAll();
UserManager.clearAll();
pluginRef.getUserManager().saveAll();
pluginRef.getUserManager().clearAll();
for (Player player : pluginRef.getServer().getOnlinePlayers()) {
PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId());

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
@ -26,7 +25,7 @@ public class McremoveCommand implements TabExecutor {
if (args.length == 1) {
String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
if (UserManager.getOfflinePlayer(playerName) == null && pluginRef.getCommandTools().unloadedProfile(sender, pluginRef.getDatabaseManager().loadPlayerProfile(playerName, false))) {
if (pluginRef.getUserManager().getOfflinePlayer(playerName) == null && pluginRef.getCommandTools().unloadedProfile(sender, pluginRef.getDatabaseManager().loadPlayerProfile(playerName, false))) {
return true;
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -30,10 +29,10 @@ public class AddXPCommand extends ExperienceCommand {
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
if (player != null) {
//Check if player profile is loaded
if (UserManager.getPlayer(player) == null)
if (pluginRef.getUserManager().getPlayer(player) == null)
return;
UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND);
pluginRef.getUserManager().getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND);
} else {
profile.addXp(skill, value);
profile.scheduleAsyncSave();

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.database.FormulaConversionTask;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -30,8 +29,8 @@ public class ConvertExperienceCommand implements CommandExecutor {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Experience.Start", previousType.toString(), pluginRef.getConfigManager().getConfigLeveling().getFormulaType().toString()));
UserManager.saveAll();
UserManager.clearAll();
pluginRef.getUserManager().saveAll();
pluginRef.getUserManager().clearAll();
new FormulaConversionTask(sender, previousType).runTaskLater(pluginRef, 1);

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
@ -64,13 +63,13 @@ public abstract class ExperienceCommand implements TabExecutor {
}
//Profile not loaded
if (UserManager.getPlayer(sender.getName()) == null) {
if (pluginRef.getUserManager().getPlayer(sender.getName()) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]));
editValues((Player) sender, pluginRef.getUserManager().getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]));
return true;
case 3:
@ -97,7 +96,7 @@ public abstract class ExperienceCommand implements TabExecutor {
int value = Integer.parseInt(args[2]);
String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().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) {

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
@ -63,7 +62,7 @@ public class SkillResetCommand implements TabExecutor {
skill = PrimarySkillType.getSkill(args[1]);
}
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill);
editValues((Player) sender, pluginRef.getUserManager().getPlayer(sender.getName()).getProfile(), skill);
return true;
case 2:
@ -83,7 +82,7 @@ public class SkillResetCommand implements TabExecutor {
}
String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().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) {

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -22,12 +21,12 @@ public class PartyAcceptCommand implements CommandExecutor {
Player player = (Player) sender;
//Check if player profile is loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (!mcMMOPlayer.hasPartyInvite()) {

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -22,12 +21,12 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
switch (args.length) {
case 2:
//Check if player profile is loaded
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
Party playerParty = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]);
OfflinePlayer target = pluginRef.getServer().getOfflinePlayer(targetName);

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -18,12 +17,12 @@ public class PartyChangePasswordCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Party party = UserManager.getPlayer((Player) sender).getParty();
Party party = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
switch (args.length) {
case 1:

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -103,16 +102,16 @@ public class PartyCommand implements TabExecutor {
Player player = (Player) sender;
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return true;
}
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
player.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (args.length < 1) {
if (!mcMMOPlayer.inParty()) {
@ -237,12 +236,12 @@ public class PartyCommand implements TabExecutor {
Player player = (Player) sender;
//Not Loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return ImmutableList.of();
}
Party party = UserManager.getPlayer(player).getParty();
Party party = pluginRef.getUserManager().getPlayer(player).getParty();
playerNames = party.getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -22,9 +21,9 @@ public class PartyCreateCommand implements CommandExecutor {
case 2:
case 3:
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
player.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -21,12 +20,12 @@ public class PartyDisbandCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
Party playerParty = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
String partyName = playerParty.getName();
for (Player member : playerParty.getOnlineMembers()) {

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -28,12 +27,12 @@ public class PartyInfoCommand implements CommandExecutor {
switch (args.length) {
case 0:
case 1:
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
Party party = mcMMOPlayer.getParty();
displayPartyHeader(player, party);

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -22,7 +21,7 @@ public class PartyInviteCommand implements CommandExecutor {
switch (args.length) {
case 2:
String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
McMMOPlayer mcMMOTarget = pluginRef.getUserManager().getOfflinePlayer(targetName);
if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
@ -30,13 +29,13 @@ public class PartyInviteCommand implements CommandExecutor {
Player target = mcMMOTarget.getPlayer();
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -22,12 +21,12 @@ public class PartyItemShareCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Party party = UserManager.getPlayer((Player) sender).getParty();
Party party = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
if (party.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.4"));

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -23,7 +22,7 @@ public class PartyJoinCommand implements CommandExecutor {
case 2:
case 3:
String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
McMMOPlayer mcMMOTarget = pluginRef.getUserManager().getPlayer(targetName);
if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return true;
@ -38,12 +37,12 @@ public class PartyJoinCommand implements CommandExecutor {
Player player = (Player) sender;
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
Party targetParty = mcMMOTarget.getParty();
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -22,12 +21,12 @@ public class PartyKickCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
Party playerParty = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]);
if (!playerParty.hasMember(targetName)) {
@ -45,7 +44,7 @@ public class PartyKickCommand implements CommandExecutor {
return true;
}
pluginRef.getPartyManager().processPartyLeaving(UserManager.getPlayer(onlineTarget));
pluginRef.getPartyManager().processPartyLeaving(pluginRef.getUserManager().getPlayer(onlineTarget));
onlineTarget.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Kick", partyName));
}

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -57,12 +56,12 @@ public class PartyLockCommand implements CommandExecutor {
}
private void togglePartyLock(CommandSender sender, boolean lock) {
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return;
}
Party party = UserManager.getPlayer((Player) sender).getParty();
Party party = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
if (!Permissions.partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoPermission"));

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -24,12 +23,12 @@ public class PartyQuitCommand implements CommandExecutor {
case 1:
Player player = (Player) sender;
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
Party playerParty = mcMMOPlayer.getParty();
if (!pluginRef.getPartyManager().handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -22,12 +21,12 @@ public class PartyRenameCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer((Player) sender);
Party playerParty = mcMMOPlayer.getParty();
String oldPartyName = playerParty.getName();

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -21,12 +20,12 @@ public class PartyXpShareCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Party party = UserManager.getPlayer((Player) sender).getParty();
Party party = pluginRef.getUserManager().getPlayer((Player) sender).getParty();
if (party.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.5"));

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -20,12 +19,12 @@ public class PartyAllianceAcceptCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (!mcMMOPlayer.hasPartyAllianceInvite()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoInvites"));

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -43,13 +42,13 @@ public class PartyAllianceCommand implements TabExecutor {
return true;
}
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
playerParty = mcMMOPlayer.getParty();

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -21,12 +20,12 @@ public class PartyAllianceDisbandCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
Party party = mcMMOPlayer.getParty();
if (party.getAlly() == null) {

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -22,7 +21,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
switch (args.length) {
case 3:
String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[2]);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
McMMOPlayer mcMMOTarget = pluginRef.getUserManager().getOfflinePlayer(targetName);
if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
@ -30,13 +29,13 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
Player target = mcMMOTarget.getPlayer();
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -22,7 +21,7 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
return true;
}
PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord();
PartyTeleportRecord ptpRecord = pluginRef.getUserManager().getPlayer(sender.getName()).getPartyTeleportRecord();
if (ptpRecord.isConfirmRequired()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.AcceptAny.Disabled"));

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.World;
import org.bukkit.command.Command;
@ -26,13 +25,13 @@ public class PtpAcceptCommand implements CommandExecutor {
return true;
}
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
PartyTeleportRecord ptpRecord = UserManager.getPlayer(player).getPartyTeleportRecord();
PartyTeleportRecord ptpRecord = pluginRef.getUserManager().getPlayer(player).getPartyTeleportRecord();
if (!ptpRecord.hasRequest()) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.NoRequests"));

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.worldguard.WorldGuardUtils;
import com.google.common.collect.ImmutableList;
@ -57,16 +56,16 @@ public class PtpCommand implements TabExecutor {
if (WorldBlacklist.isWorldBlacklisted(player.getWorld()))
return true;
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return true;
}
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None"));
@ -135,13 +134,13 @@ public class PtpCommand implements TabExecutor {
List<String> matches = StringUtil.copyPartialMatches(args[0], CommandConstants.TELEPORT_SUBCOMMANDS, new ArrayList<>(CommandConstants.TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) {
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return ImmutableList.of();
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (!mcMMOPlayer.inParty()) {
return ImmutableList.of();
@ -162,7 +161,7 @@ public class PtpCommand implements TabExecutor {
return;
}
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
McMMOPlayer mcMMOTarget = pluginRef.getUserManager().getPlayer(targetName);
Player target = mcMMOTarget.getPlayer();
PartyTeleportRecord ptpRecord = mcMMOTarget.getPartyTeleportRecord();

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -23,7 +22,7 @@ public class PtpToggleCommand implements CommandExecutor {
return true;
}
PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord();
PartyTeleportRecord ptpRecord = pluginRef.getUserManager().getPlayer(sender.getName()).getPartyTeleportRecord();
if (ptpRecord.isEnabled()) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.Disabled"));

View File

@ -3,8 +3,6 @@ package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -35,20 +33,20 @@ public class CooldownCommand implements TabExecutor {
case 0:
Player player = (Player) sender;
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled() && pluginRef.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.COOLDOWNS_BOARD)) {
ScoreboardManager.enablePlayerCooldownScoreboard(player);
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled() && pluginRef.getScoreboardSettings().isScoreboardEnabled(pluginRef.getScoreboardManager().SidebarType.COOLDOWNS_BOARD)) {
pluginRef.getScoreboardManager().enablePlayerCooldownScoreboard(player);
if (!pluginRef.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.COOLDOWNS_BOARD)) {
if (!pluginRef.getScoreboardSettings().isScoreboardPrinting(pluginRef.getScoreboardManager().SidebarType.COOLDOWNS_BOARD)) {
return true;
}
}
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
player.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Cooldowns.Header"));
player.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoSkillNote"));

View File

@ -5,8 +5,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -30,7 +28,7 @@ public class InspectCommand implements TabExecutor {
switch (args.length) {
case 1:
String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().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) {
@ -43,7 +41,7 @@ public class InspectCommand implements TabExecutor {
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player
&& pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isUseThisBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
pluginRef.getScoreboardManager().enablePlayerInspectScoreboard((Player) sender, profile);
if (!pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isPrintToChat()) {
return true;
@ -79,7 +77,7 @@ public class InspectCommand implements TabExecutor {
}
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player && pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isUseThisBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
pluginRef.getScoreboardManager().enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
if (!pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isPrintToChat()) {
return true;

View File

@ -7,8 +7,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -92,7 +90,7 @@ public class LeaderboardCommand implements TabExecutor {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(sender.getName());
long cooldownMillis = 5000;
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
@ -119,8 +117,8 @@ public class LeaderboardCommand implements TabExecutor {
}
private void display(int page, PrimarySkillType skill, CommandSender sender) {
boolean useBoard = (sender instanceof Player) && (pluginRef.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.TOP_BOARD));
boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.TOP_BOARD);
boolean useBoard = (sender instanceof Player) && (pluginRef.getScoreboardSettings().isScoreboardEnabled(pluginRef.getScoreboardManager().SidebarType.TOP_BOARD));
boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(pluginRef.getScoreboardManager().SidebarType.TOP_BOARD);
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(pluginRef);
}

View File

@ -5,8 +5,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -58,7 +56,7 @@ public class RankCommand implements TabExecutor {
}
String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getOfflinePlayer(playerName);
if (mcMMOPlayer != null) {
Player player = mcMMOPlayer.getPlayer();
@ -91,7 +89,7 @@ public class RankCommand implements TabExecutor {
private void display(CommandSender sender, String playerName) {
if (sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(sender.getName());
if (mcMMOPlayer == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
@ -116,8 +114,8 @@ public class RankCommand implements TabExecutor {
}
boolean useBoard = pluginRef.getScoreboardSettings().getScoreboardsEnabled() && (sender instanceof Player)
&& (pluginRef.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.RANK_BOARD));
boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.RANK_BOARD);
&& (pluginRef.getScoreboardSettings().isScoreboardEnabled(pluginRef.getScoreboardManager().SidebarType.RANK_BOARD));
boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(pluginRef.getScoreboardManager().SidebarType.RANK_BOARD);
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(pluginRef);
}

View File

@ -1,8 +1,6 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -31,17 +29,17 @@ public class SkillStatsCommand implements TabExecutor {
switch (args.length) {
case 0:
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
Player player = (Player) sender;
if (pluginRef.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.STATS_BOARD) && pluginRef.getScoreboardSettings().getScoreboardsEnabled()) {
ScoreboardManager.enablePlayerStatsScoreboard(player);
if (pluginRef.getScoreboardSettings().isScoreboardEnabled(pluginRef.getScoreboardManager().SidebarType.STATS_BOARD) && pluginRef.getScoreboardSettings().getScoreboardsEnabled()) {
pluginRef.getScoreboardManager().enablePlayerStatsScoreboard(player);
if (!pluginRef.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.STATS_BOARD)) {
if (!pluginRef.getScoreboardSettings().isScoreboardPrinting(pluginRef.getScoreboardManager().SidebarType.STATS_BOARD)) {
return true;
}
}
@ -56,9 +54,9 @@ public class SkillStatsCommand implements TabExecutor {
int powerLevelCap = pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().getLevelCap();
if (pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().isLevelCapEnabled()) {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel.Capped", pluginRef.getUserManager().getPlayer(player).getPowerLevel(), powerLevelCap));
} else {
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
player.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel", pluginRef.getUserManager().getPlayer(player).getPowerLevel()));
}
return true;

View File

@ -25,12 +25,12 @@
//
//// protected String[] calculateAbilityDisplayValues(Player player) {
//// //TODO: Needed?
//// if (UserManager.getPlayer(player) == null) {
//// if (pluginRef.getUserManager().getPlayer(player) == null) {
//// player.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
//// return new String[]{"DATA NOT LOADED", "DATA NOT LOADED"};
//// }
////
//// AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
//// AlchemyManager alchemyManager = pluginRef.getUserManager().getPlayer(player).getAlchemyManager();
//// String[] displayValues = new String[2];
////
//// boolean isLucky = Permissions.lucky(player, PrimarySkillType.ALCHEMY);
@ -52,7 +52,7 @@
////
//// // ALCHEMY_CONCOCTIONS
//// if (canConcoctions) {
//// AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
//// AlchemyManager alchemyManager = pluginRef.getUserManager().getPlayer(player).getAlchemyManager();
//// tier = alchemyManager.getTier();
//// ingredientCount = alchemyManager.getIngredients().size();
//// ingredientList = alchemyManager.getIngredientList();

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.axes.Axes;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
@ -37,7 +36,7 @@ public class AxesCommand extends SkillCommand {
protected void dataCalculations(Player player, double skillValue) {
// ARMOR IMPACT
if (canImpact) {
impactDamage = UserManager.getPlayer(player).getAxesManager().getImpactDurabilityDamage();
impactDamage = pluginRef.getUserManager().getPlayer(player).getAxesManager().getImpactDurabilityDamage();
}
// AXE MASTERY

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -45,7 +44,7 @@ public class ExcavationCommand extends SkillCommand {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager();
ExcavationManager excavationManager = pluginRef.getUserManager().getPlayer(player).getExcavationManager();
if (canGigaDrill) {
messages.add(getStatMessage(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, gigaDrillBreakerLength)

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
@ -52,7 +51,7 @@ public class FishingCommand extends SkillCommand {
@Override
protected void dataCalculations(Player player, double skillValue) {
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
FishingManager fishingManager = pluginRef.getUserManager().getPlayer(player).getFishingManager();
// TREASURE HUNTER
if (canTreasureHunt) {

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -41,7 +40,7 @@ public class MiningCommand extends SkillCommand {
protected void dataCalculations(Player player, double skillValue) {
// BLAST MINING
if (canBlast || canDemoExpert || canBiggerBombs) {
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
MiningManager miningManager = pluginRef.getUserManager().getPlayer(player).getMiningManager();
blastMiningRank = miningManager.getBlastMiningTier();
bonusTNTDrops = miningManager.getDropMultiplier();

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material;
@ -92,7 +91,7 @@ public class RepairCommand extends SkillCommand {
List<String> messages = new ArrayList<>();
if (canArcaneForge) {
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
RepairManager repairManager = pluginRef.getUserManager().getPlayer(player).getRepairManager();
messages.add(getStatMessage(false, true,
SubSkillType.REPAIR_ARCANE_FORGING,

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -37,7 +36,7 @@ public class SalvageCommand extends SkillCommand {
@Override
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
SalvageManager salvageManager = pluginRef.getUserManager().getPlayer(player).getSalvageManager();
if (canScrapCollector) {
messages.add(getStatMessage(false, true,

View File

@ -8,9 +8,7 @@ import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.skills.SkillUtils;
@ -62,7 +60,7 @@ public abstract class SkillCommand implements TabExecutor {
return true;
}
if (UserManager.getPlayer((Player) sender) == null) {
if (pluginRef.getUserManager().getPlayer((Player) sender) == null) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return true;
}
@ -70,7 +68,7 @@ public abstract class SkillCommand implements TabExecutor {
switch (args.length) {
case 0:
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
boolean isLucky = Permissions.lucky(player, skill);
boolean hasEndurance = SkillUtils.getEnduranceLength(player) > 0;
@ -118,7 +116,7 @@ public abstract class SkillCommand implements TabExecutor {
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled()
&& pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes()
.getConfigSectionSkillBoard().isUseThisBoard()) {
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
pluginRef.getScoreboardManager().enablePlayerSkillScoreboard(player, skill);
}
return true;
@ -214,9 +212,9 @@ public abstract class SkillCommand implements TabExecutor {
protected String[] formatLengthDisplayValues(Player player, double skillValue) {
int length = SkillUtils.calculateAbilityLength(UserManager.getPlayer(player), skill, skill.getSuperAbility());
int length = SkillUtils.calculateAbilityLength(pluginRef.getUserManager().getPlayer(player), skill, skill.getSuperAbility());
int enduranceLength = SkillUtils.calculateAbilityLengthPerks(UserManager.getPlayer(player), skill, skill.getSuperAbility());
int enduranceLength = SkillUtils.calculateAbilityLengthPerks(pluginRef.getUserManager().getPlayer(player), skill, skill.getSuperAbility());
return new String[]{String.valueOf(length), String.valueOf(enduranceLength)};
}

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -33,7 +32,7 @@ public class SmeltingCommand extends SkillCommand {
protected void dataCalculations(Player player, double skillValue) {
// FUEL EFFICIENCY
if (canFuelEfficiency) {
burnTimeModifier = String.valueOf(UserManager.getPlayer(player).getSmeltingManager().getFuelEfficiencyMultiplier());
burnTimeModifier = String.valueOf(pluginRef.getUserManager().getPlayer(player).getSmeltingManager().getFuelEfficiencyMultiplier());
}
// FLUX MINING
@ -80,7 +79,7 @@ public class SmeltingCommand extends SkillCommand {
if (canUnderstandTheArt) {
messages.add(getStatMessage(false, true, SubSkillType.SMELTING_UNDERSTANDING_THE_ART,
String.valueOf(UserManager.getPlayer(player).getSmeltingManager().getVanillaXpMultiplier())));
String.valueOf(pluginRef.getUserManager().getPlayer(player).getSmeltingManager().getVanillaXpMultiplier())));
}
return messages;

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
@ -42,7 +41,7 @@ public class SwordsCommand extends SkillCommand {
// SWORDS_RUPTURE
if (canBleed) {
bleedLength = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks();
bleedLength = pluginRef.getUserManager().getPlayer(player).getSwordsManager().getRuptureBleedTicks();
String[] bleedStrings = getAbilityDisplayValues(player, SubSkillType.SWORDS_RUPTURE);
bleedChance = bleedStrings[0];
@ -68,7 +67,7 @@ public class SwordsCommand extends SkillCommand {
protected List<String> statsDisplay(Player player, double skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
int ruptureTicks = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks();
int ruptureTicks = pluginRef.getUserManager().getPlayer(player).getSwordsManager().getRuptureBleedTicks();
double ruptureDamagePlayer = pluginRef.getConfigManager().getConfigSwords().getRuptureDamagePlayer();
double pveRupture = pluginRef.getConfigManager().getConfigSwords().getRuptureDamageMobs();
@ -98,7 +97,7 @@ public class SwordsCommand extends SkillCommand {
if (canUseSubskill(player, SubSkillType.SWORDS_STAB)) {
messages.add(getStatMessage(SubSkillType.SWORDS_STAB,
String.valueOf(UserManager.getPlayer(player).getSwordsManager().getStabDamage())));
String.valueOf(pluginRef.getUserManager().getPlayer(player).getSwordsManager().getStabDamage())));
}
if (canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
@ -60,7 +59,7 @@ public class UnarmedCommand extends SkillCommand {
// IRON ARM
if (canIronArm) {
ironArmBonus = UserManager.getPlayer(player).getUnarmedManager().getIronArmDamage();
ironArmBonus = pluginRef.getUserManager().getPlayer(player).getUnarmedManager().getIronArmDamage();
}
// IRON GRIP

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.config.hocon.scoreboard;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.scoreboards.SidebarType;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ -57,7 +57,7 @@ public class ConfigScoreboard {
return configSectionGeneral.isUseAbilityNameInsteadOfGeneric();
}
public boolean isScoreboardEnabled(ScoreboardManager.SidebarType sidebarType) {
public boolean isScoreboardEnabled(SidebarType sidebarType) {
switch (sidebarType) {
case TOP_BOARD:
return getConfigSectionScoreboardTypes().getConfigSectionTopBoard().isUseThisBoard();
@ -74,7 +74,7 @@ public class ConfigScoreboard {
}
}
public boolean isScoreboardPrinting(ScoreboardManager.SidebarType sidebarType) {
public boolean isScoreboardPrinting(SidebarType sidebarType) {
switch (sidebarType) {
case TOP_BOARD:
return getConfigSectionScoreboardTypes().getConfigSectionTopBoard().isPrintToChat();
@ -90,7 +90,7 @@ public class ConfigScoreboard {
}
}
public int getScoreboardDisplayTime(ScoreboardManager.SidebarType sidebarType) {
public int getScoreboardDisplayTime(SidebarType sidebarType) {
switch (sidebarType) {
case TOP_BOARD:
return getConfigSectionScoreboardTypes().getConfigSectionTopBoard().getDisplayTimeInSeconds();

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit;
@ -389,7 +388,7 @@ public class Party {
//First add the party leader
memberList.append(partyLeaderPrefix);
List<Player> nearbyPlayerList = getNearMembers(UserManager.getPlayer(player));
List<Player> nearbyPlayerList = getNearMembers(pluginRef.getUserManager().getPlayer(player));
boolean useDisplayNames = pluginRef.getConfigManager().getConfigParty().isPartyDisplayNamesEnabled();

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.runnables.skills.ToolLowerTask;
@ -35,8 +34,6 @@ import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.experience.ExperienceBarManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
@ -1022,10 +1019,10 @@ public class McMMOPlayer {
getProfile().scheduleAsyncSave();
}
UserManager.remove(thisPlayer);
pluginRef.getUserManager().remove(thisPlayer);
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled())
ScoreboardManager.teardownPlayer(thisPlayer);
pluginRef.getScoreboardManager().teardownPlayer(thisPlayer);
if (inParty()) {
party.removeOnlineMember(thisPlayer);

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableMap;
import java.util.HashMap;
@ -408,7 +407,7 @@ public class PlayerProfile {
* @return the total amount of Xp until next level
*/
public int getXpToLevel(PrimarySkillType primarySkillType) {
int level = (pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceFormula().isCumulativeCurveEnabled()) ? UserManager.getPlayer(playerName).getPowerLevel() : skills.get(primarySkillType);
int level = (pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceFormula().isCumulativeCurveEnabled()) ? pluginRef.getUserManager().getPlayer(playerName).getPowerLevel() : skills.get(primarySkillType);
return pluginRef.getFormulaManager().getXPtoNextLevel(level);
}

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceSkill;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.PerksUtils;
@ -125,7 +124,7 @@ public class Roll extends AcrobaticsSubSkill {
String rollChance, rollChanceLucky, gracefulRollChance, gracefulRollChanceLucky;
/* Values related to the player */
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
PlayerProfile playerProfile = pluginRef.getUserManager().getPlayer(player).getProfile();
float skillValue = playerProfile.getSkillLevel(getPrimarySkill());
boolean isLucky = Permissions.lucky(player, getPrimarySkill());
@ -280,10 +279,10 @@ public class Roll extends AcrobaticsSubSkill {
}
//Teleport CD
if (System.currentTimeMillis() < UserManager.getPlayer(player).getTeleportATS())
if (System.currentTimeMillis() < pluginRef.getUserManager().getPlayer(player).getTeleportATS())
return true;
if (UserManager.getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
if (pluginRef.getUserManager().getPlayer(player).getAcrobaticsManager().hasFallenInLocationBefore(getBlockLocation(player)))
return true;
return false;
@ -408,7 +407,7 @@ public class Roll extends AcrobaticsSubSkill {
}
public void addFallLocation(Player player) {
UserManager.getPlayer(player).getAcrobaticsManager().addLocationToFallMap(getBlockLocation(player));
pluginRef.getUserManager().getPlayer(player).getAcrobaticsManager().addLocationToFallMap(getBlockLocation(player));
}
public Location getBlockLocation(Player player) {

View File

@ -38,9 +38,9 @@
// if (player != null
// && !Misc.isNPCEntity(player)
// && Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CATALYSIS)
// && UserManager.getPlayer(player) != null) {
// && pluginRef.getUserManager().getPlayer(player) != null) {
//
// double catalysis = UserManager.getPlayer(player).getAlchemyManager().calculateBrewSpeed(Permissions.lucky(player, PrimarySkillType.ALCHEMY));
// double catalysis = pluginRef.getUserManager().getPlayer(player).getAlchemyManager().calculateBrewSpeed(Permissions.lucky(player, PrimarySkillType.ALCHEMY));
//
// McMMOPlayerCatalysisEvent event = new McMMOPlayerCatalysisEvent(player, catalysis);
// mcMMO.p.getServer().getPluginManager().callEvent(event);

View File

@ -88,11 +88,11 @@
// }
//
// private static List<ItemStack> getValidIngredients(Player player) {
// if (player == null || UserManager.getPlayer(player) == null) {
// if (player == null || pluginRef.getUserManager().getPlayer(player) == null) {
// return PotionManager.getInstance().getIngredients(1);
// }
//
// return PotionManager.getInstance().getIngredients(!Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS) ? 1 : UserManager.getPlayer(player).getAlchemyManager().getTier());
// return PotionManager.getInstance().getIngredients(!Permissions.isSubSkillEnabled(player, SubSkillType.ALCHEMY_CONCOCTIONS) ? 1 : pluginRef.getUserManager().getPlayer(player).getAlchemyManager().getTier());
// }
//
// public static void finishBrewing(BlockState brewingStand, Player player, boolean forced) {
@ -142,8 +142,8 @@
// PotionStage potionStage = PotionStage.getPotionStage(input, output);
//
// //TODO: hmm
// if (UserManager.hasPlayerDataKey(player)) {
// UserManager.getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(potionStage, 1);
// if (pluginRef.getUserManager().hasPlayerDataKey(player)) {
// pluginRef.getUserManager().getPlayer(player).getAlchemyManager().handlePotionBrewSuccesses(potionStage, 1);
// }
// }
// }

View File

@ -367,7 +367,7 @@
// if(!Config.getInstance().isAprilFoolsAllowed())
// return;
//
// int levelTotal = Misc.getRandom().nextInt(1 + UserManager.getPlayer(player).getSkillLevel(PrimarySkillType.MINING)) + 1;
// int levelTotal = Misc.getRandom().nextInt(1 + pluginRef.getUserManager().getPlayer(player).getSkillLevel(PrimarySkillType.MINING)) + 1;
// SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
// mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.HOLIDAY, "Holiday.AprilFools.Levelup", StringUtils.getCapitalized(fakeSkillType.toString()), String.valueOf(levelTotal));
//// ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.events.experience;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@ -22,14 +21,14 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
protected McMMOPlayerExperienceEvent(Player player, PrimarySkillType skill) {
super(player);
this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
this.skillLevel = pluginRef.getUserManager().getPlayer(player).getSkillLevel(skill);
this.xpGainReason = XPGainReason.UNKNOWN;
}
protected McMMOPlayerExperienceEvent(Player player, PrimarySkillType skill, XPGainReason xpGainReason) {
super(player);
this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
this.skillLevel = pluginRef.getUserManager().getPlayer(player).getSkillLevel(skill);
this.xpGainReason = xpGainReason;
}

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.events.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
@ -20,7 +19,7 @@ public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
protected McMMOPlayerSkillEvent(Player player, PrimarySkillType skill) {
super(player);
this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
this.skillLevel = pluginRef.getUserManager().getPlayer(player).getSkillLevel(skill);
}
public static HandlerList getHandlerList() {

View File

@ -20,7 +20,6 @@ import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import com.gmail.nossr50.worldguard.WorldGuardUtils;
@ -43,10 +42,10 @@ import org.bukkit.metadata.MetadataValue;
import java.util.List;
public class BlockListener implements Listener {
private final mcMMO plugin;
private final mcMMO pluginRef;
public BlockListener(final mcMMO plugin) {
this.plugin = plugin;
public BlockListener(final mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -71,7 +70,7 @@ public class BlockListener implements Listener {
}
if(event.getBlock().hasMetadata(MetadataConstants.BONUS_DROPS_METAKEY))
event.getBlock().removeMetadata(MetadataConstants.BONUS_DROPS_METAKEY, plugin);
event.getBlock().removeMetadata(MetadataConstants.BONUS_DROPS_METAKEY, pluginRef);
}
/*@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -192,7 +191,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
@ -205,7 +204,7 @@ public class BlockListener implements Listener {
pluginRef.getPlaceStore().setTrue(blockState);
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (blockState.getType() == Repair.getInstance().getAnvilMaterial()
&& PrimarySkillType.REPAIR.getPermissions(player)) {
@ -235,7 +234,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
@ -277,7 +276,7 @@ public class BlockListener implements Listener {
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!plugin.getWorldGuardManager().hasMainFlag(event.getPlayer()))
if (!pluginRef.getWorldGuardManager().hasMainFlag(event.getPlayer()))
return;
}
@ -298,11 +297,11 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
//Check if profile is loaded
if (mcMMOPlayer == null)
@ -371,7 +370,7 @@ public class BlockListener implements Listener {
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!plugin.getWorldGuardManager().hasMainFlag(event.getPlayer()))
if (!pluginRef.getWorldGuardManager().hasMainFlag(event.getPlayer()))
return;
}
@ -381,12 +380,12 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
@ -399,7 +398,7 @@ public class BlockListener implements Listener {
}
if (ItemUtils.isSword(heldItem)) {
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
HerbalismManager herbalismManager = pluginRef.getUserManager().getPlayer(player).getHerbalismManager();
if (herbalismManager.canUseHylianLuck()) {
if (herbalismManager.processHylianLuck(blockState)) {
@ -413,7 +412,7 @@ public class BlockListener implements Listener {
}
}
/*else if (!heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager();
SmeltingManager smeltingManager = pluginRef.getUserManager().getPlayer(player).getSmeltingManager();
if (smeltingManager.canUseFluxMining(blockState)) {
if (smeltingManager.processFluxMining(blockState)) {
@ -440,18 +439,18 @@ public class BlockListener implements Listener {
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!plugin.getWorldGuardManager().hasMainFlag(event.getPlayer()))
if (!pluginRef.getWorldGuardManager().hasMainFlag(event.getPlayer()))
return;
}
if (event instanceof FakeBlockDamageEvent) {
return;
}
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
//Profile not loaded
if (mcMMOPlayer == null) {
@ -494,7 +493,7 @@ public class BlockListener implements Listener {
return null;
}
return plugin.getServer().getPlayerExact(metadata.get(0).asString());
return pluginRef.getServer().getPlayerExact(metadata.get(0).asString());
}
/**
@ -510,7 +509,7 @@ public class BlockListener implements Listener {
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!plugin.getWorldGuardManager().hasMainFlag(event.getPlayer()))
if (!pluginRef.getWorldGuardManager().hasMainFlag(event.getPlayer()))
return;
}
@ -520,14 +519,14 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
@ -564,7 +563,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
@ -579,16 +578,16 @@ public class BlockListener implements Listener {
player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP");
else {
player.sendMessage("[mcMMO DEBUG] This block is considered natural by mcMMO");
UserManager.getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
pluginRef.getUserManager().getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
}
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (plugin.getWorldGuardManager().hasMainFlag(player))
if (pluginRef.getWorldGuardManager().hasMainFlag(player))
player.sendMessage("[mcMMO DEBUG] World Guard main flag is permitted for this player in this region");
else
player.sendMessage("[mcMMO DEBUG] World Guard main flag is DENIED for this player in this region");
if (plugin.getWorldGuardManager().hasXPFlag(player))
if (pluginRef.getWorldGuardManager().hasXPFlag(player))
player.sendMessage("[mcMMO DEBUG] World Guard xp flag is permitted for this player in this region");
else
player.sendMessage("[mcMMO DEBUG] World Guard xp flag is not permitted for this player in this region");

View File

@ -18,7 +18,6 @@ import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
@ -368,7 +367,7 @@ public class EntityListener implements Listener {
}
//Deflect checks
UnarmedManager unarmedManager = UserManager.getPlayer(defendingPlayer).getUnarmedManager();
UnarmedManager unarmedManager = pluginRef.getUserManager().getPlayer(defendingPlayer).getUnarmedManager();
if (unarmedManager.canDeflect()) {
if(unarmedManager.deflectCheck()) {
@ -423,7 +422,7 @@ public class EntityListener implements Listener {
}
public boolean checkParties(Cancellable event, Player defendingPlayer, Player attackingPlayer) {
if (!UserManager.hasPlayerDataKey(defendingPlayer) || !UserManager.hasPlayerDataKey(attackingPlayer)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(defendingPlayer) || !pluginRef.getUserManager().hasPlayerDataKey(attackingPlayer)) {
return true;
}
@ -510,11 +509,11 @@ public class EntityListener implements Listener {
if (livingEntity instanceof Player) {
Player player = (Player) entity;
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
//Profile not loaded
if (mcMMOPlayer == null)
@ -548,11 +547,11 @@ public class EntityListener implements Listener {
Wolf wolf = (Wolf) pet;
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
TamingManager tamingManager = UserManager.getPlayer(player).getTamingManager();
TamingManager tamingManager = pluginRef.getUserManager().getPlayer(player).getTamingManager();
switch (cause) {
case CONTACT:
@ -721,12 +720,12 @@ public class EntityListener implements Listener {
// using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
@ -736,7 +735,7 @@ public class EntityListener implements Listener {
return;
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
MiningManager miningManager = pluginRef.getUserManager().getPlayer(player).getMiningManager();
if (miningManager.canUseBiggerBombs()) {
event.setRadius(miningManager.biggerBombs(event.getRadius()));
@ -764,7 +763,7 @@ public class EntityListener implements Listener {
// using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
@ -775,11 +774,11 @@ public class EntityListener implements Listener {
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
MiningManager miningManager = pluginRef.getUserManager().getPlayer(player).getMiningManager();
if (miningManager.canUseBlastMining()) {
miningManager.blastMiningDropProcessing(event.getYield(), event.blockList());
@ -827,7 +826,7 @@ public class EntityListener implements Listener {
Player player = (Player) entity;
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
@ -837,7 +836,7 @@ public class EntityListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
@ -898,7 +897,7 @@ public class EntityListener implements Listener {
*/
case POTATO: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
event.setFoodLevel(pluginRef.getUserManager().getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
}
return;
case COD:
@ -907,7 +906,7 @@ public class EntityListener implements Listener {
case COOKED_COD:
case COOKED_SALMON:
if (Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_FISHERMANS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(newFoodLevel));
event.setFoodLevel(pluginRef.getUserManager().getPlayer(player).getFishingManager().handleFishermanDiet(newFoodLevel));
}
return;
@ -940,7 +939,7 @@ public class EntityListener implements Listener {
LivingEntity entity = event.getEntity();
if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntityExcludingVillagers(entity) || entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || Misc.isNPCEntityExcludingVillagers(entity) || entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) {
return;
}
@ -949,12 +948,12 @@ public class EntityListener implements Listener {
//Profile not loaded
//TODO: Redundant
/*if(UserManager.getPlayer(player) == null)
/*if(pluginRef.getUserManager().getPlayer(player) == null)
{
return;
}*/
UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity);
pluginRef.getUserManager().getPlayer(player).getTamingManager().awardTamingXP(entity);
}
@ -986,7 +985,7 @@ public class EntityListener implements Listener {
Tameable tameable = (Tameable) entity;
if (!UserManager.hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) {
return;
}

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.player.PlayerUpdateInventoryTask;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.Material;
@ -49,17 +48,17 @@ public class InventoryListener implements Listener {
HumanEntity player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
//Profile not loaded
if (UserManager.getPlayer((Player) player) == null) {
if (pluginRef.getUserManager().getPlayer((Player) player) == null) {
return;
}
if (!furnaceBlock.hasMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY) && furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY).size() == 0)
furnaceBlock.setMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, UserManager.getPlayer((Player) player).getPlayerMetadata());
furnaceBlock.setMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, pluginRef.getUserManager().getPlayer((Player) player).getPlayerMetadata());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@ -76,7 +75,7 @@ public class InventoryListener implements Listener {
HumanEntity player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
@ -105,16 +104,16 @@ public class InventoryListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player) || !Permissions.isSubSkillEnabled(player, SubSkillType.SMELTING_FUEL_EFFICIENCY)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !Permissions.isSubSkillEnabled(player, SubSkillType.SMELTING_FUEL_EFFICIENCY)) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime()));
event.setBurnTime(pluginRef.getUserManager().getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime()));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -138,16 +137,16 @@ public class InventoryListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.SMELTING.getPermissions(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.SMELTING.getPermissions(player)) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(smelting, event.getResult()));
event.setResult(pluginRef.getUserManager().getPlayer(player).getSmeltingManager().smeltProcessing(smelting, event.getResult()));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -170,17 +169,17 @@ public class InventoryListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, PrimarySkillType.SMELTING)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, PrimarySkillType.SMELTING)) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
int xpToDrop = event.getExpToDrop();
int exp = UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(xpToDrop);
int exp = pluginRef.getUserManager().getPlayer(player).getSmeltingManager().vanillaXPBoost(xpToDrop);
event.setExpToDrop(exp);
}
@ -201,11 +200,11 @@ public class InventoryListener implements Listener {
furnaceBlock.removeMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, pluginRef);
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
furnaceBlock.setMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, UserManager.getPlayer(player).getPlayerMetadata());
furnaceBlock.setMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, pluginRef.getUserManager().getPlayer(player).getPlayerMetadata());
}
}
@ -225,7 +224,7 @@ public class InventoryListener implements Listener {
//TODO: This is where Alchemy permissions used to be checked
//TODO: This is where Alchemy permissions used to be checked
//TODO: This is where Alchemy permissions used to be checked
/*if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
/*if (!pluginRef.getUserManager().hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
return;
}*/
@ -335,7 +334,7 @@ public class InventoryListener implements Listener {
//TODO: This is where alchemy permissions used to be checked
//TODO: This is where alchemy permissions used to be checked
//TODO: This is where alchemy permissions used to be checked
/*if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
/*if (!pluginRef.getUserManager().hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
return;
}*/

View File

@ -22,7 +22,6 @@ import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
@ -76,20 +75,20 @@ public class PlayerListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player) || event.getFrom().equals(event.getTo())) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || event.getFrom().equals(event.getTo())) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
if (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
UserManager.getPlayer(player).actualizeTeleportATS();
pluginRef.getUserManager().getPlayer(player).actualizeTeleportATS();
UserManager.getPlayer(player).actualizeTeleportATS();
pluginRef.getUserManager().getPlayer(player).actualizeTeleportATS();
}
/**
@ -188,16 +187,16 @@ public class PlayerListener implements Listener {
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
mcMMOPlayer.checkGodMode();
mcMMOPlayer.checkParty();
@ -256,16 +255,16 @@ public class PlayerListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
FishingManager fishingManager = pluginRef.getUserManager().getPlayer(player).getFishingManager();
switch (event.getState()) {
case CAUGHT_FISH:
@ -331,17 +330,17 @@ public class PlayerListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
Entity caught = event.getCaught();
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
FishingManager fishingManager = pluginRef.getUserManager().getPlayer(player).getFishingManager();
//Track the hook
if (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits()) {
@ -424,16 +423,16 @@ public class PlayerListener implements Listener {
return;
}
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
Item drop = event.getItem();
//Remove tracking
@ -483,16 +482,16 @@ public class PlayerListener implements Listener {
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
//There's an issue with using Async saves on player quit
//Basically there are conditions in which an async task does not execute fast enough to save the data if the server shutdown shortly after this task was scheduled
mcMMOPlayer.logout(true);
@ -545,16 +544,16 @@ public class PlayerListener implements Listener {
public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
UserManager.getPlayer(player).actualizeRespawnATS();
pluginRef.getUserManager().getPlayer(player).actualizeRespawnATS();
}
/**
@ -576,16 +575,16 @@ public class PlayerListener implements Listener {
return;
}
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
if (event.getHand() != EquipmentSlot.HAND || !pluginRef.getUserManager().hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
MiningManager miningManager = mcMMOPlayer.getMiningManager();
Block block = event.getClickedBlock();
ItemStack heldItem = player.getInventory().getItemInMainHand();
@ -615,7 +614,7 @@ public class PlayerListener implements Listener {
&& RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)
&& pluginRef.getSalvageableManager().isSalvageable(heldItem)
&& heldItem.getAmount() <= 1) {
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
SalvageManager salvageManager = pluginRef.getUserManager().getPlayer(player).getSalvageManager();
event.setCancelled(true);
// Make sure the player knows what he's doing when trying to salvage an enchanted item
@ -689,16 +688,16 @@ public class PlayerListener implements Listener {
return;
}
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
if (event.getHand() != EquipmentSlot.HAND || !pluginRef.getUserManager().hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
ItemStack heldItem = player.getInventory().getItemInMainHand();
//Spam Fishing Detection
@ -836,11 +835,11 @@ public class PlayerListener implements Listener {
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntityExcludingVillagers(player) || !UserManager.hasPlayerDataKey(player)) {
if (Misc.isNPCEntityExcludingVillagers(player) || !pluginRef.getUserManager().hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getOfflinePlayer(player);
if (mcMMOPlayer == null) {
pluginRef.debug(player.getName() + "is chatting, but is currently not logged in to the server.");

View File

@ -8,8 +8,6 @@ import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.PlayerLevelUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.entity.Player;
@ -34,14 +32,14 @@ public class SelfListener implements Listener {
for (int i = 0; i < event.getLevelsGained(); i++) {
int previousLevelGained = event.getSkillLevel() - i;
//Send player skill unlock notifications
UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained);
pluginRef.getUserManager().getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained);
}
//Reset the delay timer
RankUtils.resetUnlockDelayTimer();
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled())
ScoreboardManager.handleLevelUp(player, skill);
pluginRef.getScoreboardManager().handleLevelUp(player, skill);
/*if ((event.getSkillLevel() % Config.getInstance().getLevelUpEffectsTier()) == 0) {
skill.celebrateLevelUp(player);
@ -51,19 +49,19 @@ public class SelfListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerXp(McMMOPlayerXpGainEvent event) {
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled())
ScoreboardManager.handleXp(event.getPlayer(), event.getSkill());
pluginRef.getScoreboardManager().handleXp(event.getPlayer(), event.getSkill());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onAbility(McMMOPlayerAbilityActivateEvent event) {
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled())
ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill());
pluginRef.getScoreboardManager().cooldownUpdate(event.getPlayer(), event.getSkill());
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
Player player = event.getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
PrimarySkillType primarySkillType = event.getSkill();
//WorldGuard XP Check

View File

@ -74,6 +74,8 @@ public class mcMMO extends JavaPlugin {
private ChatManager chatManager;
private MobHealthBarManager mobHealthBarManager;
private EventManager eventManager;
private UserManager userManager;
private ScoreboardManager scoreboardManager;
/* Not-Managers but my naming scheme sucks */
private CommandTools commandTools;
@ -212,6 +214,12 @@ public class mcMMO extends JavaPlugin {
//Init Command Tools
//TODO: Better name?
commandTools = new CommandTools(this);
//Init User Manager
userManager = new UserManager(this);
//Init Scoreboard Manager
scoreboardManager = new ScoreboardManager(this);
}
@Override
@ -230,13 +238,13 @@ public class mcMMO extends JavaPlugin {
@Override
public void onDisable() {
try {
UserManager.saveAll(); // Make sure to save player information if the server shuts down
UserManager.clearAll();
getPartyManager().saveParties(); // Save our parties
userManager.saveAll(); // Make sure to save player information if the server shuts down
userManager.clearAll();
partyManager.saveParties(); // Save our parties
//TODO: Needed?
if (getScoreboardSettings().getScoreboardsEnabled())
ScoreboardManager.teardownAll();
scoreboardManager.teardownAll();
placeStore.saveAll(); // Save our metadata
placeStore.cleanUp(); // Cleanup empty metadata stores
@ -658,4 +666,12 @@ public class mcMMO extends JavaPlugin {
public DatabaseManagerFactory getDatabaseManagerFactory() {
return databaseManagerFactory;
}
public UserManager getUserManager() {
return userManager;
}
public ScoreboardManager getScoreboardManager() {
return scoreboardManager;
}
}

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.OfflinePlayer;
@ -38,7 +37,7 @@ public final class PartyManager {
}
public boolean canTeleport(CommandSender sender, Player player, String targetName) {
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
McMMOPlayer mcMMOTarget = pluginRef.getUserManager().getPlayer(targetName);
if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
@ -70,18 +69,18 @@ public final class PartyManager {
}
public void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
if (UserManager.getPlayer(targetPlayer) == null) {
if (pluginRef.getUserManager().getPlayer(targetPlayer) == null) {
targetPlayer.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return;
}
if (UserManager.getPlayer(teleportingPlayer) == null) {
if (pluginRef.getUserManager().getPlayer(teleportingPlayer) == null) {
teleportingPlayer.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad"));
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = pluginRef.getUserManager().getPlayer(targetPlayer);
long warmup = pluginRef.getConfigManager().getConfigParty().getPTP().getPtpWarmup();
@ -172,17 +171,17 @@ public final class PartyManager {
return false;
//Profile not loaded
if (UserManager.getPlayer(firstPlayer) == null) {
if (pluginRef.getUserManager().getPlayer(firstPlayer) == null) {
return false;
}
//Profile not loaded
if (UserManager.getPlayer(secondPlayer) == null) {
if (pluginRef.getUserManager().getPlayer(secondPlayer) == null) {
return false;
}
Party firstParty = UserManager.getPlayer(firstPlayer).getParty();
Party secondParty = UserManager.getPlayer(secondPlayer).getParty();
Party firstParty = pluginRef.getUserManager().getPlayer(firstPlayer).getParty();
Party secondParty = pluginRef.getUserManager().getPlayer(secondPlayer).getParty();
if (firstParty == null || secondParty == null) {
return false;
@ -197,17 +196,17 @@ public final class PartyManager {
return false;
//Profile not loaded
if (UserManager.getPlayer(firstPlayer) == null) {
if (pluginRef.getUserManager().getPlayer(firstPlayer) == null) {
return false;
}
//Profile not loaded
if (UserManager.getPlayer(secondPlayer) == null) {
if (pluginRef.getUserManager().getPlayer(secondPlayer) == null) {
return false;
}
Party firstParty = UserManager.getPlayer(firstPlayer).getParty();
Party secondParty = UserManager.getPlayer(secondPlayer).getParty();
Party firstParty = pluginRef.getUserManager().getPlayer(firstPlayer).getParty();
Party secondParty = pluginRef.getUserManager().getPlayer(secondPlayer).getParty();
if (firstParty == null || secondParty == null || firstParty.getAlly() == null || secondParty.getAlly() == null) {
return false;
@ -373,11 +372,11 @@ public final class PartyManager {
*/
public Party getParty(Player player) {
//Profile not loaded
if (UserManager.getPlayer(player) == null) {
if (pluginRef.getUserManager().getPlayer(player) == null) {
return null;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
return mcMMOPlayer.getParty();
}
@ -438,11 +437,11 @@ public final class PartyManager {
//TODO: Potential issues with unloaded profile?
for (Player member : party.getOnlineMembers()) {
//Profile not loaded
if (UserManager.getPlayer(member) == null) {
if (pluginRef.getUserManager().getPlayer(member) == null) {
continue;
}
processPartyLeaving(UserManager.getPlayer(member));
processPartyLeaving(pluginRef.getUserManager().getPlayer(member));
}
// Disband the alliance between the disbanded party and it's ally

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.Material;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
@ -55,11 +54,11 @@ public final class ShareHandler {
for (Player member : nearMembers) {
//Profile not loaded
if (UserManager.getPlayer(member) == null) {
if (pluginRef.getUserManager().getPlayer(member) == null) {
continue;
}
UserManager.getPlayer(member).beginUnsharedXpGain(primarySkillType, splitXp, xpGainReason, XPGainSource.PARTY_MEMBERS);
pluginRef.getUserManager().getPlayer(member).beginUnsharedXpGain(primarySkillType, splitXp, xpGainReason, XPGainSource.PARTY_MEMBERS);
}
return true;
@ -113,10 +112,10 @@ public final class ShareHandler {
int highestRoll = 0;
for (Player member : nearMembers) {
McMMOPlayer mcMMOMember = UserManager.getPlayer(member);
McMMOPlayer mcMMOMember = pluginRef.getUserManager().getPlayer(member);
//Profile not loaded
if (UserManager.getPlayer(member) == null) {
if (pluginRef.getUserManager().getPlayer(member) == null) {
continue;
}
@ -131,14 +130,14 @@ public final class ShareHandler {
highestRoll = diceRoll;
if (winningPlayer != null) {
McMMOPlayer mcMMOWinning = UserManager.getPlayer(winningPlayer);
McMMOPlayer mcMMOWinning = pluginRef.getUserManager().getPlayer(winningPlayer);
mcMMOWinning.setItemShareModifier(mcMMOWinning.getItemShareModifier() + itemWeight);
}
winningPlayer = member;
}
McMMOPlayer mcMMOTarget = UserManager.getPlayer(winningPlayer);
McMMOPlayer mcMMOTarget = pluginRef.getUserManager().getPlayer(winningPlayer);
mcMMOTarget.setItemShareModifier(mcMMOTarget.getItemShareModifier() - itemWeight);
awardDrop(winningPlayer, newStack);
}

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.runnables;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.scheduler.BukkitRunnable;
public class SaveTimerTask extends BukkitRunnable {
@ -11,7 +10,7 @@ public class SaveTimerTask extends BukkitRunnable {
// All player data will be saved periodically through this
int count = 1;
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
for (McMMOPlayer mcMMOPlayer : pluginRef.getUserManager().getPlayers()) {
new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false).runTaskLaterAsynchronously(pluginRef, count);
count++;
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -13,8 +12,8 @@ public class McScoreboardKeepTask extends BukkitRunnable {
@Override
public void run() {
if (player.isValid() && ScoreboardManager.isBoardShown(player.getName())) {
ScoreboardManager.keepBoard(player.getName());
if (player.isValid() && pluginRef.getScoreboardManager().isBoardShown(player.getName())) {
pluginRef.getScoreboardManager().keepBoard(player.getName());
}
}
}

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -60,9 +59,9 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
public void displayBoard() {
if (sender.getName().equalsIgnoreCase(playerName)) {
ScoreboardManager.showPlayerRankScoreboard((Player) sender, skills);
pluginRef.getScoreboardManager().showPlayerRankScoreboard((Player) sender, skills);
} else {
ScoreboardManager.showPlayerRankScoreboardOthers((Player) sender, playerName, skills);
pluginRef.getScoreboardManager().showPlayerRankScoreboardOthers((Player) sender, playerName, skills);
}
}
}

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -81,9 +80,9 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
private void displayBoard() {
if (skill == null) {
ScoreboardManager.showTopPowerScoreboard((Player) sender, page, userStats);
pluginRef.getScoreboardManager().showTopPowerScoreboard((Player) sender, page, userStats);
} else {
ScoreboardManager.showTopScoreboard((Player) sender, skill, page, userStats);
pluginRef.getScoreboardManager().showTopScoreboard((Player) sender, skill, page, userStats);
}
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables.commands;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -10,8 +9,8 @@ public class NotifySquelchReminderTask extends BukkitRunnable {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
if (UserManager.getPlayer(player) != null) {
if (!UserManager.getPlayer(player).useChatNotifications()) {
if (pluginRef.getUserManager().getPlayer(player) != null) {
if (!pluginRef.getUserManager().getPlayer(player).useChatNotifications()) {
player.sendMessage(pluginRef.getLocaleManager().getString("Reminder.Squelched"));
}
}

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
@ -24,7 +23,7 @@ public class FormulaConversionTask extends BukkitRunnable {
int convertedUsers = 0;
long startMillis = System.currentTimeMillis();
for (String playerName : pluginRef.getDatabaseManager().getStoredUsers()) {
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getOfflinePlayer(playerName);
PlayerProfile 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.

View File

@ -1,13 +1,12 @@
package com.gmail.nossr50.runnables.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.scheduler.BukkitRunnable;
public class ClearRegisteredXPGainTask extends BukkitRunnable {
@Override
public void run() {
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
for (McMMOPlayer mcMMOPlayer : pluginRef.getUserManager().getPlayers()) {
mcMMOPlayer.getProfile().purgeExpiredXpGains();
}
}

View File

@ -4,8 +4,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.runnables.commands.McScoreboardKeepTask;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -81,14 +79,14 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
}
mcMMOPlayer.setupPartyData();
UserManager.track(mcMMOPlayer);
pluginRef.getUserManager().track(mcMMOPlayer);
mcMMOPlayer.actualizeRespawnATS();
if (pluginRef.getScoreboardSettings().getScoreboardsEnabled()) {
ScoreboardManager.setupPlayer(player);
pluginRef.getScoreboardManager().setupPlayer(player);
if (pluginRef.getScoreboardSettings().getShowStatsAfterLogin()) {
ScoreboardManager.enablePlayerStatsScoreboard(player);
pluginRef.getScoreboardManager().enablePlayerStatsScoreboard(player);
new McScoreboardKeepTask(player).runTaskLater(pluginRef, Misc.TICK_CONVERSION_FACTOR);
}
}

View File

@ -1,12 +1,11 @@
package com.gmail.nossr50.runnables.player;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.scheduler.BukkitRunnable;
public class PowerLevelUpdatingTask extends BukkitRunnable {
@Override
public void run() {
if (!ScoreboardManager.powerLevelHeartbeat()) {
if (!pluginRef.getScoreboardManager().powerLevelHeartbeat()) {
this.cancel();
}
}

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.mining;
import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
@ -44,7 +43,7 @@ public class BlastMining {
}
public static boolean processBlastMiningExplosion(EntityDamageByEntityEvent event, TNTPrimed tnt, Player defender) {
if (!tnt.hasMetadata(MetadataConstants.TNT_TRACKING_METAKEY) || !UserManager.hasPlayerDataKey(defender)) {
if (!tnt.hasMetadata(MetadataConstants.TNT_TRACKING_METAKEY) || !pluginRef.getUserManager().hasPlayerDataKey(defender)) {
return false;
}
@ -55,11 +54,11 @@ public class BlastMining {
return false;
}
if (UserManager.getPlayer(defender) == null) {
if (pluginRef.getUserManager().getPlayer(defender) == null) {
return false;
}
MiningManager miningManager = UserManager.getPlayer(defender).getMiningManager();
MiningManager miningManager = pluginRef.getUserManager().getPlayer(defender).getMiningManager();
if (!miningManager.canUseDemolitionsExpertise()) {
return false;

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
@ -98,13 +97,13 @@ public class UnarmedManager extends SkillManager {
return;
}
if (UserManager.getPlayer(defender) == null)
if (pluginRef.getUserManager().getPlayer(defender) == null)
return;
Item item = Misc.dropItem(defender.getLocation(), defender.getInventory().getItemInMainHand());
if (item != null && pluginRef.getConfigManager().getConfigUnarmed().doesDisarmPreventTheft()) {
item.setMetadata(MetadataConstants.DISARMED_ITEM_METAKEY, UserManager.getPlayer(defender).getPlayerMetadata());
item.setMetadata(MetadataConstants.DISARMED_ITEM_METAKEY, pluginRef.getUserManager().getPlayer(defender).getPlayerMetadata());
}
defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR));

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.util;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
@ -49,7 +48,7 @@ public final class ChimaeraWing {
return;
}
mcMMOPlayer = UserManager.getPlayer(player);
mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
//Not loaded
if (mcMMOPlayer == null)

View File

@ -31,7 +31,6 @@ import com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
@ -83,7 +82,7 @@ public class EventManager {
* @return the associated McMMOPlayer for this entity
*/
public McMMOPlayer getMcMMOPlayer(Entity entity) {
return UserManager.getPlayer((Player) entity);
return pluginRef.getUserManager().getPlayer((Player) entity);
}
/**
@ -141,11 +140,11 @@ public class EventManager {
if (livingEntity instanceof Player) {
Player player = (Player) entity;
if (!UserManager.hasPlayerDataKey(player)) {
if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (mcMMOPlayer == null) {
return true;
@ -216,7 +215,7 @@ public class EventManager {
boolean isCancelled = event.isCancelled();
if (isCancelled) {
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
PlayerProfile profile = pluginRef.getUserManager().getPlayer(player).getProfile();
profile.modifySkill(skill, profile.getSkillLevel(skill) - (isLevelUp ? levelsChanged : -levelsChanged));
profile.addXp(skill, xpRemoved);
@ -232,7 +231,7 @@ public class EventManager {
boolean isCancelled = event.isCancelled();
if (isCancelled) {
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
PlayerProfile profile = pluginRef.getUserManager().getPlayer(player).getProfile();
profile.modifySkill(skill, profile.getSkillLevel(skill) - (isLevelUp ? levelsChanged : -levelsChanged));
profile.addXp(skill, xpRemoved);
@ -267,7 +266,7 @@ public class EventManager {
}
public void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(teleportingPlayer);
if (mcMMOPlayer == null)
return;
@ -322,15 +321,15 @@ public class EventManager {
boolean isCancelled = event.isCancelled();
if (!isCancelled) {
UserManager.getPlayer(player).addXp(skill, event.getRawXpGained());
UserManager.getPlayer(player).getProfile().registerXpGain(skill, event.getRawXpGained());
pluginRef.getUserManager().getPlayer(player).addXp(skill, event.getRawXpGained());
pluginRef.getUserManager().getPlayer(player).getProfile().registerXpGain(skill, event.getRawXpGained());
}
return !isCancelled;
}
public boolean handleStatsLossEvent(Player player, HashMap<String, Integer> levelChanged, HashMap<String, Double> experienceChanged) {
if (UserManager.getPlayer(player) == null)
if (pluginRef.getUserManager().getPlayer(player) == null)
return true;
McMMOPlayerStatLossEvent event = new McMMOPlayerStatLossEvent(player, levelChanged, experienceChanged);
@ -341,7 +340,7 @@ public class EventManager {
if (!isCancelled) {
levelChanged = event.getLevelChanged();
experienceChanged = event.getExperienceChanged();
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
PlayerProfile playerProfile = pluginRef.getUserManager().getPlayer(player).getProfile();
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
String skillName = primarySkillType.toString();
@ -378,17 +377,17 @@ public class EventManager {
HashMap<String, Integer> levelChangedVictim = eventVictim.getLevelChanged();
HashMap<String, Double> experienceChangedVictim = eventVictim.getExperienceChanged();
McMMOPlayer killerPlayer = UserManager.getPlayer(killer);
McMMOPlayer killerPlayer = pluginRef.getUserManager().getPlayer(killer);
//Not loaded
if (killerPlayer == null)
return true;
//Not loaded
if (UserManager.getPlayer(victim) == null)
if (pluginRef.getUserManager().getPlayer(victim) == null)
return true;
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
PlayerProfile victimProfile = pluginRef.getUserManager().getPlayer(victim).getProfile();
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
String skillName = primarySkillType.toString();

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.util;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.entity.Player;
@ -25,10 +24,10 @@ public final class HardcoreManager {
double statLossPercentage = pluginRef.getConfigManager().getConfigHardcore().getDeathPenalty().getPenaltyPercentage();
int levelThreshold = pluginRef.getConfigManager().getConfigHardcore().getDeathPenalty().getLevelThreshold();
if (UserManager.getPlayer(player) == null)
if (pluginRef.getUserManager().getPlayer(player) == null)
return;
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
PlayerProfile playerProfile = pluginRef.getUserManager().getPlayer(player).getProfile();
int totalLevelsLost = 0;
HashMap<String, Integer> levelChanged = new HashMap<>();
@ -77,11 +76,11 @@ public final class HardcoreManager {
double vampirismStatLeechPercentage = pluginRef.getConfigManager().getConfigHardcore().getVampirism().getPenaltyPercentage();
int levelThreshold = pluginRef.getConfigManager().getConfigHardcore().getVampirism().getLevelThreshold();
if (UserManager.getPlayer(killer) == null || UserManager.getPlayer(victim) == null)
if (pluginRef.getUserManager().getPlayer(killer) == null || pluginRef.getUserManager().getPlayer(victim) == null)
return;
PlayerProfile killerProfile = UserManager.getPlayer(killer).getProfile();
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
PlayerProfile killerProfile = pluginRef.getUserManager().getPlayer(killer).getProfile();
PlayerProfile victimProfile = pluginRef.getUserManager().getPlayer(victim).getProfile();
int totalLevelsStolen = 0;
HashMap<String, Integer> levelChanged = new HashMap<>();

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.util;
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableSet;
import org.bukkit.Location;
import org.bukkit.Material;
@ -176,7 +175,7 @@ public final class Misc {
Player player = pluginRef.getServer().getPlayerExact(playerName);
if (player != null) {
UserManager.remove(player);
pluginRef.getUserManager().remove(player);
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
}

View File

@ -5,8 +5,8 @@ import com.gmail.nossr50.commands.admin.ReloadLocaleCommand;
import com.gmail.nossr50.commands.chat.AdminChatCommand;
import com.gmail.nossr50.commands.chat.ChatSpyCommand;
import com.gmail.nossr50.commands.chat.PartyChatCommand;
import com.gmail.nossr50.commands.database.PurgeCommand;
import com.gmail.nossr50.commands.database.McremoveCommand;
import com.gmail.nossr50.commands.database.PurgeCommand;
import com.gmail.nossr50.commands.database.ShowDatabaseCommand;
import com.gmail.nossr50.commands.experience.AddLevelsCommand;
import com.gmail.nossr50.commands.experience.AddXPCommand;

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
@ -206,10 +205,10 @@ public final class CommandTools {
}
private void printGroupedSkillData(Player inspect, CommandSender display, String header, List<PrimarySkillType> skillGroup) {
if (UserManager.getPlayer(inspect) == null)
if (pluginRef.getUserManager().getPlayer(inspect) == null)
return;
PlayerProfile profile = UserManager.getPlayer(inspect).getProfile();
PlayerProfile profile = pluginRef.getUserManager().getPlayer(inspect).getProfile();
List<String> displayData = new ArrayList<>();
displayData.add(header);

View File

@ -62,7 +62,7 @@ public class NotificationManager {
* @param key the locale key for the notifications defined message
*/
public void sendPlayerInformation(Player player, NotificationType notificationType, String key) {
if (UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
if (pluginRef.getUserManager().getPlayer(player) == null || !pluginRef.getUserManager().getPlayer(player).useChatNotifications())
return;
TextComponent textComponent = TextComponentFactory.getNotificationTextComponentFromLocale(key);
@ -106,7 +106,7 @@ public class NotificationManager {
public void sendPlayerInformationChatOnly(Player player, String key, String... values)
{
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
if(pluginRef.getUserManager().getPlayer(player) == null || !pluginRef.getUserManager().getPlayer(player).useChatNotifications())
return;
String preColoredString = pluginRef.getLocaleManager().getString(key, (Object[]) values);
@ -115,7 +115,7 @@ public class NotificationManager {
public void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values)
{
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
if(pluginRef.getUserManager().getPlayer(player) == null || !pluginRef.getUserManager().getPlayer(player).useChatNotifications())
return;
TextComponent textComponent = buildTextComponent(key, values);
@ -263,9 +263,9 @@ public class NotificationManager {
}
public boolean doesPlayerUseNotifications(Player player) {
if (UserManager.getPlayer(player) == null)
if (pluginRef.getUserManager().getPlayer(player) == null)
return false;
else
return UserManager.getPlayer(player).useChatNotifications();
return pluginRef.getUserManager().getPlayer(player).useChatNotifications();
}
}

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.util.player;
import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Entity;
@ -14,9 +15,13 @@ import java.util.HashSet;
public final class UserManager {
private UserManager() {
private mcMMO pluginRef;
public UserManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
private static HashSet<McMMOPlayer> playerDataSet; //Used to track players for sync saves on shutdown
private HashSet<McMMOPlayer> playerDataSet; //Used to track players for sync saves on shutdown
/**
@ -24,7 +29,7 @@ public final class UserManager {
*
* @param mcMMOPlayer the player profile to start tracking
*/
public static void track(McMMOPlayer mcMMOPlayer) {
public void track(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().setMetadata(MetadataConstants.PLAYER_DATA_METAKEY, new FixedMetadataValue(pluginRef, mcMMOPlayer));
if(playerDataSet == null)
@ -33,7 +38,7 @@ public final class UserManager {
playerDataSet.add(mcMMOPlayer); //for sync saves on shutdown
}
public static void cleanupPlayer(McMMOPlayer mcMMOPlayer) {
public void cleanupPlayer(McMMOPlayer mcMMOPlayer) {
if(playerDataSet != null && playerDataSet.contains(mcMMOPlayer))
playerDataSet.remove(mcMMOPlayer);
}
@ -43,7 +48,7 @@ public final class UserManager {
*
* @param player The Player object
*/
public static void remove(Player player) {
public void remove(Player player) {
McMMOPlayer mcMMOPlayer = getPlayer(player);
player.removeMetadata(MetadataConstants.PLAYER_DATA_METAKEY, pluginRef);
@ -54,7 +59,7 @@ public final class UserManager {
/**
* Clear all users.
*/
public static void clearAll() {
public void clearAll() {
for (Player player : pluginRef.getServer().getOnlinePlayers()) {
remove(player);
}
@ -66,7 +71,7 @@ public final class UserManager {
/**
* Save all users ON THIS THREAD.
*/
public static void saveAll() {
public void saveAll() {
if(playerDataSet == null)
return;
@ -89,7 +94,7 @@ public final class UserManager {
pluginRef.getLogger().info("Finished save operation for "+trackedSyncData.size()+" players!");
}
public static Collection<McMMOPlayer> getPlayers() {
public Collection<McMMOPlayer> getPlayers() {
Collection<McMMOPlayer> playerCollection = new ArrayList<>();
for (Player player : pluginRef.getServer().getOnlinePlayers()) {
@ -107,11 +112,11 @@ public final class UserManager {
* @param playerName The name of the player whose McMMOPlayer to retrieve
* @return the player's McMMOPlayer object
*/
public static McMMOPlayer getPlayer(String playerName) {
public McMMOPlayer getPlayer(String playerName) {
return retrieveMcMMOPlayer(playerName, false);
}
public static McMMOPlayer getOfflinePlayer(OfflinePlayer player) {
public McMMOPlayer getOfflinePlayer(OfflinePlayer player) {
if (player instanceof Player) {
return getPlayer((Player) player);
}
@ -119,7 +124,7 @@ public final class UserManager {
return retrieveMcMMOPlayer(player.getName(), true);
}
public static McMMOPlayer getOfflinePlayer(String playerName) {
public McMMOPlayer getOfflinePlayer(String playerName) {
return retrieveMcMMOPlayer(playerName, true);
}
@ -129,7 +134,7 @@ public final class UserManager {
* @param player target player
* @return McMMOPlayer object for this player, null if Player has not been loaded
*/
public static McMMOPlayer getPlayer(Player player) {
public McMMOPlayer getPlayer(Player player) {
//Avoid Array Index out of bounds
if (player != null && player.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY))
return (McMMOPlayer) player.getMetadata(MetadataConstants.PLAYER_DATA_METAKEY).get(0).value();
@ -137,7 +142,7 @@ public final class UserManager {
return null;
}
private static McMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) {
private McMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) {
Player player = pluginRef.getServer().getPlayerExact(playerName);
if (player == null) {
@ -151,7 +156,7 @@ public final class UserManager {
return getPlayer(player);
}
public static boolean hasPlayerDataKey(Entity entity) {
public boolean hasPlayerDataKey(Entity entity) {
return entity != null && entity.hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY);
}
}

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.util.random;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player;
public class RandomChanceSkill implements RandomChanceExecution {
@ -20,7 +19,7 @@ public class RandomChanceSkill implements RandomChanceExecution {
this.probabilityCap = RandomChanceUtil.LINEAR_CURVE_VAR;
if (player != null)
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(primarySkillType);
this.skillLevel = pluginRef.getUserManager().getPlayer(player).getSkillLevel(primarySkillType);
else
this.skillLevel = 0;
@ -40,7 +39,7 @@ public class RandomChanceSkill implements RandomChanceExecution {
this.subSkillType = subSkillType;
if (player != null)
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(primarySkillType);
this.skillLevel = pluginRef.getUserManager().getPlayer(player).getSkillLevel(primarySkillType);
else
this.skillLevel = 0;

View File

@ -4,163 +4,61 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.events.scoreboard.McMMOScoreboardMakeboardEvent;
import com.gmail.nossr50.events.scoreboard.ScoreboardEventReason;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Manages the Scoreboards used to display a variety of mcMMO related information to the player
*/
public class ScoreboardManager {
static final Map<String, ScoreboardWrapper> PLAYER_SCOREBOARDS = new HashMap<>();
private final mcMMO pluginRef;
private final Map<String, ScoreboardWrapper> PLAYER_SCOREBOARDS = new HashMap<>();
// do not localize; these are internal identifiers
static final String SIDEBAR_OBJECTIVE = "mcmmo_sidebar";
static final String POWER_OBJECTIVE = "mcmmo_pwrlvl";
private final ScoreboardStrings scoreboardStrings;
static final String HEADER_STATS = pluginRef.getLocaleManager().getString("Scoreboard.Header.PlayerStats");
static final String HEADER_COOLDOWNS = pluginRef.getLocaleManager().getString("Scoreboard.Header.PlayerCooldowns");
static final String HEADER_RANK = pluginRef.getLocaleManager().getString("Scoreboard.Header.PlayerRank");
static final String TAG_POWER_LEVEL = pluginRef.getLocaleManager().getString("Scoreboard.Header.PowerLevel");
private List<String> dirtyPowerLevels = new ArrayList<>();
static final String POWER_LEVEL = pluginRef.getLocaleManager().getString("Scoreboard.Misc.PowerLevel");
static final String LABEL_POWER_LEVEL = POWER_LEVEL;
static final String LABEL_LEVEL = pluginRef.getLocaleManager().getString("Scoreboard.Misc.Level");
static final String LABEL_CURRENT_XP = pluginRef.getLocaleManager().getString("Scoreboard.Misc.CurrentXP");
static final String LABEL_REMAINING_XP = pluginRef.getLocaleManager().getString("Scoreboard.Misc.RemainingXP");
static final String LABEL_ABILITY_COOLDOWN = pluginRef.getLocaleManager().getString("Scoreboard.Misc.Cooldown");
static final String LABEL_OVERALL = pluginRef.getLocaleManager().getString("Scoreboard.Misc.Overall");
static final Map<PrimarySkillType, String> skillLabels;
static final Map<SuperAbilityType, String> abilityLabelsColored;
static final Map<SuperAbilityType, String> abilityLabelsSkill;
private static List<String> dirtyPowerLevels = new ArrayList<>();
/*
* Initializes the static properties of this class
*/
static {
/*
* We need immutable objects for our ConfigScoreboard's labels
*/
ImmutableMap.Builder<PrimarySkillType, String> skillLabelBuilder = ImmutableMap.builder();
ImmutableMap.Builder<SuperAbilityType, String> abilityLabelBuilder = ImmutableMap.builder();
ImmutableMap.Builder<SuperAbilityType, String> abilityLabelSkillBuilder = ImmutableMap.builder();
/*
* Builds the labels for our ScoreBoards
* Stylizes the targetBoard in a Rainbow Pattern
* This is off by default
*/
if (pluginRef.getScoreboardSettings().getUseRainbowSkillStyling()) {
// Everything but black, gray, gold
List<ChatColor> colors = Lists.newArrayList(
ChatColor.WHITE,
ChatColor.YELLOW,
ChatColor.LIGHT_PURPLE,
ChatColor.RED,
ChatColor.AQUA,
ChatColor.GREEN,
ChatColor.DARK_GRAY,
ChatColor.BLUE,
ChatColor.DARK_PURPLE,
ChatColor.DARK_RED,
ChatColor.DARK_AQUA,
ChatColor.DARK_GREEN,
ChatColor.DARK_BLUE);
Collections.shuffle(colors, Misc.getRandom());
int i = 0;
for (PrimarySkillType type : PrimarySkillType.values()) {
// Include child skills
skillLabelBuilder.put(type, getShortenedName(colors.get(i) + type.getName(), false));
if (type.getSuperAbility() != null) {
abilityLabelBuilder.put(type.getSuperAbility(), getShortenedName(colors.get(i) + type.getSuperAbility().getName()));
if (type == PrimarySkillType.MINING) {
abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, getShortenedName(colors.get(i) + SuperAbilityType.BLAST_MINING.getName()));
}
}
if (++i == colors.size()) {
i = 0;
}
}
}
/*
* Builds the labels for our ScoreBoards
* Stylizes the targetBoard using our normal color scheme
*/
else {
for (PrimarySkillType type : PrimarySkillType.values()) {
// Include child skills
skillLabelBuilder.put(type, getShortenedName(ChatColor.GREEN + type.getName()));
if (type.getSuperAbility() != null) {
abilityLabelBuilder.put(type.getSuperAbility(), formatAbility(type.getSuperAbility().getName()));
if (type == PrimarySkillType.MINING) {
abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, formatAbility(SuperAbilityType.BLAST_MINING.getName()));
}
}
}
}
for (SuperAbilityType type : SuperAbilityType.values()) {
abilityLabelSkillBuilder.put(type, formatAbility((type == SuperAbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA), type.getName()));
}
skillLabels = skillLabelBuilder.build();
abilityLabelsColored = abilityLabelBuilder.build();
abilityLabelsSkill = abilityLabelSkillBuilder.build();
}
private static String formatAbility(String abilityName) {
return formatAbility(ChatColor.AQUA, abilityName);
}
private static String formatAbility(ChatColor color, String abilityName) {
if (pluginRef.getScoreboardSettings().getUseAbilityNamesOverGenerics()) {
return getShortenedName(color + abilityName);
} else {
return color + pluginRef.getLocaleManager().getString("Scoreboard.Misc.Ability");
}
}
private static String getShortenedName(String name) {
return getShortenedName(name, true);
}
private static String getShortenedName(String name, boolean useDots) {
if (name.length() > 16) {
name = useDots ? name.substring(0, 14) + ".." : name.substring(0, 16);
}
return name;
public ScoreboardManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;
this.scoreboardStrings = new ScoreboardStrings(pluginRef);
}
// Called by PlayerJoinEvent listener
public static void setupPlayer(Player player) {
PLAYER_SCOREBOARDS.put(player.getName(), ScoreboardWrapper.create(player));
public void setupPlayer(Player player) {
PLAYER_SCOREBOARDS.put(player.getName(), create(player));
dirtyPowerLevels.add(player.getName());
}
public ScoreboardWrapper create(Player player) {
//TODO: Christ...
//Call our custom event
if(pluginRef.getServer().getScoreboardManager() != null) {
McMMOScoreboardMakeboardEvent event = new McMMOScoreboardMakeboardEvent(pluginRef.getServer().getScoreboardManager().getNewScoreboard(), player.getScoreboard(), player, ScoreboardEventReason.CREATING_NEW_SCOREBOARD);
player.getServer().getPluginManager().callEvent(event);
return new ScoreboardWrapper(event.getTargetPlayer(), event.getTargetBoard(), scoreboardStrings, pluginRef);
}
//Use the values from the event
return null;
}
// **** Listener call-ins **** //
// Called by PlayerQuitEvent listener
public static void teardownPlayer(Player player) {
public void teardownPlayer(Player player) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.remove(player.getName());
if (wrapper != null && wrapper.revertTask != null) {
@ -169,7 +67,7 @@ public class ScoreboardManager {
}
// Called in onDisable()
public static void teardownAll() {
public void teardownAll() {
ImmutableList<Player> onlinePlayers = ImmutableList.copyOf(pluginRef.getServer().getOnlinePlayers());
pluginRef.debug("Tearing down scoreboards... (" + onlinePlayers.size() + ")");
for (Player player : onlinePlayers) {
@ -178,7 +76,7 @@ public class ScoreboardManager {
}
// Called by ScoreboardWrapper when its Player logs off and an action tries to be performed
public static void cleanup(ScoreboardWrapper wrapper) {
public void cleanup(ScoreboardWrapper wrapper) {
PLAYER_SCOREBOARDS.remove(wrapper.playerName);
if (wrapper.revertTask != null) {
@ -187,7 +85,7 @@ public class ScoreboardManager {
}
// Called by internal level-up event listener
public static void handleLevelUp(Player player, PrimarySkillType skill) {
public void handleLevelUp(Player player, PrimarySkillType skill) {
// Selfboards
ScoreboardWrapper selfboardWrapper = PLAYER_SCOREBOARDS.get(player.getName());
@ -214,7 +112,7 @@ public class ScoreboardManager {
}
// Called by internal xp event listener
public static void handleXp(Player player, PrimarySkillType skill) {
public void handleXp(Player player, PrimarySkillType skill) {
// Selfboards
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
@ -224,7 +122,7 @@ public class ScoreboardManager {
}
// Called by internal ability event listeners
public static void cooldownUpdate(Player player, PrimarySkillType skill) {
public void cooldownUpdate(Player player, PrimarySkillType skill) {
// Selfboards
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
@ -233,7 +131,7 @@ public class ScoreboardManager {
}
}
public static void enablePlayerSkillScoreboard(Player player, PrimarySkillType skill) {
public void enablePlayerSkillScoreboard(Player player, PrimarySkillType skill) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
wrapper.setOldScoreboard();
@ -244,7 +142,7 @@ public class ScoreboardManager {
// **** Setup methods **** //
public static void enablePlayerSkillLevelUpScoreboard(Player player, PrimarySkillType skill) {
public void enablePlayerSkillLevelUpScoreboard(Player player, PrimarySkillType skill) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
// Do NOT run if already shown
@ -258,7 +156,7 @@ public class ScoreboardManager {
changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionSkillBoard().getShowBoardOnPlayerLevelUpTime());
}
public static void enablePlayerStatsScoreboard(Player player) {
public void enablePlayerStatsScoreboard(Player player) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
wrapper.setOldScoreboard();
@ -267,7 +165,7 @@ public class ScoreboardManager {
changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.STATS_BOARD));
}
public static void enablePlayerInspectScoreboard(Player player, PlayerProfile targetProfile) {
public void enablePlayerInspectScoreboard(Player player, PlayerProfile targetProfile) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
wrapper.setOldScoreboard();
@ -276,7 +174,7 @@ public class ScoreboardManager {
changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().getDisplayTimeInSeconds());
}
public static void enablePlayerCooldownScoreboard(Player player) {
public void enablePlayerCooldownScoreboard(Player player) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
wrapper.setOldScoreboard();
@ -285,7 +183,7 @@ public class ScoreboardManager {
changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.COOLDOWNS_BOARD));
}
public static void showPlayerRankScoreboard(Player player, Map<PrimarySkillType, Integer> rank) {
public void showPlayerRankScoreboard(Player player, Map<PrimarySkillType, Integer> rank) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
wrapper.setOldScoreboard();
@ -295,7 +193,7 @@ public class ScoreboardManager {
changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.RANK_BOARD));
}
public static void showPlayerRankScoreboardOthers(Player player, String targetName, Map<PrimarySkillType, Integer> rank) {
public void showPlayerRankScoreboardOthers(Player player, String targetName, Map<PrimarySkillType, Integer> rank) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
wrapper.setOldScoreboard();
@ -305,7 +203,7 @@ public class ScoreboardManager {
changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.RANK_BOARD));
}
public static void showTopScoreboard(Player player, PrimarySkillType skill, int pageNumber, List<PlayerStat> stats) {
public void showTopScoreboard(Player player, PrimarySkillType skill, int pageNumber, List<PlayerStat> stats) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
wrapper.setOldScoreboard();
@ -315,7 +213,7 @@ public class ScoreboardManager {
changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.TOP_BOARD));
}
public static void showTopPowerScoreboard(Player player, int pageNumber, List<PlayerStat> stats) {
public void showTopPowerScoreboard(Player player, int pageNumber, List<PlayerStat> stats) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
wrapper.setOldScoreboard();
@ -328,7 +226,7 @@ public class ScoreboardManager {
/**
* @return false if power levels are disabled
*/
public static boolean powerLevelHeartbeat() {
public boolean powerLevelHeartbeat() {
Objective mainObjective = getPowerLevelObjective();
if (mainObjective == null) {
@ -336,7 +234,7 @@ public class ScoreboardManager {
}
for (String playerName : dirtyPowerLevels) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(playerName);
if (mcMMOPlayer == null) {
continue;
@ -366,9 +264,9 @@ public class ScoreboardManager {
*
* @return the main targetBoard objective, or null if disabled
*/
public static Objective getPowerLevelObjective() {
public Objective getPowerLevelObjective() {
if (!pluginRef.getScoreboardSettings().getPowerLevelTagsEnabled()) {
Objective objective = pluginRef.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
Objective objective = pluginRef.getServer().getScoreboardManager().getMainScoreboard().getObjective(scoreboardStrings.POWER_OBJECTIVE);
if (objective != null) {
objective.unregister();
@ -378,18 +276,18 @@ public class ScoreboardManager {
return null;
}
Objective powerObjective = pluginRef.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
Objective powerObjective = pluginRef.getServer().getScoreboardManager().getMainScoreboard().getObjective(scoreboardStrings.POWER_OBJECTIVE);
if (powerObjective == null) {
powerObjective = pluginRef.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy");
powerObjective.setDisplayName(TAG_POWER_LEVEL);
powerObjective = pluginRef.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(scoreboardStrings.POWER_OBJECTIVE, "dummy");
powerObjective.setDisplayName(scoreboardStrings.TAG_POWER_LEVEL);
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
}
return powerObjective;
}
private static void changeScoreboard(ScoreboardWrapper wrapper, int displayTime) {
private void changeScoreboard(ScoreboardWrapper wrapper, int displayTime) {
if (displayTime == -1) {
wrapper.showBoardWithNoRevert();
} else {
@ -397,28 +295,23 @@ public class ScoreboardManager {
}
}
public static boolean isBoardShown(String playerName) {
public boolean isBoardShown(String playerName) {
return PLAYER_SCOREBOARDS.get(playerName).isBoardShown();
}
public static void clearBoard(String playerName) {
public void clearBoard(String playerName) {
PLAYER_SCOREBOARDS.get(playerName).tryRevertBoard();
}
public static void keepBoard(String playerName) {
public void keepBoard(String playerName) {
PLAYER_SCOREBOARDS.get(playerName).cancelRevert();
}
public static void setRevertTimer(String playerName, int seconds) {
public void setRevertTimer(String playerName, int seconds) {
PLAYER_SCOREBOARDS.get(playerName).showBoardAndScheduleRevert(seconds * Misc.TICK_CONVERSION_FACTOR);
}
public enum SidebarType {
NONE,
SKILL_BOARD,
STATS_BOARD,
COOLDOWNS_BOARD,
RANK_BOARD,
TOP_BOARD
public List<String> getDirtyPowerLevels() {
return dirtyPowerLevels;
}
}

View File

@ -0,0 +1,168 @@
package com.gmail.nossr50.util.scoreboards;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import org.bukkit.ChatColor;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* Temporary class
* Scoreboard code was a mess, in the process of unmaking it a static singleton cluster-@#$% I decided to hold off on rewriting that abomination and use this class a temporary band-aid fix
*/
//TODO: Rewrite scoreboard code so this thing doesn't need to exist
public class ScoreboardStrings {
private final mcMMO pluginRef;
// do not localize; these are internal identifiers
public final String SIDEBAR_OBJECTIVE = "mcmmo_sidebar";
public final String POWER_OBJECTIVE = "mcmmo_pwrlvl";
public String HEADER_STATS;
public final String HEADER_COOLDOWNS;
public final String HEADER_RANK;
public final String TAG_POWER_LEVEL;
public final String POWER_LEVEL;
public final String LABEL_POWER_LEVEL;
public final String LABEL_LEVEL;
public final String LABEL_CURRENT_XP;
public final String LABEL_REMAINING_XP;
public final String LABEL_ABILITY_COOLDOWN;
public final String LABEL_OVERALL;
public Map<PrimarySkillType, String> skillLabels;
public Map<SuperAbilityType, String> abilityLabelsColored;
public Map<SuperAbilityType, String> abilityLabelsSkill;
public ScoreboardStrings(mcMMO pluginRef) {
this.pluginRef = pluginRef;
HEADER_STATS = pluginRef.getLocaleManager().getString("Scoreboard.Header.PlayerStats");
HEADER_COOLDOWNS = pluginRef.getLocaleManager().getString("Scoreboard.Header.PlayerCooldowns");
HEADER_RANK = pluginRef.getLocaleManager().getString("Scoreboard.Header.PlayerRank");
TAG_POWER_LEVEL = pluginRef.getLocaleManager().getString("Scoreboard.Header.PowerLevel");
POWER_LEVEL = pluginRef.getLocaleManager().getString("Scoreboard.Misc.PowerLevel");
LABEL_POWER_LEVEL = POWER_LEVEL;
LABEL_LEVEL = pluginRef.getLocaleManager().getString("Scoreboard.Misc.Level");
LABEL_CURRENT_XP = pluginRef.getLocaleManager().getString("Scoreboard.Misc.CurrentXP");
LABEL_REMAINING_XP = pluginRef.getLocaleManager().getString("Scoreboard.Misc.RemainingXP");
LABEL_ABILITY_COOLDOWN = pluginRef.getLocaleManager().getString("Scoreboard.Misc.Cooldown");
LABEL_OVERALL = pluginRef.getLocaleManager().getString("Scoreboard.Misc.Overall");
init(pluginRef);
}
/*
* Initializes the properties of this class
*/
private void init(mcMMO pluginRef) {
/*
* We need immutable objects for our ConfigScoreboard's labels
*/
ImmutableMap.Builder<PrimarySkillType, String> skillLabelBuilder = ImmutableMap.builder();
ImmutableMap.Builder<SuperAbilityType, String> abilityLabelBuilder = ImmutableMap.builder();
ImmutableMap.Builder<SuperAbilityType, String> abilityLabelSkillBuilder = ImmutableMap.builder();
/*
* Builds the labels for our ScoreBoards
* Stylizes the targetBoard in a Rainbow Pattern
* This is off by default
*/
if (pluginRef.getScoreboardSettings().getUseRainbowSkillStyling()) {
// Everything but black, gray, gold
List<ChatColor> colors = Lists.newArrayList(
ChatColor.WHITE,
ChatColor.YELLOW,
ChatColor.LIGHT_PURPLE,
ChatColor.RED,
ChatColor.AQUA,
ChatColor.GREEN,
ChatColor.DARK_GRAY,
ChatColor.BLUE,
ChatColor.DARK_PURPLE,
ChatColor.DARK_RED,
ChatColor.DARK_AQUA,
ChatColor.DARK_GREEN,
ChatColor.DARK_BLUE);
Collections.shuffle(colors, Misc.getRandom());
int i = 0;
for (PrimarySkillType type : PrimarySkillType.values()) {
// Include child skills
skillLabelBuilder.put(type, getShortenedName(colors.get(i) + type.getName(), false));
if (type.getSuperAbility() != null) {
abilityLabelBuilder.put(type.getSuperAbility(), getShortenedName(colors.get(i) + type.getSuperAbility().getName()));
if (type == PrimarySkillType.MINING) {
abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, getShortenedName(colors.get(i) + SuperAbilityType.BLAST_MINING.getName()));
}
}
if (++i == colors.size()) {
i = 0;
}
}
}
/*
* Builds the labels for our ScoreBoards
* Stylizes the targetBoard using our normal color scheme
*/
else {
for (PrimarySkillType type : PrimarySkillType.values()) {
// Include child skills
skillLabelBuilder.put(type, getShortenedName(ChatColor.GREEN + type.getName()));
if (type.getSuperAbility() != null) {
abilityLabelBuilder.put(type.getSuperAbility(), formatAbility(type.getSuperAbility().getName()));
if (type == PrimarySkillType.MINING) {
abilityLabelBuilder.put(SuperAbilityType.BLAST_MINING, formatAbility(SuperAbilityType.BLAST_MINING.getName()));
}
}
}
}
for (SuperAbilityType type : SuperAbilityType.values()) {
abilityLabelSkillBuilder.put(type, formatAbility((type == SuperAbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA), type.getName()));
}
skillLabels = skillLabelBuilder.build();
abilityLabelsColored = abilityLabelBuilder.build();
abilityLabelsSkill = abilityLabelSkillBuilder.build();
}
private String formatAbility(String abilityName) {
return formatAbility(ChatColor.AQUA, abilityName);
}
private String formatAbility(ChatColor color, String abilityName) {
if (pluginRef.getScoreboardSettings().getUseAbilityNamesOverGenerics()) {
return getShortenedName(color + abilityName);
} else {
return color + pluginRef.getLocaleManager().getString("Scoreboard.Misc.Ability");
}
}
private String getShortenedName(String name) {
return getShortenedName(name, true);
}
private String getShortenedName(String name, boolean useDots) {
if (name.length() > 16) {
name = useDots ? name.substring(0, 14) + ".." : name.substring(0, 16);
}
return name;
}
}

View File

@ -5,11 +5,13 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.events.scoreboard.*;
import com.gmail.nossr50.events.scoreboard.McMMOScoreboardObjectiveEvent;
import com.gmail.nossr50.events.scoreboard.McMMOScoreboardRevertEvent;
import com.gmail.nossr50.events.scoreboard.ScoreboardEventReason;
import com.gmail.nossr50.events.scoreboard.ScoreboardObjectiveEventReason;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -25,6 +27,9 @@ import java.util.Map;
public class ScoreboardWrapper {
// Initialization variables
public final mcMMO pluginRef;
public final ScoreboardStrings scoreboardStrings;
public final String playerName;
public final Player player;
private final Scoreboard scoreboard;
@ -44,32 +49,28 @@ public class ScoreboardWrapper {
private Scoreboard oldBoard = null;
private PlayerProfile targetProfile = null;
private ScoreboardWrapper(Player player, Scoreboard scoreboard) {
protected ScoreboardWrapper(Player player, Scoreboard scoreboard, ScoreboardStrings scoreboardStrings, mcMMO pluginRef) {
this.scoreboardStrings = scoreboardStrings;
this.pluginRef = pluginRef;
this.player = player;
this.playerName = player.getName();
this.scoreboard = scoreboard;
sidebarType = SidebarType.NONE;
sidebarObjective = this.scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
powerObjective = this.scoreboard.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy");
sidebarObjective = this.scoreboard.registerNewObjective(scoreboardStrings.SIDEBAR_OBJECTIVE, "dummy");
powerObjective = this.scoreboard.registerNewObjective(scoreboardStrings.POWER_OBJECTIVE, "dummy");
if (pluginRef.getScoreboardSettings().getPowerLevelTagsEnabled()) {
powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL);
powerObjective.setDisplayName(scoreboardStrings.TAG_POWER_LEVEL);
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
for (McMMOPlayer mcMMOPlayer : pluginRef.getUserManager().getPlayers()) {
powerObjective.getScore(mcMMOPlayer.getProfile().getPlayerName()).setScore(mcMMOPlayer.getPowerLevel());
}
}
}
public static ScoreboardWrapper create(Player player) {
//Call our custom event
McMMOScoreboardMakeboardEvent event = new McMMOScoreboardMakeboardEvent(pluginRef.getServer().getScoreboardManager().getNewScoreboard(), player.getScoreboard(), player, ScoreboardEventReason.CREATING_NEW_SCOREBOARD);
player.getServer().getPluginManager().callEvent(event);
//Use the values from the event
return new ScoreboardWrapper(event.getTargetPlayer(), event.getTargetBoard());
}
public void doSidebarUpdateSoon() {
if (updateTask == null) {
// To avoid spamming the scheduler, store the instance and run 2 ticks later
@ -115,7 +116,7 @@ public class ScoreboardWrapper {
Player player = pluginRef.getServer().getPlayerExact(playerName);
if (player == null) {
ScoreboardManager.cleanup(this);
pluginRef.getScoreboardManager().cleanup(this);
return;
}
@ -135,7 +136,7 @@ public class ScoreboardWrapper {
Player player = pluginRef.getServer().getPlayerExact(playerName);
if (player == null) {
ScoreboardManager.cleanup(this);
pluginRef.getScoreboardManager().cleanup(this);
return;
}
@ -151,7 +152,7 @@ public class ScoreboardWrapper {
Player player = pluginRef.getServer().getPlayerExact(playerName);
if (player == null) {
ScoreboardManager.cleanup(this);
pluginRef.getScoreboardManager().cleanup(this);
return;
}
@ -165,10 +166,10 @@ public class ScoreboardWrapper {
// TODO is there any way to do the time that looks acceptable?
// player.sendMessage(pluginRef.getLocaleManager().getString("Commands.ConfigScoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase()), ticks / 20F));
if (UserManager.getPlayer(playerName) == null)
if (pluginRef.getUserManager().getPlayer(playerName) == null)
return;
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
PlayerProfile profile = pluginRef.getUserManager().getPlayer(player).getProfile();
if (profile.getScoreboardTipsShown() >= pluginRef.getScoreboardSettings().getTipsAmount()) {
return;
@ -188,7 +189,7 @@ public class ScoreboardWrapper {
Player player = pluginRef.getServer().getPlayerExact(playerName);
if (player == null) {
ScoreboardManager.cleanup(this);
pluginRef.getScoreboardManager().cleanup(this);
return;
}
@ -220,7 +221,7 @@ public class ScoreboardWrapper {
Player player = pluginRef.getServer().getPlayerExact(playerName);
if (player == null) {
ScoreboardManager.cleanup(this);
pluginRef.getScoreboardManager().cleanup(this);
return false;
}
@ -255,7 +256,7 @@ public class ScoreboardWrapper {
targetProfile = null;
leaderboardPage = -1;
loadObjective(ScoreboardManager.skillLabels.get(skill));
loadObjective(scoreboardStrings.skillLabels.get(skill));
}
public void setTypeSelfStats() {
@ -266,7 +267,7 @@ public class ScoreboardWrapper {
targetProfile = null;
leaderboardPage = -1;
loadObjective(ScoreboardManager.HEADER_STATS);
loadObjective(scoreboardStrings.HEADER_STATS);
}
// Board Type Changing 'API' methods
@ -290,7 +291,7 @@ public class ScoreboardWrapper {
targetProfile = null;
leaderboardPage = -1;
loadObjective(ScoreboardManager.HEADER_COOLDOWNS);
loadObjective(scoreboardStrings.HEADER_COOLDOWNS);
}
public void setTypeSelfRank() {
@ -301,7 +302,7 @@ public class ScoreboardWrapper {
targetProfile = null;
leaderboardPage = -1;
loadObjective(ScoreboardManager.HEADER_RANK);
loadObjective(scoreboardStrings.HEADER_RANK);
}
public void setTypeInspectRank(String otherPlayer) {
@ -312,7 +313,7 @@ public class ScoreboardWrapper {
targetProfile = null;
leaderboardPage = -1;
loadObjective(ScoreboardManager.HEADER_RANK);
loadObjective(scoreboardStrings.HEADER_RANK);
}
public void setTypeTopPower(int page) {
@ -325,7 +326,7 @@ public class ScoreboardWrapper {
int endPosition = page * 10;
int startPosition = endPosition - 9;
loadObjective(String.format("%s (%2d - %2d)", ScoreboardManager.POWER_LEVEL, startPosition, endPosition));
loadObjective(String.format("%s (%2d - %2d)", scoreboardStrings.POWER_LEVEL, startPosition, endPosition));
}
public void setTypeTop(PrimarySkillType skill, int page) {
@ -338,7 +339,7 @@ public class ScoreboardWrapper {
int endPosition = page * 10;
int startPosition = endPosition - 9;
loadObjective(String.format("%s (%2d - %2d)", ScoreboardManager.skillLabels.get(skill), startPosition, endPosition));
loadObjective(String.format("%s (%2d - %2d)", scoreboardStrings.skillLabels.get(skill), startPosition, endPosition));
}
// Setup for after a board type change
@ -352,7 +353,7 @@ public class ScoreboardWrapper {
//Register objective
McMMOScoreboardObjectiveEvent registerEvent = callObjectiveEvent(ScoreboardObjectiveEventReason.REGISTER_NEW_OBJECTIVE);
if (!registerEvent.isCancelled())
sidebarObjective = registerEvent.getTargetBoard().registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
sidebarObjective = registerEvent.getTargetBoard().registerNewObjective(scoreboardStrings.SIDEBAR_OBJECTIVE, "dummy");
if (displayName.length() > 32) {
displayName = displayName.substring(0, 32);
@ -389,11 +390,11 @@ public class ScoreboardWrapper {
Player player = pluginRef.getServer().getPlayerExact(playerName);
if (player == null) {
ScoreboardManager.cleanup(this);
pluginRef.getScoreboardManager().cleanup(this);
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
if (mcMMOPlayer == null)
return;
@ -406,23 +407,23 @@ public class ScoreboardWrapper {
if (!targetSkill.isChildSkill()) {
int currentXP = mcMMOPlayer.getSkillXpLevel(targetSkill);
sidebarObjective.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(mcMMOPlayer.getXpToLevel(targetSkill) - currentXP);
sidebarObjective.getScore(scoreboardStrings.LABEL_CURRENT_XP).setScore(currentXP);
sidebarObjective.getScore(scoreboardStrings.LABEL_REMAINING_XP).setScore(mcMMOPlayer.getXpToLevel(targetSkill) - currentXP);
} else {
for (PrimarySkillType parentSkill : FamilyTree.getParents(targetSkill)) {
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(mcMMOPlayer.getSkillLevel(parentSkill));
sidebarObjective.getScore(scoreboardStrings.skillLabels.get(parentSkill)).setScore(mcMMOPlayer.getSkillLevel(parentSkill));
}
}
sidebarObjective.getScore(ScoreboardManager.LABEL_LEVEL).setScore(mcMMOPlayer.getSkillLevel(targetSkill));
sidebarObjective.getScore(scoreboardStrings.LABEL_LEVEL).setScore(mcMMOPlayer.getSkillLevel(targetSkill));
if (targetSkill.getSuperAbility() != null) {
boolean stopUpdating;
if (targetSkill == PrimarySkillType.MINING) {
// Special-Case: Mining has two abilities, both with cooldowns
Score cooldownSB = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(SuperAbilityType.SUPER_BREAKER));
Score cooldownBM = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(SuperAbilityType.BLAST_MINING));
Score cooldownSB = sidebarObjective.getScore(scoreboardStrings.abilityLabelsSkill.get(SuperAbilityType.SUPER_BREAKER));
Score cooldownBM = sidebarObjective.getScore(scoreboardStrings.abilityLabelsSkill.get(SuperAbilityType.BLAST_MINING));
int secondsSB = Math.max(mcMMOPlayer.calculateTimeRemaining(SuperAbilityType.SUPER_BREAKER), 0);
int secondsBM = Math.max(mcMMOPlayer.calculateTimeRemaining(SuperAbilityType.BLAST_MINING), 0);
@ -432,7 +433,7 @@ public class ScoreboardWrapper {
stopUpdating = (secondsSB == 0 && secondsBM == 0);
} else {
SuperAbilityType ability = targetSkill.getSuperAbility();
Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability));
Score cooldown = sidebarObjective.getScore(scoreboardStrings.abilityLabelsSkill.get(ability));
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);
cooldown.setScore(seconds);
@ -458,7 +459,7 @@ public class ScoreboardWrapper {
anyCooldownsActive = true;
}
sidebarObjective.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
sidebarObjective.getScore(scoreboardStrings.abilityLabelsColored.get(ability)).setScore(seconds);
}
if (anyCooldownsActive) {
@ -477,7 +478,7 @@ public class ScoreboardWrapper {
} else if (targetPlayer == null) {
newProfile = mcMMOPlayer.getProfile(); // self
} else {
newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online
newProfile = pluginRef.getUserManager().getPlayer(targetPlayer).getProfile(); // online
}
// Calculate power level here
@ -492,10 +493,10 @@ public class ScoreboardWrapper {
continue;
}
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(level);
sidebarObjective.getScore(scoreboardStrings.skillLabels.get(skill)).setScore(level);
}
sidebarObjective.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(powerLevel);
sidebarObjective.getScore(scoreboardStrings.LABEL_POWER_LEVEL).setScore(powerLevel);
break;
case RANK_BOARD:
@ -523,14 +524,14 @@ public class ScoreboardWrapper {
rank = rankData.get(skill);
if (rank != null) {
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(rank);
sidebarObjective.getScore(scoreboardStrings.skillLabels.get(skill)).setScore(rank);
}
}
rank = rankData.get(null);
if (rank != null) {
sidebarObjective.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(rank);
sidebarObjective.getScore(scoreboardStrings.LABEL_POWER_LEVEL).setScore(rank);
}
}

View File

@ -0,0 +1,10 @@
package com.gmail.nossr50.util.scoreboards;
public enum SidebarType {
NONE,
SKILL_BOARD,
STATS_BOARD,
COOLDOWNS_BOARD,
RANK_BOARD,
TOP_BOARD
}

Some files were not shown because too many files have changed in this diff Show More