diff --git a/Changelog.txt b/Changelog.txt index 5d76589b4..fffd444ab 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -67,6 +67,7 @@ Version 2.2.0 Increased the default recipe cost for Chimaera Wing from 5 to 40 Blast Mining Damage Decrease now scales more smoothly from ranks 1-8 Fixed a bug where Rupture wasn't using the base ticks setting from config when determining how many ticks of rupture to apply + Fixed a bug where admin or party chat could be sent to the whole server Admins will now be notified if a player trips over-fishing exploit detection 3+ times in a row (Locale: "Fishing.OverFishingDetected") Note: Admins are players who are an operator or have adminchat permission. diff --git a/src/main/java/com/gmail/nossr50/api/ChatAPI.java b/src/main/java/com/gmail/nossr50/api/ChatAPI.java index 7d7aad775..b94705752 100644 --- a/src/main/java/com/gmail/nossr50/api/ChatAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ChatAPI.java @@ -147,7 +147,7 @@ // // private static ChatManager getPartyChatManager(Plugin plugin, String party) { // ChatManager chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY); -// ((PartyChatManager) chatManager).setParty(PartyManager.getParty(party)); +// ((PartyChatManager) chatManager).setParty(pluginRef.getPartyManager().getParty(party)); // // return chatManager; // } diff --git a/src/main/java/com/gmail/nossr50/api/PartyAPI.java b/src/main/java/com/gmail/nossr50/api/PartyAPI.java index 432bd78ba..9bd46805f 100644 --- a/src/main/java/com/gmail/nossr50/api/PartyAPI.java +++ b/src/main/java/com/gmail/nossr50/api/PartyAPI.java @@ -56,7 +56,7 @@ // * @return true if the two players are in the same party, false otherwise // */ // public static boolean inSameParty(Player playera, Player playerb) { -// return PartyManager.inSameParty(playera, playerb); +// return pluginRef.getPartyManager().inSameParty(playera, playerb); // } // // /** @@ -67,7 +67,7 @@ // * @return the list of parties. // */ // public static List getParties() { -// return PartyManager.getParties(); +// return pluginRef.getPartyManager().getParties(); // } // // /** @@ -85,18 +85,18 @@ // if (UserManager.getPlayer(player) == null) // return; // -// Party party = PartyManager.getParty(partyName); +// Party party = pluginRef.getPartyManager().getParty(partyName); // // if (party == null) { // party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName); // } else if (mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) { -// if (PartyManager.isPartyFull(player, party)) { +// if (pluginRef.getPartyManager().isPartyFull(player, party)) { // mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString()); // return; // } // } // -// PartyManager.addToParty(UserManager.getPlayer(player), party); +// pluginRef.getPartyManager().addToParty(UserManager.getPlayer(player), party); // } // // /** @@ -133,13 +133,13 @@ // if (UserManager.getPlayer(player) == null) // return; // -// Party party = PartyManager.getParty(partyName); +// Party party = pluginRef.getPartyManager().getParty(partyName); // // if (party == null) { // party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName); // } // -// PartyManager.addToParty(UserManager.getPlayer(player), party); +// pluginRef.getPartyManager().addToParty(UserManager.getPlayer(player), party); // } // // /** @@ -154,7 +154,7 @@ // if (UserManager.getPlayer(player) == null) // return; // -// PartyManager.removeFromParty(UserManager.getPlayer(player)); +// pluginRef.getPartyManager().removeFromParty(UserManager.getPlayer(player)); // } // // /** @@ -166,7 +166,7 @@ // * @return the leader of the party // */ // public static String getPartyLeader(String partyName) { -// return PartyManager.getPartyLeaderName(partyName); +// return pluginRef.getPartyManager().getPartyLeaderName(partyName); // } // // /** @@ -179,7 +179,7 @@ // */ // @Deprecated // public static void setPartyLeader(String partyName, String playerName) { -// PartyManager.setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), PartyManager.getParty(partyName)); +// pluginRef.getPartyManager().setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), pluginRef.getPartyManager().getParty(partyName)); // } // // /** @@ -194,7 +194,7 @@ // public static List getOnlineAndOfflineMembers(Player player) { // List members = new ArrayList<>(); // -// for (UUID memberUniqueId : PartyManager.getAllMembers(player).keySet()) { +// for (UUID memberUniqueId : pluginRef.getPartyManager().getAllMembers(player).keySet()) { // OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId); // members.add(member); // } @@ -211,7 +211,7 @@ // */ // @Deprecated // public static LinkedHashSet getMembers(Player player) { -// return (LinkedHashSet) PartyManager.getAllMembers(player).values(); +// return (LinkedHashSet) pluginRef.getPartyManager().getAllMembers(player).values(); // } // // /** @@ -223,7 +223,7 @@ // * @return all the player names and uuids in the player's party // */ // public static LinkedHashMap getMembersMap(Player player) { -// return PartyManager.getAllMembers(player); +// return pluginRef.getPartyManager().getAllMembers(player); // } // // /** @@ -235,7 +235,7 @@ // * @return all online players in this party // */ // public static List getOnlineMembers(String partyName) { -// return PartyManager.getOnlineMembers(partyName); +// return pluginRef.getPartyManager().getOnlineMembers(partyName); // } // // /** @@ -247,7 +247,7 @@ // * @return all online players in the player's party // */ // public static List getOnlineMembers(Player player) { -// return PartyManager.getOnlineMembers(player); +// return pluginRef.getPartyManager().getOnlineMembers(player); // } // // public static boolean hasAlly(String partyName) { @@ -255,7 +255,7 @@ // } // // public static String getAllyName(String partyName) { -// Party ally = PartyManager.getParty(partyName).getAlly(); +// Party ally = pluginRef.getPartyManager().getParty(partyName).getAlly(); // if (ally != null) { // return ally.getName(); // } diff --git a/src/main/java/com/gmail/nossr50/api/exceptions/InvalidFormulaTypeException.java b/src/main/java/com/gmail/nossr50/api/exceptions/InvalidFormulaTypeException.java index 2fee51fd7..c46332b99 100644 --- a/src/main/java/com/gmail/nossr50/api/exceptions/InvalidFormulaTypeException.java +++ b/src/main/java/com/gmail/nossr50/api/exceptions/InvalidFormulaTypeException.java @@ -1,9 +1,9 @@ -//package com.gmail.nossr50.api.exceptions; -// -//public class InvalidFormulaTypeException extends RuntimeException { -// private static final long serialVersionUID = 3368670229490121886L; -// -// public InvalidFormulaTypeException() { -// super("That is not a valid FormulaType."); -// } -//} +package com.gmail.nossr50.api.exceptions; + +public class InvalidFormulaTypeException extends RuntimeException { + private static final long serialVersionUID = 3368670229490121886L; + + public InvalidFormulaTypeException() { + super("That is not a valid FormulaType."); + } +} diff --git a/src/main/java/com/gmail/nossr50/api/exceptions/InvalidPlayerException.java b/src/main/java/com/gmail/nossr50/api/exceptions/InvalidPlayerException.java index 12a8635cf..47d065e4a 100644 --- a/src/main/java/com/gmail/nossr50/api/exceptions/InvalidPlayerException.java +++ b/src/main/java/com/gmail/nossr50/api/exceptions/InvalidPlayerException.java @@ -1,9 +1,9 @@ -//package com.gmail.nossr50.api.exceptions; -// -//public class InvalidPlayerException extends RuntimeException { -// private static final long serialVersionUID = 907213002618581385L; -// -// public InvalidPlayerException() { -// super("That player does not exist in the database."); -// } -//} +package com.gmail.nossr50.api.exceptions; + +public class InvalidPlayerException extends RuntimeException { + private static final long serialVersionUID = 907213002618581385L; + + public InvalidPlayerException() { + super("That player does not exist in the database."); + } +} diff --git a/src/main/java/com/gmail/nossr50/api/exceptions/InvalidSkillException.java b/src/main/java/com/gmail/nossr50/api/exceptions/InvalidSkillException.java index d1ce509a4..598a44d7e 100644 --- a/src/main/java/com/gmail/nossr50/api/exceptions/InvalidSkillException.java +++ b/src/main/java/com/gmail/nossr50/api/exceptions/InvalidSkillException.java @@ -1,9 +1,9 @@ -//package com.gmail.nossr50.api.exceptions; -// -//public class InvalidSkillException extends RuntimeException { -// private static final long serialVersionUID = 942705284195791157L; -// -// public InvalidSkillException(String s) { -// super(s + " does not match a valid skill."); -// } -//} +package com.gmail.nossr50.api.exceptions; + +public class InvalidSkillException extends RuntimeException { + private static final long serialVersionUID = 942705284195791157L; + + public InvalidSkillException(String s) { + super(s + " does not match a valid skill."); + } +} diff --git a/src/main/java/com/gmail/nossr50/api/exceptions/InvalidXPGainReasonException.java b/src/main/java/com/gmail/nossr50/api/exceptions/InvalidXPGainReasonException.java index 842504756..b2c1232b2 100644 --- a/src/main/java/com/gmail/nossr50/api/exceptions/InvalidXPGainReasonException.java +++ b/src/main/java/com/gmail/nossr50/api/exceptions/InvalidXPGainReasonException.java @@ -1,9 +1,9 @@ -//package com.gmail.nossr50.api.exceptions; -// -//public class InvalidXPGainReasonException extends RuntimeException { -// private static final long serialVersionUID = 4427052841957931157L; -// -// public InvalidXPGainReasonException() { -// super("That is not a valid XPGainReason."); -// } -//} +package com.gmail.nossr50.api.exceptions; + +public class InvalidXPGainReasonException extends RuntimeException { + private static final long serialVersionUID = 4427052841957931157L; + + public InvalidXPGainReasonException() { + super("That is not a valid XPGainReason."); + } +} diff --git a/src/main/java/com/gmail/nossr50/api/exceptions/McMMOPlayerNotFoundException.java b/src/main/java/com/gmail/nossr50/api/exceptions/McMMOPlayerNotFoundException.java index 03d15718f..b0b0f0087 100644 --- a/src/main/java/com/gmail/nossr50/api/exceptions/McMMOPlayerNotFoundException.java +++ b/src/main/java/com/gmail/nossr50/api/exceptions/McMMOPlayerNotFoundException.java @@ -1,11 +1,11 @@ -//package com.gmail.nossr50.api.exceptions; -// -//import org.bukkit.entity.Player; -// -//public class McMMOPlayerNotFoundException extends RuntimeException { -// private static final long serialVersionUID = 761917904993202836L; -// -// public McMMOPlayerNotFoundException(Player player) { -// super("McMMOPlayer object was not found for [NOTE: This can mean the profile is not loaded yet!] : " + player.getName() + " " + player.getUniqueId()); -// } -//} +package com.gmail.nossr50.api.exceptions; + +import org.bukkit.entity.Player; + +public class McMMOPlayerNotFoundException extends RuntimeException { + private static final long serialVersionUID = 761917904993202836L; + + public McMMOPlayerNotFoundException(Player player) { + super("McMMOPlayer object was not found for [NOTE: This can mean the profile is not loaded yet!] : " + player.getName() + " " + player.getUniqueId()); + } +} diff --git a/src/main/java/com/gmail/nossr50/api/exceptions/MissingSkillPropertyDefinition.java b/src/main/java/com/gmail/nossr50/api/exceptions/MissingSkillPropertyDefinition.java index 4f32ea256..e0aada6a4 100644 --- a/src/main/java/com/gmail/nossr50/api/exceptions/MissingSkillPropertyDefinition.java +++ b/src/main/java/com/gmail/nossr50/api/exceptions/MissingSkillPropertyDefinition.java @@ -1,7 +1,7 @@ -//package com.gmail.nossr50.api.exceptions; -// -//public class MissingSkillPropertyDefinition extends RuntimeException { -// public MissingSkillPropertyDefinition(String details) { -// super("A skill property is undefined! Details: " + details); -// } -//} +package com.gmail.nossr50.api.exceptions; + +public class MissingSkillPropertyDefinition extends RuntimeException { + public MissingSkillPropertyDefinition(String details) { + super("A skill property is undefined! Details: " + details); + } +} diff --git a/src/main/java/com/gmail/nossr50/api/exceptions/UndefinedSkillBehaviour.java b/src/main/java/com/gmail/nossr50/api/exceptions/UndefinedSkillBehaviour.java index f4d11fd53..29bfd2855 100644 --- a/src/main/java/com/gmail/nossr50/api/exceptions/UndefinedSkillBehaviour.java +++ b/src/main/java/com/gmail/nossr50/api/exceptions/UndefinedSkillBehaviour.java @@ -1,9 +1,9 @@ -//package com.gmail.nossr50.api.exceptions; -// -//import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -// -//public class UndefinedSkillBehaviour extends RuntimeException { -// public UndefinedSkillBehaviour(PrimarySkillType primarySkillType) { -// super("Undefined behaviour for skill! - " + primarySkillType.toString()); -// } -//} +package com.gmail.nossr50.api.exceptions; + +import com.gmail.nossr50.datatypes.skills.PrimarySkillType; + +public class UndefinedSkillBehaviour extends RuntimeException { + public UndefinedSkillBehaviour(PrimarySkillType primarySkillType) { + super("Undefined behaviour for skill! - " + primarySkillType.toString()); + } +} diff --git a/src/main/java/com/gmail/nossr50/bukkit/BukkitFactory.java b/src/main/java/com/gmail/nossr50/bukkit/BukkitFactory.java index 28f0564a0..df1e9509b 100644 --- a/src/main/java/com/gmail/nossr50/bukkit/BukkitFactory.java +++ b/src/main/java/com/gmail/nossr50/bukkit/BukkitFactory.java @@ -11,16 +11,22 @@ import org.bukkit.inventory.ItemStack; */ public class BukkitFactory { + private mcMMO pluginRef; + + public BukkitFactory(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + /** * Creates a BukkitMMOItem which contains Bukkit implementations for the type MMOItem * @return a new BukkitMMOItem */ - public static MMOItem createItem(String namespaceKey, int amount, RawNBT rawNBT) { + public MMOItem createItem(String namespaceKey, int amount, RawNBT rawNBT) { return new BukkitMMOItem(namespaceKey, amount, rawNBT); } - public static MMOItem createItem(ItemStack itemStack) { - return createItem(itemStack.getType().getKey().toString(), itemStack.getAmount(), new RawNBT(mcMMO.getNbtManager().getNBT(itemStack).toString())); + public MMOItem createItem(ItemStack itemStack) { + return createItem(itemStack.getType().getKey().toString(), itemStack.getAmount(), new RawNBT(pluginRef.getNbtManager().getNBT(itemStack).toString())); } } diff --git a/src/main/java/com/gmail/nossr50/chat/AdminChatManager.java b/src/main/java/com/gmail/nossr50/chat/AdminChatManager.java deleted file mode 100644 index 3f3612b14..000000000 --- a/src/main/java/com/gmail/nossr50/chat/AdminChatManager.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.gmail.nossr50.chat; - -import com.gmail.nossr50.events.chat.McMMOAdminChatEvent; -import com.gmail.nossr50.mcMMO; -import org.bukkit.plugin.Plugin; - -public class AdminChatManager extends ChatManager { - protected AdminChatManager(Plugin plugin) { - super(plugin, - mcMMO.getConfigManager().getConfigCommands().isUseDisplayNames(), - mcMMO.getConfigManager().getConfigCommands().getAdminChatPrefix()); - } - - @Override - public void handleChat(String senderName, String displayName, String message, boolean isAsync) { - handleChat(new McMMOAdminChatEvent(plugin, senderName, displayName, message, isAsync)); - } - - @Override - protected void sendMessage() { - plugin.getServer().broadcast(message, "mcmmo.chat.adminchat"); - } -} diff --git a/src/main/java/com/gmail/nossr50/chat/ChatManager.java b/src/main/java/com/gmail/nossr50/chat/ChatManager.java index f4d8d03a6..ca88a19d5 100644 --- a/src/main/java/com/gmail/nossr50/chat/ChatManager.java +++ b/src/main/java/com/gmail/nossr50/chat/ChatManager.java @@ -2,83 +2,105 @@ package com.gmail.nossr50.chat; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.events.chat.McMMOChatEvent; +import com.gmail.nossr50.events.chat.McMMOAdminChatEvent; import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.player.UserManager; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -public abstract class ChatManager { - protected Plugin plugin; - protected boolean useDisplayNames; - protected String chatPrefix; +import java.util.regex.Matcher; +import java.util.regex.Pattern; - protected String senderName; - protected String displayName; - protected String message; +public class ChatManager { + private final String ADMIN_CHAT_PERMISSION = "mcmmo.chat.adminchat"; + private mcMMO pluginRef; - protected ChatManager(Plugin plugin, boolean useDisplayNames, String chatPrefix) { - this.plugin = plugin; - this.useDisplayNames = useDisplayNames; - this.chatPrefix = chatPrefix; + public ChatManager(mcMMO pluginRef) { + this.pluginRef = pluginRef; } - protected void handleChat(McMMOChatEvent event) { - plugin.getServer().getPluginManager().callEvent(event); + public void processAdminChat(Player player, String message) { + sendAdminChatMessage(new McMMOAdminChatEvent(pluginRef, player.getName(), player.getDisplayName(), message)); + } + + public void processAdminChat(String senderName, String displayName, String message) { + sendAdminChatMessage(new McMMOAdminChatEvent(pluginRef, senderName, displayName, message)); + } + + public void processPartyChat(Party party, Player sender, String message) { + sendPartyChatMessage(new McMMOPartyChatEvent(pluginRef, sender.getName(), sender.getDisplayName(), party, message)); + } + + public void processPartyChat(Party party, String senderName, String message) { + sendPartyChatMessage(new McMMOPartyChatEvent(pluginRef, senderName, senderName, party, message)); + } + + private void sendAdminChatMessage(McMMOAdminChatEvent event) { + pluginRef.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; } - senderName = event.getSender(); - displayName = useDisplayNames ? event.getDisplayName() : senderName; - message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage(); + String chatPrefix = pluginRef.getConfigManager().getConfigCommands().getAdminChatPrefix(); + String senderName = event.getSender(); + String displayName = pluginRef.getConfigManager().getConfigCommands().isUseDisplayNames() ? event.getDisplayName() : senderName; + String message = pluginRef.getLocaleManager().formatString(chatPrefix, displayName) + " " + event.getMessage(); - sendMessage(); + pluginRef.getServer().broadcast(message, ADMIN_CHAT_PERMISSION); + } + + private void sendPartyChatMessage(McMMOPartyChatEvent event) { + pluginRef.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return; + } + + Party party = event.getParty(); + String chatPrefix = pluginRef.getConfigManager().getConfigParty().getPartyChatPrefixFormat(); + String senderName = event.getSender(); + String displayName = pluginRef.getConfigManager().getConfigCommands().isUseDisplayNames() ? event.getDisplayName() : senderName; + String message = pluginRef.getLocaleManager().formatString(chatPrefix, displayName) + " " + event.getMessage(); + + if (pluginRef.getConfigManager().getConfigParty().isPartyLeaderColoredGold() + && senderName.equalsIgnoreCase(party.getLeader().getPlayerName())) { + message = message.replaceFirst(Pattern.quote(displayName), ChatColor.GOLD + Matcher.quoteReplacement(displayName) + ChatColor.RESET); + } + + for (Player member : party.getOnlineMembers()) { + member.sendMessage(message); + } + + if (party.getAlly() != null) { + for (Player member : party.getAlly().getOnlineMembers()) { + String allyPrefix = pluginRef.getLocaleManager().formatString(pluginRef.getConfigManager().getConfigParty().getPartyChatPrefixAlly()); + member.sendMessage(allyPrefix + message); + } + } + + pluginRef.getServer().getConsoleSender().sendMessage(ChatColor.stripColor("[mcMMO] [P]<" + party.getName() + ">" + message)); /* * Party Chat Spying - * Party messages will be copied to people with the mcmmo.admin.chatspy permission node */ - if (event instanceof McMMOPartyChatEvent) { - //We need to grab the party chat name - McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event; + for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) { + Player player = mcMMOPlayer.getPlayer(); - //Find the people with permissions - for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) { - Player player = mcMMOPlayer.getPlayer(); + //Check for toggled players + if (mcMMOPlayer.isPartyChatSpying()) { + Party adminParty = mcMMOPlayer.getParty(); - //Check for toggled players - if (mcMMOPlayer.isPartyChatSpying()) { - Party adminParty = mcMMOPlayer.getParty(); - - //Only message admins not part of this party - if (adminParty != null) { - //TODO: Incorporate JSON - if (!adminParty.getName().equalsIgnoreCase(partyChatEvent.getParty())) - player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message)); - } else { - player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message)); - } + //Only message admins not part of this party + if (adminParty != null) { + //TODO: Incorporate JSON + if (adminParty != event.getParty()) + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.AdminChatSpy.Chat", event.getParty(), message)); + } else { + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.AdminChatSpy.Chat", event.getParty(), message)); } } } } - - public void handleChat(String senderName, String message) { - handleChat(senderName, senderName, message, false); - } - - public void handleChat(Player player, String message, boolean isAsync) { - handleChat(player.getName(), player.getDisplayName(), message, isAsync); - } - - public void handleChat(String senderName, String displayName, String message) { - handleChat(senderName, displayName, message, false); - } - - public abstract void handleChat(String senderName, String displayName, String message, boolean isAsync); - - protected abstract void sendMessage(); } diff --git a/src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java b/src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java deleted file mode 100644 index 4146d26c7..000000000 --- a/src/main/java/com/gmail/nossr50/chat/ChatManagerFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.gmail.nossr50.chat; - -import com.gmail.nossr50.datatypes.chat.ChatMode; -import org.bukkit.plugin.Plugin; - -import java.util.HashMap; - -public class ChatManagerFactory { - private static final HashMap adminChatManagers = new HashMap<>(); - private static final HashMap partyChatManagers = new HashMap<>(); - - public static ChatManager getChatManager(Plugin plugin, ChatMode mode) { - switch (mode) { - case ADMIN: - if (!adminChatManagers.containsKey(plugin)) { - adminChatManagers.put(plugin, new AdminChatManager(plugin)); - } - - return adminChatManagers.get(plugin); - case PARTY: - if (!partyChatManagers.containsKey(plugin)) { - partyChatManagers.put(plugin, new PartyChatManager(plugin)); - } - - return partyChatManagers.get(plugin); - default: - return null; - } - } -} diff --git a/src/main/java/com/gmail/nossr50/chat/PartyChatManager.java b/src/main/java/com/gmail/nossr50/chat/PartyChatManager.java deleted file mode 100644 index 242ddee90..000000000 --- a/src/main/java/com/gmail/nossr50/chat/PartyChatManager.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.gmail.nossr50.chat; - -import com.gmail.nossr50.datatypes.party.Party; -import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.runnables.party.PartyChatTask; -import org.bukkit.plugin.Plugin; - -public class PartyChatManager extends ChatManager { - private Party party; - - protected PartyChatManager(Plugin plugin) { - super(plugin, mcMMO.getConfigManager().getConfigParty().isPartyDisplayNamesEnabled(), - mcMMO.getConfigManager().getConfigParty().getPartyChat().getPartyChatPrefixFormat()); - } - - public void setParty(Party party) { - this.party = party; - } - - @Override - public void handleChat(String senderName, String displayName, String message, boolean isAsync) { - handleChat(new McMMOPartyChatEvent(plugin, senderName, displayName, party.getName(), message, isAsync)); - } - - @Override - protected void sendMessage() { - new PartyChatTask(plugin, party, senderName, displayName, message).runTask(plugin); - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/MHDCommand.java b/src/main/java/com/gmail/nossr50/commands/MHDCommand.java index 9af60e8c1..046f4a1da 100644 --- a/src/main/java/com/gmail/nossr50/commands/MHDCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/MHDCommand.java @@ -14,22 +14,28 @@ import java.util.List; public class MHDCommand implements TabExecutor { + private mcMMO pluginRef; + + public MHDCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (mcMMO.getDatabaseManager() instanceof SQLDatabaseManager) { - SQLDatabaseManager m = (SQLDatabaseManager) mcMMO.getDatabaseManager(); + if (pluginRef.getDatabaseManager() instanceof SQLDatabaseManager) { + SQLDatabaseManager m = (SQLDatabaseManager) pluginRef.getDatabaseManager(); m.resetMobHealthSettings(); for (McMMOPlayer player : UserManager.getPlayers()) { - player.getProfile().setMobHealthbarType(mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType()); + player.getProfile().setMobHealthbarType(pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType()); } sender.sendMessage("Mob health reset"); return true; } - if (mcMMO.getDatabaseManager() instanceof FlatfileDatabaseManager) { - FlatfileDatabaseManager m = (FlatfileDatabaseManager) mcMMO.getDatabaseManager(); + if (pluginRef.getDatabaseManager() instanceof FlatfileDatabaseManager) { + FlatfileDatabaseManager m = (FlatfileDatabaseManager) pluginRef.getDatabaseManager(); m.resetMobHealthSettings(); for (McMMOPlayer player : UserManager.getPlayers()) { - player.getProfile().setMobHealthbarType(mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType()); + player.getProfile().setMobHealthbarType(pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType()); } sender.sendMessage("Mob health reset"); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/McImportCommand.java b/src/main/java/com/gmail/nossr50/commands/McImportCommand.java deleted file mode 100644 index 5e08491fd..000000000 --- a/src/main/java/com/gmail/nossr50/commands/McImportCommand.java +++ /dev/null @@ -1,320 +0,0 @@ -package com.gmail.nossr50.commands; - -import com.gmail.nossr50.datatypes.skills.ModConfigType; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.Misc; -import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import java.io.*; -import java.util.ArrayList; -import java.util.HashMap; - -public class McImportCommand implements CommandExecutor { - int fileAmount; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 0: - importModConfig(); - return true; - - default: - return false; - } - } - - public void importModConfig() { - String importFilePath = mcMMO.getModDirectory() + File.separator + "import"; - File importFile = new File(importFilePath, "import.log"); - mcMMO.p.getLogger().info("Starting import of mod materials..."); - fileAmount = 0; - - HashMap> materialNames = new HashMap<>(); - - BufferedReader in = null; - - try { - // Open the file - in = new BufferedReader(new FileReader(importFile)); - - String line; - String materialName; - String modName; - - // While not at the end of the file - while ((line = in.readLine()) != null) { - String[] split1 = line.split("material "); - - if (split1.length != 2) { - continue; - } - - String[] split2 = split1[1].split(" with"); - - if (split2.length != 2) { - continue; - } - - materialName = split2[0]; - - // Categorise each material under a mod config type - ModConfigType type = ModConfigType.getModConfigType(materialName); - - if (!materialNames.containsKey(type)) { - materialNames.put(type, new ArrayList<>()); - } - - materialNames.get(type).add(materialName); - } - } catch (FileNotFoundException e) { - mcMMO.p.getLogger().warning("Could not find " + importFile.getAbsolutePath() + " ! (No such file or directory)"); - mcMMO.p.getLogger().warning("Copy and paste latest.log to " + importFile.getParentFile().getAbsolutePath() + " and rename it to import.log"); - return; - } catch (Exception e) { - e.printStackTrace(); - return; - } finally { - tryClose(in); - } - - createOutput(materialNames); - - mcMMO.p.getLogger().info("Import finished! Created " + fileAmount + " files!"); - } - - private void createOutput(HashMap> materialNames) { - for (ModConfigType modConfigType : materialNames.keySet()) { - HashMap> materialNamesType = new HashMap<>(); - - for (String materialName : materialNames.get(modConfigType)) { - String modName = Misc.getModName(materialName); - - if (!materialNamesType.containsKey(modName)) { - materialNamesType.put(modName, new ArrayList<>()); - } - - materialNamesType.get(modName).add(materialName); - } - - createOutput(modConfigType, materialNamesType); - } - - } - - private void tryClose(Closeable c) { - if (c == null) { - return; - } - try { - c.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void createOutput(ModConfigType modConfigType, HashMap> materialNames) { - File outputFilePath = new File(mcMMO.getModDirectory() + File.separator + "output"); - if (!outputFilePath.exists() && !outputFilePath.mkdirs()) { - mcMMO.p.getLogger().severe("Could not create output directory! " + outputFilePath.getAbsolutePath()); - } - - FileWriter out = null; - String type = modConfigType.name().toLowerCase(); - - for (String modName : materialNames.keySet()) { - File outputFile = new File(outputFilePath, modName + "." + type + ".yml"); - mcMMO.p.getLogger().info("Creating " + outputFile.getName()); - try { - if (outputFile.exists() && !outputFile.delete()) { - mcMMO.p.getLogger().severe("Not able to delete old output file! " + outputFile.getAbsolutePath()); - } - - if (!outputFile.createNewFile()) { - mcMMO.p.getLogger().severe("Could not create output file! " + outputFile.getAbsolutePath()); - continue; - } - - StringBuilder writer = new StringBuilder(); - HashMap> configSections = getConfigSections(modConfigType, modName, materialNames); - - if (configSections == null) { - mcMMO.p.getLogger().severe("Something went wrong!! type is " + type); - return; - } - - // Write the file, go through each skill and write all the materials - for (String configSection : configSections.keySet()) { - if (configSection.equals("UNIDENTIFIED")) { - writer.append("# This isn't a valid config section and all materials in this category need to be").append("\r\n"); - writer.append("# copy and pasted to a valid section of this config file.").append("\r\n"); - } - writer.append(configSection).append(":").append("\r\n"); - - for (String line : configSections.get(configSection)) { - writer.append(line).append("\r\n"); - } - - writer.append("\r\n"); - } - - out = new FileWriter(outputFile); - out.write(writer.toString()); - } catch (Exception e) { - e.printStackTrace(); - return; - } finally { - tryClose(out); - fileAmount++; - } - } - } - - private HashMap> getConfigSections(ModConfigType type, String modName, HashMap> materialNames) { - switch (type) { - case BLOCKS: - return getConfigSectionsBlocks(modName, materialNames); - case TOOLS: - return getConfigSectionsTools(modName, materialNames); - case ARMOR: - return getConfigSectionsArmor(modName, materialNames); - case UNKNOWN: - return getConfigSectionsUnknown(modName, materialNames); - } - - return null; - } - - private HashMap> getConfigSectionsBlocks(String modName, HashMap> materialNames) { - HashMap> configSections = new HashMap<>(); - - // Go through all the materials and categorise them under a skill - for (String materialName : materialNames.get(modName)) { - String skillName = "UNIDENTIFIED"; - if (materialName.contains("ORE")) { - skillName = "Mining"; - } else if (materialName.contains("LOG") || materialName.contains("LEAVES")) { - skillName = "Woodcutting"; - } else if (materialName.contains("GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) { - skillName = "Herbalism"; - } else if (materialName.contains("DIRT") || materialName.contains("SAND")) { - skillName = "Excavation"; - } - - if (!configSections.containsKey(skillName)) { - configSections.put(skillName, new ArrayList<>()); - } - - ArrayList skillContents = configSections.get(skillName); - skillContents.add(" " + materialName + "|0:"); - skillContents.add(" " + " " + "XP_Gain: 99"); - skillContents.add(" " + " " + "Double_Drops_Enabled: true"); - - if (skillName.equals("Mining")) { - skillContents.add(" " + " " + "Smelting_XP_Gain: 9"); - } else if (skillName.equals("Woodcutting")) { - skillContents.add(" " + " " + "Is_Log: " + materialName.contains("LOG")); - } - } - - return configSections; - } - - private HashMap> getConfigSectionsTools(String modName, HashMap> materialNames) { - HashMap> configSections = new HashMap<>(); - - // Go through all the materials and categorise them under a tool type - for (String materialName : materialNames.get(modName)) { - String toolType = "UNIDENTIFIED"; - if (materialName.contains("PICKAXE")) { - toolType = "Pickaxes"; - } else if (materialName.contains("AXE")) { - toolType = "Axes"; - } else if (materialName.contains("BOW")) { - toolType = "Bows"; - } else if (materialName.contains("HOE")) { - toolType = "Hoes"; - } else if (materialName.contains("SHOVEL") || materialName.contains("SPADE")) { - toolType = "Shovels"; - } else if (materialName.contains("SWORD")) { - toolType = "Swords"; - } - - if (!configSections.containsKey(toolType)) { - configSections.put(toolType, new ArrayList<>()); - } - - ArrayList skillContents = configSections.get(toolType); - skillContents.add(" " + materialName + ":"); - skillContents.add(" " + " " + "XP_Modifier: 1.0"); - skillContents.add(" " + " " + "Tier: 1"); - skillContents.add(" " + " " + "Ability_Enabled: true"); - addRepairableLines(materialName, skillContents); - } - - return configSections; - } - - private HashMap> getConfigSectionsArmor(String modName, HashMap> materialNames) { - HashMap> configSections = new HashMap<>(); - - // Go through all the materials and categorise them under an armor type - for (String materialName : materialNames.get(modName)) { - String toolType = "UNIDENTIFIED"; - if (materialName.contains("BOOT") || materialName.contains("SHOE")) { - toolType = "Boots"; - } else if (materialName.contains("CHESTPLATE") || materialName.contains("CHEST")) { - toolType = "Chestplates"; - } else if (materialName.contains("HELM") || materialName.contains("HAT")) { - toolType = "Helmets"; - } else if (materialName.contains("LEGGINGS") || materialName.contains("LEGS") || materialName.contains("PANTS")) { - toolType = "Leggings"; - } - - if (!configSections.containsKey(toolType)) { - configSections.put(toolType, new ArrayList<>()); - } - - ArrayList skillContents = configSections.get(toolType); - skillContents.add(" " + materialName + ":"); - addRepairableLines(materialName, skillContents); - } - - return configSections; - } - - private void addRepairableLines(String materialName, ArrayList skillContents) { - skillContents.add(" " + " " + "Repairable: true"); - skillContents.add(" " + " " + "Repair_Material: REPAIR_MATERIAL_NAME"); - skillContents.add(" " + " " + "Repair_Material_Data_Value: 0"); - skillContents.add(" " + " " + "Repair_Material_Quantity: 9"); - skillContents.add(" " + " " + "Repair_Material_Pretty_Name: Repair Item Name"); - skillContents.add(" " + " " + "Repair_MinimumLevel: 0"); - skillContents.add(" " + " " + "Repair_XpMultiplier: 1.0"); - - Material material = Material.matchMaterial(materialName); - short durability = (material == null) ? (short) 9999 : material.getMaxDurability(); - skillContents.add(" " + " " + "Durability: " + ((durability > 0) ? durability : (short) 9999)); - } - - private HashMap> getConfigSectionsUnknown(String modName, HashMap> materialNames) { - HashMap> configSections = new HashMap<>(); - - // Go through all the materials and print them - for (String materialName : materialNames.get(modName)) { - String configKey = "UNIDENTIFIED"; - - if (!configSections.containsKey(configKey)) { - configSections.put(configKey, new ArrayList<>()); - } - - ArrayList skillContents = configSections.get(configKey); - skillContents.add(" " + materialName); - } - - return configSections; - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java b/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java index 0628b9364..a34d61819 100644 --- a/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McabilityCommand.java @@ -1,11 +1,18 @@ package com.gmail.nossr50.commands; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import org.bukkit.command.CommandSender; public class McabilityCommand extends ToggleCommand { + + private mcMMO pluginRef; + + public McabilityCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override protected boolean hasOtherPermission(CommandSender sender) { return Permissions.mcabilityOthers(sender); @@ -18,12 +25,12 @@ public class McabilityCommand extends ToggleCommand { @Override protected void applyCommandAction(McMMOPlayer mcMMOPlayer) { - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On"))); + mcMMOPlayer.getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On"))); mcMMOPlayer.toggleAbilityUse(); } @Override protected void sendSuccessMessage(CommandSender sender, String playerName) { - sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle", playerName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Ability.Toggle", playerName)); } } diff --git a/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java b/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java index ac8f0e1cf..ec268ce97 100644 --- a/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McconvertCommand.java @@ -18,11 +18,22 @@ import java.util.Collections; import java.util.List; public class McconvertCommand implements TabExecutor { - private static final List FORMULA_TYPES; - private static final List DATABASE_TYPES; - private static final List SUBCOMMANDS = ImmutableList.of("database", "experience"); + private List FORMULA_TYPES; + private List DATABASE_TYPES; + private final List SUBCOMMANDS = ImmutableList.of("database", "experience"); + private CommandExecutor databaseConvertCommand; + private CommandExecutor experienceConvertCommand; - static { + private mcMMO pluginRef; + + public McconvertCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + databaseConvertCommand = new ConvertDatabaseCommand(pluginRef); + experienceConvertCommand = new ConvertExperienceCommand(pluginRef); + initTypes(); + } + + private void initTypes() { ArrayList formulaTypes = new ArrayList<>(); ArrayList databaseTypes = new ArrayList<>(); @@ -37,7 +48,7 @@ public class McconvertCommand implements TabExecutor { // Custom stuff databaseTypes.remove(DatabaseType.CUSTOM.toString()); - if (mcMMO.getDatabaseManager().getDatabaseType() == DatabaseType.CUSTOM) { + if (pluginRef.getDatabaseManager().getDatabaseType() == DatabaseType.CUSTOM) { databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName()); } @@ -46,12 +57,8 @@ public class McconvertCommand implements TabExecutor { FORMULA_TYPES = ImmutableList.copyOf(formulaTypes); DATABASE_TYPES = ImmutableList.copyOf(databaseTypes); - } - private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand(); - private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand(); - @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { diff --git a/src/main/java/com/gmail/nossr50/commands/McgodCommand.java b/src/main/java/com/gmail/nossr50/commands/McgodCommand.java index 1867c4672..bcb4b0d2d 100644 --- a/src/main/java/com/gmail/nossr50/commands/McgodCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McgodCommand.java @@ -1,11 +1,18 @@ package com.gmail.nossr50.commands; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import org.bukkit.command.CommandSender; public class McgodCommand extends ToggleCommand { + + private mcMMO pluginRef; + + public McgodCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override protected boolean hasOtherPermission(CommandSender sender) { return Permissions.mcgodOthers(sender); @@ -18,12 +25,12 @@ public class McgodCommand extends ToggleCommand { @Override protected void applyCommandAction(McMMOPlayer mcMMOPlayer) { - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled"))); + mcMMOPlayer.getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled"))); mcMMOPlayer.toggleGodMode(); } @Override protected void sendSuccessMessage(CommandSender sender, String playerName) { - sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Toggle", playerName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.GodMode.Toggle", playerName)); } } diff --git a/src/main/java/com/gmail/nossr50/commands/McmmoCommand.java b/src/main/java/com/gmail/nossr50/commands/McmmoCommand.java index f7b6fb4a8..7d922194a 100644 --- a/src/main/java/com/gmail/nossr50/commands/McmmoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McmmoCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands; import com.gmail.nossr50.commands.party.PartySubcommandType; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import org.bukkit.ChatColor; @@ -10,6 +9,13 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; public class McmmoCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public McmmoCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { @@ -19,16 +25,16 @@ public class McmmoCommand implements CommandExecutor { return true; } - String description = LocaleLoader.getString("mcMMO.Description"); + String description = pluginRef.getLocaleManager().getString("mcMMO.Description"); String[] mcSplit = description.split(","); sender.sendMessage(mcSplit); - if (mcMMO.getConfigManager().getConfigAds().isShowDonationInfo()) { - sender.sendMessage(LocaleLoader.getString("MOTD.Donate")); + if (pluginRef.getConfigManager().getConfigAds().isShowDonationInfo()) { + sender.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Donate")); sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "nossr50@gmail.com" + ChatColor.GOLD + " Paypal"); } - sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion())); + sender.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Version", pluginRef.getDescription().getVersion())); // mcMMO.getHolidayManager().anniversaryCheck(sender); return true; @@ -40,7 +46,7 @@ public class McmmoCommand implements CommandExecutor { return true; } - sender.sendMessage(LocaleLoader.getString("Commands.mcc.Header")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcc.Header")); displayGeneralCommands(sender); displayOtherCommands(sender); displayPartyCommands(sender); @@ -53,16 +59,16 @@ public class McmmoCommand implements CommandExecutor { } private void displayGeneralCommands(CommandSender sender) { - sender.sendMessage(ChatColor.DARK_AQUA + " /mcstats " + LocaleLoader.getString("Commands.Stats")); - sender.sendMessage(ChatColor.DARK_AQUA + " /" + LocaleLoader.getString("Commands.SkillInfo")); - sender.sendMessage(ChatColor.DARK_AQUA + " /mctop " + LocaleLoader.getString("Commands.Leaderboards")); + sender.sendMessage(ChatColor.DARK_AQUA + " /mcstats " + pluginRef.getLocaleManager().getString("Commands.Stats")); + sender.sendMessage(ChatColor.DARK_AQUA + " /" + pluginRef.getLocaleManager().getString("Commands.SkillInfo")); + sender.sendMessage(ChatColor.DARK_AQUA + " /mctop " + pluginRef.getLocaleManager().getString("Commands.Leaderboards")); if (Permissions.inspect(sender)) { - sender.sendMessage(ChatColor.DARK_AQUA + " /inspect " + LocaleLoader.getString("Commands.Inspect")); + sender.sendMessage(ChatColor.DARK_AQUA + " /inspect " + pluginRef.getLocaleManager().getString("Commands.Inspect")); } if (Permissions.mcability(sender)) { - sender.sendMessage(ChatColor.DARK_AQUA + " /mcability " + LocaleLoader.getString("Commands.ToggleAbility")); + sender.sendMessage(ChatColor.DARK_AQUA + " /mcability " + pluginRef.getLocaleManager().getString("Commands.ToggleAbility")); } } @@ -71,41 +77,41 @@ public class McmmoCommand implements CommandExecutor { if (!Permissions.skillreset(sender) && !Permissions.mmoedit(sender) && !Permissions.adminChat(sender) && !Permissions.mcgod(sender)) return; - sender.sendMessage(LocaleLoader.getString("Commands.Other")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Other")); if (Permissions.skillreset(sender)) { - sender.sendMessage(ChatColor.DARK_AQUA + " /skillreset " + LocaleLoader.getString("Commands.Reset")); + sender.sendMessage(ChatColor.DARK_AQUA + " /skillreset " + pluginRef.getLocaleManager().getString("Commands.Reset")); } if (Permissions.mmoedit(sender)) { - sender.sendMessage(ChatColor.DARK_AQUA + " /mmoedit " + LocaleLoader.getString("Commands.mmoedit")); + sender.sendMessage(ChatColor.DARK_AQUA + " /mmoedit " + pluginRef.getLocaleManager().getString("Commands.mmoedit")); } if (Permissions.adminChat(sender)) { - sender.sendMessage(ChatColor.DARK_AQUA + " /adminchat " + LocaleLoader.getString("Commands.AdminToggle")); + sender.sendMessage(ChatColor.DARK_AQUA + " /adminchat " + pluginRef.getLocaleManager().getString("Commands.AdminToggle")); } if (Permissions.mcgod(sender)) { - sender.sendMessage(ChatColor.DARK_AQUA + " /mcgod " + LocaleLoader.getString("Commands.mcgod")); + sender.sendMessage(ChatColor.DARK_AQUA + " /mcgod " + pluginRef.getLocaleManager().getString("Commands.mcgod")); } } private void displayPartyCommands(CommandSender sender) { if (Permissions.party(sender)) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands")); - sender.sendMessage(ChatColor.DARK_AQUA + " /party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1")); - sender.sendMessage(ChatColor.DARK_AQUA + " /party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2")); - sender.sendMessage(ChatColor.DARK_AQUA + " /party quit " + LocaleLoader.getString("Commands.Party.Quit")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Commands")); + sender.sendMessage(ChatColor.DARK_AQUA + " /party create <" + pluginRef.getLocaleManager().getString("Commands.Usage.PartyName") + "> " + pluginRef.getLocaleManager().getString("Commands.Party1")); + sender.sendMessage(ChatColor.DARK_AQUA + " /party join <" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "> " + pluginRef.getLocaleManager().getString("Commands.Party2")); + sender.sendMessage(ChatColor.DARK_AQUA + " /party quit " + pluginRef.getLocaleManager().getString("Commands.Party.Quit")); if (Permissions.partyChat(sender)) { - sender.sendMessage(ChatColor.DARK_AQUA + " /party chat " + LocaleLoader.getString("Commands.Party.Toggle")); + sender.sendMessage(ChatColor.DARK_AQUA + " /party chat " + pluginRef.getLocaleManager().getString("Commands.Party.Toggle")); } - sender.sendMessage(ChatColor.DARK_AQUA + " /party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite")); - sender.sendMessage(ChatColor.DARK_AQUA + " /party accept " + LocaleLoader.getString("Commands.Party.Accept")); + sender.sendMessage(ChatColor.DARK_AQUA + " /party invite <" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "> " + pluginRef.getLocaleManager().getString("Commands.Party.Invite")); + sender.sendMessage(ChatColor.DARK_AQUA + " /party accept " + pluginRef.getLocaleManager().getString("Commands.Party.Accept")); if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) { - sender.sendMessage(ChatColor.DARK_AQUA + " /party teleport <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Teleport")); + sender.sendMessage(ChatColor.DARK_AQUA + " /party teleport <" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "> " + pluginRef.getLocaleManager().getString("Commands.Party.Teleport")); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java index b26e980fd..67ec2fd39 100644 --- a/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McnotifyCommand.java @@ -1,7 +1,7 @@ package com.gmail.nossr50.commands; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; @@ -12,6 +12,13 @@ import org.bukkit.entity.Player; import java.util.List; public class McnotifyCommand implements TabExecutor { + + private mcMMO pluginRef; + + public McnotifyCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { @@ -20,9 +27,9 @@ public class McnotifyCommand implements TabExecutor { //Not Loaded yet if (mcMMOPlayer == null) - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); - sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On"))); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On"))); mcMMOPlayer.toggleChatNotifications(); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java b/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java index 9cc0ed3c1..1f3dba285 100644 --- a/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McrefreshCommand.java @@ -1,11 +1,18 @@ package com.gmail.nossr50.commands; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import org.bukkit.command.CommandSender; public class McrefreshCommand extends ToggleCommand { + + private mcMMO pluginRef; + + public McrefreshCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override protected boolean hasOtherPermission(CommandSender sender) { return Permissions.mcrefreshOthers(sender); @@ -23,11 +30,11 @@ public class McrefreshCommand extends ToggleCommand { mcMMOPlayer.resetToolPrepMode(); mcMMOPlayer.resetAbilityMode(); - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); + mcMMOPlayer.getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Ability.Generic.Refresh")); } @Override protected void sendSuccessMessage(CommandSender sender, String playerName) { - sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", playerName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcrefresh.Success", playerName)); } } diff --git a/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java b/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java index 01d4ebe91..1fd532927 100644 --- a/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; @@ -14,6 +13,13 @@ import java.util.ArrayList; import java.util.List; public class McscoreboardCommand implements TabExecutor { + + private mcMMO pluginRef; + + public McscoreboardCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + private static final List FIRST_ARGS = ImmutableList.of("keep", "time", "clear"); @Override @@ -26,23 +32,23 @@ public class McscoreboardCommand implements TabExecutor { case 1: if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) { ScoreboardManager.clearBoard(sender.getName()); - sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Clear")); return true; } if (args[0].equalsIgnoreCase("keep")) { - if (!mcMMO.getScoreboardSettings().getScoreboardsEnabled()) { - sender.sendMessage(LocaleLoader.getString("Commands.Disabled")); + if (!pluginRef.getScoreboardSettings().getScoreboardsEnabled()) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Disabled")); return true; } if (!ScoreboardManager.isBoardShown(sender.getName())) { - sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.NoBoard")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.NoBoard")); return true; } ScoreboardManager.keepBoard(sender.getName()); - sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Keep")); return true; } @@ -57,7 +63,7 @@ public class McscoreboardCommand implements TabExecutor { int time = Math.abs(Integer.parseInt(args[1])); ScoreboardManager.setRevertTimer(sender.getName(), time); - sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", time)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Timer", time)); return true; } @@ -79,10 +85,10 @@ public class McscoreboardCommand implements TabExecutor { } private boolean help(CommandSender sender) { - sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.0")); - sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.1")); - sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.2")); - sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.3")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Help.0")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Help.1")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Help.2")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Help.3")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java index 3d6dde72b..e4074dc9a 100644 --- a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands; import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; @@ -17,7 +16,12 @@ import java.util.ArrayList; import java.util.List; public class XprateCommand implements TabExecutor { - private final double ORIGINAL_XP_RATE = mcMMO.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult(); + + private mcMMO pluginRef; + + public XprateCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -32,27 +36,27 @@ public class XprateCommand implements TabExecutor { return true; } - if (mcMMO.p.isXPEventEnabled()) { + if (pluginRef.isXPEventEnabled()) { - if (mcMMO.getConfigManager().getConfigEvent().isSendTitleMessages()) { - mcMMO.getNotificationManager().broadcastTitle(mcMMO.p.getServer(), - LocaleLoader.getString("Commands.Event.Stop"), - LocaleLoader.getString("Commands.Event.Stop.Subtitle"), + if (pluginRef.getConfigManager().getConfigEvent().isSendTitleMessages()) { + pluginRef.getNotificationManager().broadcastTitle(pluginRef.getServer(), + pluginRef.getLocaleManager().getString("Commands.Event.Stop"), + pluginRef.getLocaleManager().getString("Commands.Event.Stop.Subtitle"), 10, 10 * 20, 20); } - if (mcMMO.getConfigManager().getConfigEvent().isBroadcastXPRateEventMessages()) { - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop")); - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle")); + if (pluginRef.getConfigManager().getConfigEvent().isBroadcastXPRateEventMessages()) { + pluginRef.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.Stop")); + pluginRef.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.Stop.Subtitle")); } //Admin notification - mcMMO.getNotificationManager().processSensitiveCommandNotification(sender, SensitiveCommandType.XPRATE_END); + pluginRef.getNotificationManager().processSensitiveCommandNotification(sender, SensitiveCommandType.XPRATE_END); - mcMMO.p.toggleXpEventEnabled(); + pluginRef.toggleXpEventEnabled(); } - mcMMO.getDynamicSettingsManager().getExperienceManager().resetGlobalXpMult(); + pluginRef.getDynamicSettingsManager().getExperienceManager().resetGlobalXpMult(); return true; case 2: @@ -66,9 +70,9 @@ public class XprateCommand implements TabExecutor { } if (CommandUtils.shouldDisableToggle(args[1])) { - mcMMO.p.setXPEventEnabled(false); + pluginRef.setXPEventEnabled(false); } else if (CommandUtils.shouldEnableToggle(args[1])) { - mcMMO.p.setXPEventEnabled(true); + pluginRef.setXPEventEnabled(true); } else { return false; } @@ -76,26 +80,26 @@ public class XprateCommand implements TabExecutor { int newXpRate = Integer.parseInt(args[0]); if (newXpRate < 0) { - sender.sendMessage(ChatColor.RED + LocaleLoader.getString("Commands.NegativeNumberWarn")); + sender.sendMessage(ChatColor.RED + pluginRef.getLocaleManager().getString("Commands.NegativeNumberWarn")); return true; } - mcMMO.getDynamicSettingsManager().getExperienceManager().setGlobalXpMult(newXpRate); + pluginRef.getDynamicSettingsManager().getExperienceManager().setGlobalXpMult(newXpRate); - if (mcMMO.getConfigManager().getConfigEvent().isSendTitleMessages()) { - mcMMO.getNotificationManager().broadcastTitle(mcMMO.p.getServer(), - LocaleLoader.getString("Commands.Event.Start"), - LocaleLoader.getString("Commands.Event.XP", newXpRate), + if (pluginRef.getConfigManager().getConfigEvent().isSendTitleMessages()) { + pluginRef.getNotificationManager().broadcastTitle(pluginRef.getServer(), + pluginRef.getLocaleManager().getString("Commands.Event.Start"), + pluginRef.getLocaleManager().getString("Commands.Event.XP", newXpRate), 10, 10 * 20, 20); } - if (mcMMO.getConfigManager().getConfigEvent().isBroadcastXPRateEventMessages()) { - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start")); - mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate)); + if (pluginRef.getConfigManager().getConfigEvent().isBroadcastXPRateEventMessages()) { + pluginRef.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.Start")); + pluginRef.getServer().broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Event.XP", newXpRate)); } //Admin notification - mcMMO.getNotificationManager().processSensitiveCommandNotification(sender, SensitiveCommandType.XPRATE_MODIFY, String.valueOf(newXpRate)); + pluginRef.getNotificationManager().processSensitiveCommandNotification(sender, SensitiveCommandType.XPRATE_MODIFY, String.valueOf(newXpRate)); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java b/src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java index da15b8297..0cecaddb6 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/McmmoReloadLocaleCommand.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.commands.admin; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -10,21 +10,26 @@ import org.bukkit.command.CommandSender; * @author Mark Vainomaa */ public final class McmmoReloadLocaleCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public McmmoReloadLocaleCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 0: - if (!Permissions.reloadlocale(sender)) { - sender.sendMessage(command.getPermissionMessage()); - return true; - } - - LocaleLoader.reloadLocale(); - sender.sendMessage(LocaleLoader.getString("Locale.Reloaded")); - + if (args.length == 0) { + if (!Permissions.reloadlocale(sender)) { + sender.sendMessage(command.getPermissionMessage()); return true; - default: - return false; + } + + pluginRef.getLocaleManager().reloadLocale(); + sender.sendMessage(pluginRef.getLocaleManager().getString("Locale.Reloaded")); + + return true; } + return false; } } diff --git a/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebug.java b/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebug.java index 9ced7e818..734100f28 100644 --- a/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebug.java +++ b/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebug.java @@ -1,11 +1,18 @@ package com.gmail.nossr50.commands.admin; +import com.gmail.nossr50.mcMMO; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; public class PlayerDebug implements CommandExecutor { + private mcMMO pluginRef; + + public PlayerDebug(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { return false; diff --git a/src/main/java/com/gmail/nossr50/commands/chat/AdminChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/AdminChatCommand.java index 41f3746b5..2916483bc 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/AdminChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/AdminChatCommand.java @@ -1,15 +1,16 @@ package com.gmail.nossr50.commands.chat; import com.gmail.nossr50.datatypes.chat.ChatMode; +import com.gmail.nossr50.mcMMO; import org.bukkit.command.CommandSender; public class AdminChatCommand extends ChatCommand { - public AdminChatCommand() { - super(ChatMode.ADMIN); + public AdminChatCommand(mcMMO pluginRef) { + super(ChatMode.ADMIN, pluginRef); } @Override protected void handleChatSending(CommandSender sender, String[] args) { - chatManager.handleChat(sender.getName(), getDisplayName(sender), buildChatMessage(args, 0)); + pluginRef.getChatManager().processAdminChat(sender.getName(), getDisplayName(sender), buildChatMessage(args, 0)); } } diff --git a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java index 27ab659be..b99117205 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java @@ -1,13 +1,9 @@ package com.gmail.nossr50.commands.chat; -import com.gmail.nossr50.chat.ChatManager; -import com.gmail.nossr50.chat.ChatManagerFactory; 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.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableList; @@ -21,12 +17,12 @@ import java.util.ArrayList; import java.util.List; public abstract class ChatCommand implements TabExecutor { - protected ChatManager chatManager; private ChatMode chatMode; + public mcMMO pluginRef; - public ChatCommand(ChatMode chatMode) { + public ChatCommand(ChatMode chatMode, mcMMO pluginRef) { this.chatMode = chatMode; - this.chatManager = ChatManagerFactory.getChatManager(mcMMO.p, chatMode); + this.pluginRef = pluginRef; } @Override @@ -109,19 +105,19 @@ public abstract class ChatCommand implements TabExecutor { } protected String getDisplayName(CommandSender sender) { - return (sender instanceof Player) ? ((Player) sender).getDisplayName() : LocaleLoader.getString("Commands.Chat.Console"); + return (sender instanceof Player) ? ((Player) sender).getDisplayName() : pluginRef.getLocaleManager().getString("Commands.Chat.Console"); } protected abstract void handleChatSending(CommandSender sender, String[] args); private void enableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) { if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None")); return; } - if (chatMode == ChatMode.PARTY && (mcMMOPlayer.getParty().getLevel() < PartyManager.getPartyFeatureUnlockLevel(PartyFeature.CHAT))) { - sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1")); + if (chatMode == ChatMode.PARTY && (mcMMOPlayer.getParty().getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.CHAT))) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.1")); return; } @@ -131,7 +127,7 @@ public abstract class ChatCommand implements TabExecutor { private void disableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) { if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None")); return; } diff --git a/src/main/java/com/gmail/nossr50/commands/chat/McChatSpy.java b/src/main/java/com/gmail/nossr50/commands/chat/McChatSpy.java index 87ef2285f..df05fbcf7 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/McChatSpy.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/McChatSpy.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.chat; import com.gmail.nossr50.commands.ToggleCommand; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Permissions; import org.bukkit.command.CommandSender; @@ -19,12 +18,12 @@ public class McChatSpy extends ToggleCommand { @Override protected void applyCommandAction(McMMOPlayer mcMMOPlayer) { - mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.AdminChatSpy." + (mcMMOPlayer.isPartyChatSpying() ? "Disabled" : "Enabled"))); + mcMMOPlayer.getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Commands.AdminChatSpy." + (mcMMOPlayer.isPartyChatSpying() ? "Disabled" : "Enabled"))); mcMMOPlayer.togglePartyChatSpying(); } @Override protected void sendSuccessMessage(CommandSender sender, String playerName) { - sender.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Toggle", playerName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.AdminChatSpy.Toggle", playerName)); } } diff --git a/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java index d9dfb35c5..5fcaf9d7a 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java @@ -1,18 +1,16 @@ package com.gmail.nossr50.commands.chat; -import com.gmail.nossr50.chat.PartyChatManager; 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.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyChatCommand extends ChatCommand { - public PartyChatCommand() { - super(ChatMode.PARTY); + public PartyChatCommand(mcMMO pluginRef) { + super(ChatMode.PARTY, pluginRef); } @Override @@ -28,33 +26,32 @@ public class PartyChatCommand extends ChatCommand { party = UserManager.getPlayer((Player) sender).getParty(); if (party == null) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None")); return; } - if (party.getLevel() < PartyManager.getPartyFeatureUnlockLevel(PartyFeature.CHAT)) { - sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1")); + if (party.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.CHAT)) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.1")); return; } message = buildChatMessage(args, 0); } else { if (args.length < 2) { - sender.sendMessage(LocaleLoader.getString("Party.Specify")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Specify")); return; } - party = PartyManager.getParty(args[0]); + party = pluginRef.getPartyManager().getParty(args[0]); if (party == null) { - sender.sendMessage(LocaleLoader.getString("Party.InvalidName")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.InvalidName")); return; } message = buildChatMessage(args, 1); } - ((PartyChatManager) chatManager).setParty(party); - chatManager.handleChat(sender.getName(), getDisplayName(sender), message); + pluginRef.getChatManager().processPartyChat(party, getDisplayName(sender), message); } } diff --git a/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java b/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java index cd7f5770d..67e9b2584 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/ConvertDatabaseCommand.java @@ -4,7 +4,6 @@ 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.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.database.DatabaseConversionTask; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; @@ -15,15 +14,22 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class ConvertDatabaseCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public ConvertDatabaseCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 2: DatabaseType previousType = DatabaseType.getDatabaseType(args[1]); - DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType(); + DatabaseType newType = pluginRef.getDatabaseManager().getDatabaseType(); if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) { - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString())); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Database.Same", newType.toString())); return true; } @@ -36,34 +42,34 @@ public class ConvertDatabaseCommand implements CommandExecutor { clazz = Class.forName(args[1]); if (!DatabaseManager.class.isAssignableFrom(clazz)) { - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1])); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Database.InvalidType", args[1])); return true; } oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class) clazz); } catch (Throwable e) { e.printStackTrace(); - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1])); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Database.InvalidType", args[1])); return true; } } - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString())); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString())); UserManager.saveAll(); UserManager.clearAll(); - for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { + for (Player player : pluginRef.getServer().getOnlinePlayers()) { PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId()); if (profile.isLoaded()) { - mcMMO.getDatabaseManager().saveUser(profile); + pluginRef.getDatabaseManager().saveUser(profile); } - new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading } - new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p); + new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(pluginRef); return true; default: diff --git a/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java index 078a5cab6..d245c67a7 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/McpurgeCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.database; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; @@ -10,17 +9,24 @@ import org.bukkit.command.TabExecutor; import java.util.List; public class McpurgeCommand implements TabExecutor { + + private mcMMO pluginRef; + + public McpurgeCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 0: - mcMMO.getDatabaseManager().purgePowerlessUsers(); + pluginRef.getDatabaseManager().purgePowerlessUsers(); - if (mcMMO.getDatabaseCleaningSettings().getOldUserCutoffMonths() != -1) { - mcMMO.getDatabaseManager().purgeOldUsers(); + if (pluginRef.getDatabaseCleaningSettings().getOldUserCutoffMonths() != -1) { + pluginRef.getDatabaseManager().purgeOldUsers(); } - sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcpurge.Success")); return true; default: diff --git a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java index 77c04cd67..28912d6e9 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.database; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; @@ -16,33 +15,37 @@ import java.util.List; import java.util.UUID; public class McremoveCommand implements TabExecutor { + + private mcMMO pluginRef; + + public McremoveCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - String playerName = CommandUtils.getMatchedPlayerName(args[0]); - - if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) { - return true; - } - - UUID uuid = null; - - if(Bukkit.getPlayer(playerName) != null) { - uuid = Bukkit.getPlayer(playerName).getUniqueId(); - } - - if (mcMMO.getDatabaseManager().removeUser(playerName, uuid)) { - sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName)); - } else { - sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen. - } + if (args.length == 1) { + String playerName = CommandUtils.getMatchedPlayerName(args[0]); + if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, pluginRef.getDatabaseManager().loadPlayerProfile(playerName, false))) { return true; + } - default: - return false; + UUID uuid = null; + + if (Bukkit.getPlayer(playerName) != null) { + uuid = Bukkit.getPlayer(playerName).getUniqueId(); + } + + if (pluginRef.getDatabaseManager().removeUser(playerName, uuid)) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcremove.Success", playerName)); + } else { + sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen. + } + + return true; } + return false; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java b/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java index 660d59f4c..2598d79ca 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/MmoshowdbCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands.database; import com.gmail.nossr50.database.DatabaseManagerFactory; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; @@ -11,23 +10,27 @@ import org.bukkit.command.TabExecutor; import java.util.List; public class MmoshowdbCommand implements TabExecutor { + + private mcMMO pluginRef; + + public MmoshowdbCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 0: - Class clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass(); + if (args.length == 0) { + Class clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass(); - if (clazz != null) { - sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName())); - return true; - } - - sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (mcMMO.getMySQLConfigSettings().isMySQLEnabled() ? "sql" : "flatfile"))); + if (clazz != null) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mmoshowdb", clazz.getName())); return true; + } - default: - return false; + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mmoshowdb", (pluginRef.getMySQLConfigSettings().isMySQLEnabled() ? "sql" : "flatfile"))); + return true; } + return false; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java index d81f205d9..2afc1afc7 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java @@ -3,13 +3,20 @@ package com.gmail.nossr50.commands.experience; import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Permissions; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class AddlevelsCommand extends ExperienceCommand { + + private mcMMO pluginRef; + + public AddlevelsCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override protected boolean permissionsCheckSelf(CommandSender sender) { return Permissions.addlevels(sender); @@ -35,11 +42,11 @@ public class AddlevelsCommand extends ExperienceCommand { @Override protected void handlePlayerMessageAll(Player player, int value) { - player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value)); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardAll.1", value)); } @Override protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) { - player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName())); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardSkill.1", value, skill.getName())); } } diff --git a/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java index 560cb943b..c47259b7b 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/AddxpCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.experience.XPGainSource; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.CommandSender; @@ -37,11 +36,11 @@ public class AddxpCommand extends ExperienceCommand { @Override protected void handlePlayerMessageAll(Player player, int value) { - player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value)); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.addxp.AwardAll", value)); } @Override protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) { - player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName())); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.addxp.AwardSkill", value, skill.getName())); } } diff --git a/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java index 0193a0485..14beba99a 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/ConvertExperienceCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands.experience; import com.gmail.nossr50.datatypes.experience.FormulaType; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.database.FormulaConversionTask; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; @@ -12,6 +11,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class ConvertExperienceCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public ConvertExperienceCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { @@ -22,22 +28,22 @@ public class ConvertExperienceCommand implements CommandExecutor { if(formulaType.toString().equalsIgnoreCase(args[1])) { FormulaType previousType = formulaType; - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), mcMMO.getConfigManager().getConfigLeveling().getFormulaType().toString())); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Experience.Start", previousType.toString(), pluginRef.getConfigManager().getConfigLeveling().getFormulaType().toString())); UserManager.saveAll(); UserManager.clearAll(); - new FormulaConversionTask(sender, previousType).runTaskLater(mcMMO.p, 1); + new FormulaConversionTask(sender, previousType).runTaskLater(pluginRef, 1); - for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { - new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + for (Player player : pluginRef.getServer().getOnlinePlayers()) { + new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading } return true; } } - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Experience.Invalid")); return true; diff --git a/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java index 9bec99bfc..be6ed72fe 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.experience; 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.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; @@ -20,11 +19,18 @@ import java.util.List; import java.util.UUID; public abstract class ExperienceCommand implements TabExecutor { + + private mcMMO pluginRef; + + public ExperienceCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) { if (skill == null) { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardAll.2", playerName)); } else { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName)); } } @@ -54,13 +60,13 @@ public abstract class ExperienceCommand implements TabExecutor { } if (skill != null && skill.isChildSkill()) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Skill.ChildSkill")); return true; } //Profile not loaded if (UserManager.getPlayer(sender.getName()) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } @@ -85,7 +91,7 @@ public abstract class ExperienceCommand implements TabExecutor { } if (skill != null && skill.isChildSkill()) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Skill.ChildSkill")); return true; } @@ -97,11 +103,11 @@ public abstract class ExperienceCommand implements TabExecutor { // 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) { UUID uuid = null; - OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName); + OfflinePlayer player = pluginRef.getServer().getOfflinePlayer(playerName); if (player != null) { uuid = player.getUniqueId(); } - PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false); + PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, uuid, false); if (CommandUtils.unloadedProfile(sender, profile)) { return true; diff --git a/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java index 8049a3a22..0b05b912c 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java @@ -3,13 +3,17 @@ package com.gmail.nossr50.commands.experience; import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Permissions; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class MmoeditCommand extends ExperienceCommand { + public MmoeditCommand(mcMMO pluginRef) { + super(pluginRef); + } + @Override protected boolean permissionsCheckSelf(CommandSender sender) { return Permissions.mmoedit(sender); @@ -41,11 +45,11 @@ public class MmoeditCommand extends ExperienceCommand { @Override protected void handlePlayerMessageAll(Player player, int value) { - player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value)); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.mmoedit.AllSkills.1", value)); } @Override protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) { - player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value)); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.mmoedit.Modified.1", skill.getName(), value)); } } diff --git a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java index c7a20ca5e..268444bcc 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason; 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.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Permissions; @@ -27,11 +26,18 @@ import java.util.UUID; * value/quantity argument is removed. */ public class SkillresetCommand implements TabExecutor { + + private mcMMO pluginRef; + + public SkillresetCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) { if (skill == null) { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardAll.2", playerName)); } else { - sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName)); } } @@ -84,11 +90,11 @@ public class SkillresetCommand implements TabExecutor { // 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) { UUID uuid = null; - OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName); + OfflinePlayer player = pluginRef.getServer().getOfflinePlayer(playerName); if (player != null) { uuid = player.getUniqueId(); } - PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false); + PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, uuid, false); if (CommandUtils.unloadedProfile(sender, profile)) { return true; @@ -143,11 +149,11 @@ public class SkillresetCommand implements TabExecutor { } protected void handlePlayerMessageAll(Player player) { - player.sendMessage(LocaleLoader.getString("Commands.Reset.All")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Reset.All")); } protected void handlePlayerMessageSkill(Player player, PrimarySkillType skill) { - player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getName())); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Reset.Single", skill.getName())); } private boolean validateArguments(CommandSender sender, String skillName) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java index af4f1bc46..be2d444bc 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -12,35 +10,32 @@ import org.bukkit.entity.Player; public class PartyAcceptCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - switch (args.length) { - case 1: - Player player = (Player) sender; + if (args.length == 1) { + Player player = (Player) sender; - //Check if player profile is loaded - if (UserManager.getPlayer(player) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); - return true; - } - - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - - - if (!mcMMOPlayer.hasPartyInvite()) { - sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites")); - return true; - } - - // Changing parties - if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) { - return true; - } - - PartyManager.joinInvitedParty(mcMMOPlayer); + //Check if player profile is loaded + if (UserManager.getPlayer(player) == null) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; + } - default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept")); + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + + + if (!mcMMOPlayer.hasPartyInvite()) { + sender.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoInvites")); return true; + } + + // Changing parties + if (!pluginRef.getPartyManager().changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) { + return true; + } + + pluginRef.getPartyManager().joinInvitedParty(mcMMOPlayer); + return true; } + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "party", "accept")); + return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java index 36d855107..26f129819 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java @@ -1,9 +1,7 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.OfflinePlayer; @@ -13,30 +11,37 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyChangeOwnerCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyChangeOwnerCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 2: //Check if player profile is loaded if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } Party playerParty = UserManager.getPlayer((Player) sender).getParty(); String targetName = CommandUtils.getMatchedPlayerName(args[1]); - OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName); + OfflinePlayer target = pluginRef.getServer().getOfflinePlayer(targetName); if (!playerParty.hasMember(target.getUniqueId())) { - sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.NotInYourParty", targetName)); return true; } - PartyManager.setPartyLeader(target.getUniqueId(), playerParty); + pluginRef.getPartyManager().setPartyLeader(target.getUniqueId(), playerParty); return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "owner", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java index 607e03fed..b80b948bc 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -12,7 +11,7 @@ public class PartyChangePasswordCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } @@ -33,8 +32,8 @@ public class PartyChangePasswordCommand implements CommandExecutor { return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "[clear|reset]")); - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "<" + LocaleLoader.getString("Commands.Usage.Password") + ">")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "password", "[clear|reset]")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "password", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Password") + ">")); return true; } } @@ -42,12 +41,12 @@ public class PartyChangePasswordCommand implements CommandExecutor { private void unprotectParty(Party party, CommandSender sender) { party.setLocked(true); party.setPassword(null); - sender.sendMessage(LocaleLoader.getString("Party.Password.Removed")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Password.Removed")); } private void protectParty(Party party, CommandSender sender, String password) { party.setLocked(true); party.setPassword(password); - sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Password.Set", password)); } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java index fb0fa75af..a7148f555 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand; import com.gmail.nossr50.commands.party.teleport.PtpCommand; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.commands.CommandUtils; @@ -24,11 +23,19 @@ import java.util.Collections; import java.util.List; public class PartyCommand implements TabExecutor { - private static final List PARTY_SUBCOMMANDS; - private static final List XPSHARE_COMPLETIONS = ImmutableList.of("none", "equal"); - private static final List ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc"); - static { + private mcMMO pluginRef; + + public PartyCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + initSubCommandList(); + } + + private List PARTY_SUBCOMMANDS; + private final List XPSHARE_COMPLETIONS = ImmutableList.of("none", "equal"); + private final List ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc"); + + private void initSubCommandList() { ArrayList subcommands = new ArrayList<>(); for (PartySubcommandType subcommand : PartySubcommandType.values()) { @@ -61,7 +68,7 @@ public class PartyCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { //If the party system is disabled, don't fire this command - if (!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled()) + if (!pluginRef.getConfigManager().getConfigParty().isPartySystemEnabled()) return true; if (CommandUtils.noConsoleUsage(sender)) { @@ -80,7 +87,7 @@ public class PartyCommand implements TabExecutor { } if (UserManager.getPlayer(player) == null) { - player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + player.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } @@ -88,7 +95,7 @@ public class PartyCommand implements TabExecutor { if (args.length < 1) { if (!mcMMOPlayer.inParty()) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None")); return printUsage(player); } @@ -122,7 +129,7 @@ public class PartyCommand implements TabExecutor { // Party member commands if (!mcMMOPlayer.inParty()) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None")); return printUsage(player); } @@ -143,7 +150,7 @@ public class PartyCommand implements TabExecutor { // Party leader commands if (!mcMMOPlayer.getParty().getLeader().getUniqueId().equals(player.getUniqueId())) { - sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.NotOwner")); return true; } @@ -210,7 +217,7 @@ public class PartyCommand implements TabExecutor { //Not Loaded if (UserManager.getPlayer(player) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return ImmutableList.of(); } @@ -236,9 +243,9 @@ public class PartyCommand implements TabExecutor { } private boolean printUsage(Player player) { - player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join")); - player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); - player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?")); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.0", "/party join")); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.1", "/party create")); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.2", "/party ?")); return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java index 386b10adb..3d707a660 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -19,25 +17,25 @@ public class PartyCreateCommand implements CommandExecutor { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); if (UserManager.getPlayer(player) == null) { - player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + player.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } // Check to see if the party exists, and if it does cancel creating a new party - if (PartyManager.checkPartyExistence(player, args[1])) { + if (pluginRef.getPartyManager().checkPartyExistence(player, args[1])) { return true; } // Changing parties - if (!PartyManager.changeOrJoinParty(mcMMOPlayer, args[1])) { + if (!pluginRef.getPartyManager().changeOrJoinParty(mcMMOPlayer, args[1])) { return true; } - PartyManager.createParty(mcMMOPlayer, args[1], getPassword(args)); + pluginRef.getPartyManager().createParty(mcMMOPlayer, args[1], getPassword(args)); return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "create", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.3", "party", "create", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.PartyName") + ">", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Password") + "]")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java index 315fa96b7..a9cbd9c9c 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java @@ -2,8 +2,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.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -16,7 +14,7 @@ public class PartyDisbandCommand implements CommandExecutor { switch (args.length) { case 1: if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } @@ -24,18 +22,18 @@ public class PartyDisbandCommand implements CommandExecutor { String partyName = playerParty.getName(); for (Player member : playerParty.getOnlineMembers()) { - if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) { + if (!pluginRef.getPartyManager().handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) { return true; } - member.sendMessage(LocaleLoader.getString("Party.Disband")); + member.sendMessage(pluginRef.getLocaleManager().getString("Party.Disband")); } - PartyManager.disbandParty(playerParty); + pluginRef.getPartyManager().disbandParty(playerParty); return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "party", "disband")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java index fcf4908c0..eefa9891a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.party; -import com.gmail.nossr50.locale.LocaleLoader; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -11,19 +10,19 @@ public class PartyHelpCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 1: - sender.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit")); - sender.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); - sender.sendMessage(LocaleLoader.getString("Party.Help.4", "/party ")); - sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password")); - sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick")); - sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader")); - sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband")); - sender.sendMessage(LocaleLoader.getString("Party.Help.9", "/party itemshare")); - sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party xpshare")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.3", "/party join", "/party quit")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.1", "/party create")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.4", "/party ")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.5", "/party password")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.6", "/party kick")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.7", "/party leader")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.8", "/party disband")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.9", "/party itemshare")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Help.10", "/party xpshare")); return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "help")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "party", "help")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java index d5054b0d8..6bff77540 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java @@ -4,8 +4,6 @@ import com.gmail.nossr50.datatypes.party.Party; 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.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -23,7 +21,7 @@ public class PartyInfoCommand implements CommandExecutor { case 0: case 1: if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } Player player = (Player) sender; @@ -37,26 +35,26 @@ public class PartyInfoCommand implements CommandExecutor { return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "info")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "party", "info")); return true; } } private void displayPartyHeader(Player player, Party party) { - player.sendMessage(LocaleLoader.getString("Commands.Party.Header")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Header")); /*if (!party.hasReachedLevelCap()) { status.append(" (").append(party.getXpToLevelPercentage()).append(")"); }*/ - player.sendMessage(LocaleLoader.getString("Commands.Party.Status", party.getName(), LocaleLoader.getString("Party.Status." + (party.isLocked() ? "Locked" : "Unlocked")), party.getLevel()) + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Status", party.getName(), pluginRef.getLocaleManager().getString("Party.Status." + (party.isLocked() ? "Locked" : "Unlocked")), party.getLevel()) /*if (!party.hasReachedLevelCap()) { status.append(" (").append(party.getXpToLevelPercentage()).append(")"); }*/); } private void displayPartyFeatures(Player player, Party party) { - player.sendMessage(LocaleLoader.getString("Commands.Party.Features.Header")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Features.Header")); List unlockedPartyFeatures = new ArrayList<>(); List lockedPartyFeatures = new ArrayList<>(); @@ -73,7 +71,7 @@ public class PartyInfoCommand implements CommandExecutor { } } - player.sendMessage(LocaleLoader.getString("Commands.Party.UnlockedFeatures", unlockedPartyFeatures.isEmpty() ? "None" : unlockedPartyFeatures)); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.UnlockedFeatures", unlockedPartyFeatures.isEmpty() ? "None" : unlockedPartyFeatures)); for (String message : lockedPartyFeatures) { player.sendMessage(message); @@ -81,7 +79,7 @@ public class PartyInfoCommand implements CommandExecutor { } private boolean isUnlockedFeature(Party party, PartyFeature partyFeature) { - return party.getLevel() >= PartyManager.getPartyFeatureUnlockLevel(partyFeature); + return party.getLevel() >= pluginRef.getPartyManager().getPartyFeatureUnlockLevel(partyFeature); } private void displayShareModeInfo(Player player, Party party) { @@ -98,21 +96,21 @@ public class PartyInfoCommand implements CommandExecutor { String separator = ""; if (xpShareEnabled) { - expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", party.getXpShareMode().toString()); + expShareInfo = pluginRef.getLocaleManager().getString("Commands.Party.ExpShare", party.getXpShareMode().toString()); } if (itemShareEnabled) { - itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", party.getItemShareMode().toString()); + itemShareInfo = pluginRef.getLocaleManager().getString("Commands.Party.ItemShare", party.getItemShareMode().toString()); } if (xpShareEnabled && itemShareEnabled) { separator = ChatColor.DARK_GRAY + " || "; } - player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo); if (itemSharingActive) { - player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", party.getItemShareCategories())); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.ItemShareCategories", party.getItemShareCategories())); } } @@ -121,11 +119,11 @@ public class PartyInfoCommand implements CommandExecutor { * Only show members of the party that this member can see */ - List nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer); + List nearMembers = pluginRef.getPartyManager().getNearVisibleMembers(mcMMOPlayer); int membersOnline = party.getVisibleMembers(player).size(); - player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); - player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", nearMembers.size() + 1, membersOnline)); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Members.Header")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.MembersNear", nearMembers.size() + 1, membersOnline)); player.sendMessage(party.createMembersList(player)); } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java index 15be8037e..dd8187590 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java @@ -2,9 +2,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.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; @@ -27,7 +24,7 @@ public class PartyInviteCommand implements CommandExecutor { Player target = mcMMOTarget.getPlayer(); if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } @@ -36,39 +33,39 @@ public class PartyInviteCommand implements CommandExecutor { String playerName = player.getName(); if (player.equals(target)) { - sender.sendMessage(LocaleLoader.getString("Party.Invite.Self")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Invite.Self")); return true; } - if (PartyManager.inSameParty(player, target)) { - sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName)); + if (pluginRef.getPartyManager().inSameParty(player, target)) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Player.InSameParty", targetName)); return true; } - if (!PartyManager.canInvite(mcMMOPlayer)) { - player.sendMessage(LocaleLoader.getString("Party.Locked")); + if (!pluginRef.getPartyManager().canInvite(mcMMOPlayer)) { + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Locked")); return true; } Party playerParty = mcMMOPlayer.getParty(); - if (mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) - if (PartyManager.isPartyFull(target, playerParty)) { - player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", + if (pluginRef.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) + if (pluginRef.getPartyManager().isPartyFull(target, playerParty)) { + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), - mcMMO.getConfigManager().getConfigParty().getPartySizeLimit())); + pluginRef.getConfigManager().getConfigParty().getPartySizeLimit())); return true; } mcMMOTarget.setPartyInvite(playerParty); - sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); - target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), playerName)); - target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Invite.Success")); + target.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Invite.0", playerParty.getName(), playerName)); + target.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Invite.1")); return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "invite", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java index cf7d4e3a5..8e2a71b38 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java @@ -4,8 +4,6 @@ import com.gmail.nossr50.datatypes.party.ItemShareType; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.ShareMode; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; @@ -18,14 +16,14 @@ public class PartyItemShareCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } Party party = UserManager.getPlayer((Player) sender).getParty(); - if (party.getLevel() < PartyManager.getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) { - sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.4")); + if (party.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.4")); return true; } @@ -34,7 +32,7 @@ public class PartyItemShareCommand implements CommandExecutor { ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase()); if (mode == null) { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", "")); return true; } @@ -49,21 +47,21 @@ public class PartyItemShareCommand implements CommandExecutor { } else if (CommandUtils.shouldDisableToggle(args[2])) { toggle = false; } else { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", " ")); return true; } try { handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase()), toggle); } catch (IllegalArgumentException ex) { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", " ")); } return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "")); - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", " ")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", "")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", " ")); return true; } } @@ -71,7 +69,7 @@ public class PartyItemShareCommand implements CommandExecutor { private void handleChangingShareMode(Party party, ShareMode mode) { party.setItemShareMode(mode); - String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))); + String changeModeMessage = pluginRef.getLocaleManager().getString("Commands.Party.SetSharing", pluginRef.getLocaleManager().getString("Party.ShareType.Item"), pluginRef.getLocaleManager().getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))); for (Player member : party.getOnlineMembers()) { member.sendMessage(changeModeMessage); @@ -81,7 +79,7 @@ public class PartyItemShareCommand implements CommandExecutor { private void handleToggleItemShareCategory(Party party, ItemShareType type, boolean toggle) { party.setSharingDrops(type, toggle); - String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled"); + String toggleMessage = pluginRef.getLocaleManager().getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled"); for (Player member : party.getOnlineMembers()) { member.sendMessage(toggleMessage); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java index f5b2939bd..2085d1448 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java @@ -2,9 +2,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.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; @@ -28,14 +25,14 @@ public class PartyJoinCommand implements CommandExecutor { Player target = mcMMOTarget.getPlayer(); if (!mcMMOTarget.inParty()) { - sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.PlayerNotInParty", targetName)); return true; } Player player = (Player) sender; if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } @@ -43,36 +40,36 @@ public class PartyJoinCommand implements CommandExecutor { Party targetParty = mcMMOTarget.getParty(); if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) { - sender.sendMessage(LocaleLoader.getString("Party.Join.Self")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Join.Self")); return true; } String password = getPassword(args); // Make sure party passwords match - if (!PartyManager.checkPartyPassword(player, targetParty, password)) { + if (!pluginRef.getPartyManager().checkPartyPassword(player, targetParty, password)) { return true; } String partyName = targetParty.getName(); // Changing parties - if (!PartyManager.changeOrJoinParty(mcMMOPlayer, partyName)) { + if (!pluginRef.getPartyManager().changeOrJoinParty(mcMMOPlayer, partyName)) { return true; } - if (mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) - if (PartyManager.isPartyFull(player, targetParty)) { - player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString())); + if (pluginRef.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) + if (pluginRef.getPartyManager().isPartyFull(player, targetParty)) { + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.PartyFull", targetParty.toString())); return true; } - player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName)); - PartyManager.addToParty(mcMMOPlayer, targetParty); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Join", partyName)); + pluginRef.getPartyManager().addToParty(mcMMOPlayer, targetParty); return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "join", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.3", "party", "join", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Password") + "]")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java index b2c9e63a8..55dd0e4b8 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java @@ -2,9 +2,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.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.OfflinePlayer; @@ -19,7 +16,7 @@ public class PartyKickCommand implements CommandExecutor { switch (args.length) { case 2: if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } @@ -27,29 +24,29 @@ public class PartyKickCommand implements CommandExecutor { String targetName = CommandUtils.getMatchedPlayerName(args[1]); if (!playerParty.hasMember(targetName)) { - sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.NotInYourParty", targetName)); return true; } - OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName); + OfflinePlayer target = pluginRef.getServer().getOfflinePlayer(targetName); if (target.isOnline()) { Player onlineTarget = target.getPlayer(); String partyName = playerParty.getName(); - if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) { + if (!pluginRef.getPartyManager().handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) { return true; } - PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget)); - onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName)); + pluginRef.getPartyManager().processPartyLeaving(UserManager.getPlayer(onlineTarget)); + onlineTarget.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Kick", partyName)); } - PartyManager.removeFromParty(target, playerParty); + pluginRef.getPartyManager().removeFromParty(target, playerParty); return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "kick", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java index 3583afd25..877895801 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; @@ -46,29 +45,29 @@ public class PartyLockCommand implements CommandExecutor { } private void sendUsageStrings(CommandSender sender) { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]")); - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "lock", "[on|off]")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "party", "unlock")); } private void togglePartyLock(CommandSender sender, boolean lock) { if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return; } Party party = UserManager.getPlayer((Player) sender).getParty(); if (!Permissions.partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) { - sender.sendMessage(LocaleLoader.getString("mcMMO.NoPermission")); + sender.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoPermission")); return; } if (lock ? party.isLocked() : !party.isLocked()) { - sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "IsLocked" : "IsntLocked"))); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party." + (lock ? "IsLocked" : "IsntLocked"))); return; } party.setLocked(lock); - sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "Locked" : "Unlocked"))); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party." + (lock ? "Locked" : "Unlocked"))); } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java index 1c10c0d99..569b88ec6 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java @@ -3,8 +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.events.party.McMMOPartyChangeEvent.EventReason; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -19,23 +17,23 @@ public class PartyQuitCommand implements CommandExecutor { Player player = (Player) sender; if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); Party playerParty = mcMMOPlayer.getParty(); - if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) { + if (!pluginRef.getPartyManager().handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) { return true; } - PartyManager.removeFromParty(mcMMOPlayer); - sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave")); + pluginRef.getPartyManager().removeFromParty(mcMMOPlayer); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Leave")); return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "quit")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "party", "quit")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java index adebc23c3..129d72ef2 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java @@ -3,8 +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.events.party.McMMOPartyChangeEvent.EventReason; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -17,7 +15,7 @@ public class PartyRenameCommand implements CommandExecutor { switch (args.length) { case 2: if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } @@ -29,36 +27,36 @@ public class PartyRenameCommand implements CommandExecutor { // This is to prevent party leaders from spamming other players with the rename message if (oldPartyName.equalsIgnoreCase(newPartyName)) { - sender.sendMessage(LocaleLoader.getString("Party.Rename.Same")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Rename.Same")); return true; } Player player = mcMMOPlayer.getPlayer(); // Check to see if the party exists, and if it does cancel renaming the party - if (PartyManager.checkPartyExistence(player, newPartyName)) { + if (pluginRef.getPartyManager().checkPartyExistence(player, newPartyName)) { return true; } String leaderName = playerParty.getLeader().getPlayerName(); for (Player member : playerParty.getOnlineMembers()) { - if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) { + if (!pluginRef.getPartyManager().handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) { return true; } if (!member.getName().equalsIgnoreCase(leaderName)) { - member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName)); + member.sendMessage(pluginRef.getLocaleManager().getString("Party.InformedOnNameChange", leaderName, newPartyName)); } } playerParty.setName(newPartyName); - sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Rename", newPartyName)); return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "rename", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.PartyName") + ">")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java index 222fc81c0..fe8bba31e 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java @@ -3,8 +3,6 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.ShareMode; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; @@ -17,14 +15,14 @@ public class PartyXpShareCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } Party party = UserManager.getPlayer((Player) sender).getParty(); - if (party.getLevel() < PartyManager.getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) { - sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.5")); + if (party.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.5")); return true; } @@ -35,13 +33,13 @@ public class PartyXpShareCommand implements CommandExecutor { } else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) { handleChangingShareMode(party, ShareMode.EQUAL); } else { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "xpshare", "")); } return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "xpshare", "")); return true; } } @@ -49,7 +47,7 @@ public class PartyXpShareCommand implements CommandExecutor { private void handleChangingShareMode(Party party, ShareMode mode) { party.setXpShareMode(mode); - String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Xp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))); + String changeModeMessage = pluginRef.getLocaleManager().getString("Commands.Party.SetSharing", pluginRef.getLocaleManager().getString("Party.ShareType.Xp"), pluginRef.getLocaleManager().getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))); for (Player member : party.getOnlineMembers()) { member.sendMessage(changeModeMessage); diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java index 33415bc33..ad30e5d94 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.commands.party.alliance; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -15,27 +13,27 @@ public class PartyAllianceAcceptCommand implements CommandExecutor { switch (args.length) { case 2: if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } Player player = (Player) sender; McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); if (!mcMMOPlayer.hasPartyAllianceInvite()) { - sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites")); + sender.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoInvites")); return true; } if (mcMMOPlayer.getParty().getAlly() != null) { - player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.AlreadyAllies")); return true; } - PartyManager.acceptAllianceInvite(mcMMOPlayer); + pluginRef.getPartyManager().acceptAllianceInvite(mcMMOPlayer); return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "alliance", "accept")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java index a7e89bba8..5652de6ec 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java @@ -3,8 +3,6 @@ package com.gmail.nossr50.commands.party.alliance; 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.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableList; @@ -35,7 +33,7 @@ public class PartyAllianceCommand implements TabExecutor { } if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } @@ -46,8 +44,8 @@ public class PartyAllianceCommand implements TabExecutor { switch (args.length) { case 1: - if (playerParty.getLevel() < PartyManager.getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) { - sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3")); + if (playerParty.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.3")); return true; } @@ -64,8 +62,8 @@ public class PartyAllianceCommand implements TabExecutor { case 2: case 3: - if (playerParty.getLevel() < PartyManager.getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) { - sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3")); + if (playerParty.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.3")); return true; } @@ -98,8 +96,8 @@ public class PartyAllianceCommand implements TabExecutor { } private void printUsage() { - player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Help.0")); - player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Help.1")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Help.0")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Help.1")); } @Override @@ -120,12 +118,12 @@ public class PartyAllianceCommand implements TabExecutor { } private void displayPartyHeader() { - player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Header")); - player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Ally", playerParty.getName(), targetParty.getName())); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Header")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Ally", playerParty.getName(), targetParty.getName())); } private void displayMemberInfo(McMMOPlayer mcMMOPlayer) { - player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Members.Header")); player.sendMessage(playerParty.createMembersList(player)); player.sendMessage(ChatColor.DARK_GRAY + "----------------------------"); player.sendMessage(targetParty.createMembersList(player)); diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java index b8c31af11..aef23d8c5 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java @@ -2,8 +2,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.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -16,7 +14,7 @@ public class PartyAllianceDisbandCommand implements CommandExecutor { switch (args.length) { case 2: if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } Player player = (Player) sender; @@ -24,15 +22,15 @@ public class PartyAllianceDisbandCommand implements CommandExecutor { Party party = mcMMOPlayer.getParty(); if (party.getAlly() == null) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.None")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.None")); return true; } - PartyManager.disbandAlliance(player, party, party.getAlly()); + pluginRef.getPartyManager().disbandAlliance(player, party, party.getAlly()); return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "alliance", "disband")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java index 1f6f5137b..83453ea78 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java @@ -2,8 +2,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.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; @@ -26,7 +24,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor { Player target = mcMMOTarget.getPlayer(); if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } @@ -35,41 +33,41 @@ public class PartyAllianceInviteCommand implements CommandExecutor { String playerName = player.getName(); if (player.equals(target)) { - sender.sendMessage(LocaleLoader.getString("Party.Invite.Self")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Invite.Self")); return true; } if (!mcMMOTarget.inParty()) { - player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName)); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.PlayerNotInParty", targetName)); return true; } - if (PartyManager.inSameParty(player, target)) { - sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName)); + if (pluginRef.getPartyManager().inSameParty(player, target)) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Player.InSameParty", targetName)); return true; } if (!mcMMOTarget.getParty().getLeader().getUniqueId().equals(target.getUniqueId())) { - player.sendMessage(LocaleLoader.getString("Party.Target.NotOwner", targetName)); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Target.NotOwner", targetName)); return true; } Party playerParty = mcMMOPlayer.getParty(); if (playerParty.getAlly() != null) { - player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.AlreadyAllies")); return true; } mcMMOTarget.setPartyAllianceInvite(playerParty); - sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); - target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.0", playerParty.getName(), playerName)); - target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.1")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Invite.Success")); + target.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Invite.0", playerParty.getName(), playerName)); + target.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Invite.1")); return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "alliance", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.3", "party", "alliance", "invite", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">")); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java index e2b784aa1..78d9efcfc 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptAnyCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands.party.teleport; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; @@ -19,9 +18,9 @@ public class PtpAcceptAnyCommand implements CommandExecutor { PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord(); if (ptpRecord.isConfirmRequired()) { - sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.AcceptAny.Disabled")); } else { - sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.AcceptAny.Enabled")); } ptpRecord.toggleConfirmRequired(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java index 71b2c60bb..fd6e8c5e9 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands.party.teleport; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; @@ -13,6 +12,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PtpAcceptCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PtpAcceptCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!Permissions.partyTeleportAccept(sender)) { @@ -21,7 +27,7 @@ public class PtpAcceptCommand implements CommandExecutor { } if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } @@ -29,13 +35,13 @@ public class PtpAcceptCommand implements CommandExecutor { PartyTeleportRecord ptpRecord = UserManager.getPlayer(player).getPartyTeleportRecord(); if (!ptpRecord.hasRequest()) { - player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.NoRequests")); return true; } - if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), mcMMO.getConfigManager().getConfigParty().getPTP().getPtpRequestTimeout())) { + if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), pluginRef.getConfigManager().getConfigParty().getPTP().getPtpRequestTimeout())) { ptpRecord.removeRequest(); - player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.RequestExpired")); return true; } @@ -46,16 +52,16 @@ public class PtpAcceptCommand implements CommandExecutor { return true; } - if (mcMMO.getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) { + if (pluginRef.getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) { World targetWorld = target.getWorld(); World playerWorld = player.getWorld(); if (!Permissions.partyTeleportAllWorlds(target)) { if (!Permissions.partyTeleportWorld(target, targetWorld)) { - target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName())); + target.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.NoWorldPermissions", targetWorld.getName())); return true; } else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) { - target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName())); + target.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.NoWorldPermissions", playerWorld.getName())); return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java index 6bf0c182c..909bee84f 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java @@ -5,9 +5,7 @@ import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.runnables.items.TeleportationWarmup; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; @@ -15,7 +13,6 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; -import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; @@ -29,13 +26,20 @@ import java.util.ArrayList; import java.util.List; public class PtpCommand implements TabExecutor { - public static final List TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall"); + + private mcMMO pluginRef; + + public PtpCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + + public final List TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall"); private CommandExecutor ptpToggleCommand = new PtpToggleCommand(); private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand(); private CommandExecutor ptpAcceptCommand = new PtpAcceptCommand(); - protected static boolean canTeleport(CommandSender sender, Player player, String targetName) { + protected boolean canTeleport(CommandSender sender, Player player, String targetName) { McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName); if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { @@ -45,49 +49,49 @@ public class PtpCommand implements TabExecutor { Player target = mcMMOTarget.getPlayer(); if (player.equals(target)) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Self")); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Teleport.Self")); return false; } - if (!PartyManager.inSameParty(player, target)) { - player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); + if (!pluginRef.getPartyManager().inSameParty(player, target)) { + player.sendMessage(pluginRef.getLocaleManager().getString("Party.NotInYourParty", targetName)); return false; } if (!mcMMOTarget.getPartyTeleportRecord().isEnabled()) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", targetName)); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Teleport.Disabled", targetName)); return false; } if (!target.isValid()) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead")); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Teleport.Dead")); return false; } return true; } - protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) { + protected void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) { if (UserManager.getPlayer(targetPlayer) == null) { - targetPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + targetPlayer.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return; } if (UserManager.getPlayer(teleportingPlayer) == null) { - teleportingPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + teleportingPlayer.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return; } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer); McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer); - long warmup = mcMMO.getConfigManager().getConfigParty().getPTP().getPtpWarmup(); + long warmup = pluginRef.getConfigManager().getConfigParty().getPTP().getPtpWarmup(); mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer); if (warmup > 0) { - teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup)); - new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup); + teleportingPlayer.sendMessage(pluginRef.getLocaleManager().getString("Teleport.Commencing", warmup)); + new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(pluginRef, 20 * warmup); } else { EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer); } @@ -103,7 +107,7 @@ public class PtpCommand implements TabExecutor { /* WORLD GUARD MAIN FLAG CHECK */ if (WorldGuardUtils.isWorldGuardLoaded()) { - if (!WorldGuardManager.getInstance().hasMainFlag(player)) + if (!pluginRef.getWorldGuardManager().hasMainFlag(player)) return true; } @@ -116,73 +120,70 @@ public class PtpCommand implements TabExecutor { } if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); if (!mcMMOPlayer.inParty()) { - sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None")); return true; } Party party = mcMMOPlayer.getParty(); - if (party.getLevel() < PartyManager.getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) { - sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.2")); + if (party.getLevel() < pluginRef.getPartyManager().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) { + sender.sendMessage(pluginRef.getLocaleManager().getString("Party.Feature.Disabled.2")); return true; } - switch (args.length) { - case 1: - if (args[0].equalsIgnoreCase("toggle")) { - return ptpToggleCommand.onCommand(sender, command, label, args); - } + if (args.length == 1) { + if (args[0].equalsIgnoreCase("toggle")) { + return ptpToggleCommand.onCommand(sender, command, label, args); + } - if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) { - return ptpAcceptAnyCommand.onCommand(sender, command, label, args); - } + if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) { + return ptpAcceptAnyCommand.onCommand(sender, command, label, args); + } - long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); - int hurtCooldown = mcMMO.getConfigManager().getConfigParty().getPTP().getPtpRecentlyHurtCooldown(); + long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); + int hurtCooldown = pluginRef.getConfigManager().getConfigParty().getPTP().getPtpRecentlyHurtCooldown(); - if (hurtCooldown > 0) { - int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player); + if (hurtCooldown > 0) { + int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player); - if (timeRemaining > 0) { - player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining)); - return true; - } - } - - if (args[0].equalsIgnoreCase("accept")) { - return ptpAcceptCommand.onCommand(sender, command, label, args); - } - - if (!Permissions.partyTeleportSend(sender)) { - sender.sendMessage(command.getPermissionMessage()); + if (timeRemaining > 0) { + player.sendMessage(pluginRef.getLocaleManager().getString("Item.Injured.Wait", timeRemaining)); return true; } + } - int ptpCooldown = mcMMO.getConfigManager().getConfigParty().getPTP().getPtpCooldown(); - long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse(); + if (args[0].equalsIgnoreCase("accept")) { + return ptpAcceptCommand.onCommand(sender, command, label, args); + } - if (ptpCooldown > 0) { - int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player); - - if (timeRemaining > 0) { - player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining)); - return true; - } - } - - sendTeleportRequest(sender, player, CommandUtils.getMatchedPlayerName(args[0])); + if (!Permissions.partyTeleportSend(sender)) { + sender.sendMessage(command.getPermissionMessage()); return true; + } - default: - return false; + int ptpCooldown = pluginRef.getConfigManager().getConfigParty().getPTP().getPtpCooldown(); + long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse(); + + if (ptpCooldown > 0) { + int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player); + + if (timeRemaining > 0) { + player.sendMessage(pluginRef.getLocaleManager().getString("Item.Generic.Wait", timeRemaining)); + return true; + } + } + + sendTeleportRequest(sender, player, CommandUtils.getMatchedPlayerName(args[0])); + return true; } + return false; } @Override @@ -193,7 +194,7 @@ public class PtpCommand implements TabExecutor { if (matches.size() == 0) { if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return ImmutableList.of(); } @@ -232,9 +233,9 @@ public class PtpCommand implements TabExecutor { ptpRecord.setRequestor(player); ptpRecord.actualizeTimeout(); - player.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Invite.Success")); - target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName())); - target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", mcMMO.getConfigManager().getConfigParty().getPTP().getPtpRequestTimeout())); + target.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.Request1", player.getName())); + target.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.Request2", pluginRef.getConfigManager().getConfigParty().getPTP().getPtpRequestTimeout())); } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java index 34c261349..8191e9e11 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpToggleCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands.party.teleport; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; @@ -19,9 +18,9 @@ public class PtpToggleCommand implements CommandExecutor { PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord(); if (ptpRecord.isEnabled()) { - sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.Disabled")); } else { - sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.ptp.Enabled")); } ptpRecord.toggleEnabled(); diff --git a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java index fc312666f..0ab6c1aeb 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.player; 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.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.commands.CommandUtils; @@ -20,6 +19,13 @@ import java.util.ArrayList; import java.util.List; public class InspectCommand implements TabExecutor { + + private mcMMO pluginRef; + + public InspectCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { @@ -29,35 +35,35 @@ public class InspectCommand implements TabExecutor { // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. if (mcMMOPlayer == null) { - PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile + PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile if (!CommandUtils.isLoaded(sender, profile)) { return true; } - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player - && mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isUseThisBoard()) { + if (pluginRef.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player + && pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isUseThisBoard()) { ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile); - if (!mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isPrintToChat()) { + if (!pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isPrintToChat()) { return true; } } - sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.OfflineStats", playerName)); - sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Gathering")); for (PrimarySkillType skill : PrimarySkillType.GATHERING_SKILLS) { sender.sendMessage(CommandUtils.displaySkill(profile, skill)); } - sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Combat")); for (PrimarySkillType skill : PrimarySkillType.COMBAT_SKILLS) { sender.sendMessage(CommandUtils.displaySkill(profile, skill)); } - sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Misc")); for (PrimarySkillType skill : PrimarySkillType.MISC_SKILLS) { sender.sendMessage(CommandUtils.displaySkill(profile, skill)); } @@ -66,26 +72,26 @@ public class InspectCommand implements TabExecutor { Player target = mcMMOPlayer.getPlayer(); if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) { - sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Offline")); return true; } else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) { return true; } - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player && mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isUseThisBoard()) { + if (pluginRef.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player && pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isUseThisBoard()) { ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile()); - if (!mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isPrintToChat()) { + if (!pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isPrintToChat()) { return true; } } - sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName())); + sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Stats", target.getName())); CommandUtils.printGatheringSkills(target, sender); CommandUtils.printCombatSkills(target, sender); CommandUtils.printMiscSkills(target, sender); - sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); } return true; diff --git a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java index eea7ff30f..fb46ea38b 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java @@ -2,7 +2,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.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; @@ -16,6 +15,13 @@ import org.bukkit.entity.Player; import java.util.List; public class MccooldownCommand implements TabExecutor { + + private mcMMO pluginRef; + + public MccooldownCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { @@ -30,23 +36,23 @@ public class MccooldownCommand implements TabExecutor { case 0: Player player = (Player) sender; - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && mcMMO.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.COOLDOWNS_BOARD)) { + if (pluginRef.getScoreboardSettings().getScoreboardsEnabled() && pluginRef.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.COOLDOWNS_BOARD)) { ScoreboardManager.enablePlayerCooldownScoreboard(player); - if (!mcMMO.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.COOLDOWNS_BOARD)) { + if (!pluginRef.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.COOLDOWNS_BOARD)) { return true; } } if (UserManager.getPlayer(player) == null) { - player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + player.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header")); - player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Cooldowns.Header")); + player.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoSkillNote")); for (SuperAbilityType ability : SuperAbilityType.values()) { if (!ability.getPermissions(player)) { @@ -56,9 +62,9 @@ public class MccooldownCommand implements TabExecutor { int seconds = mcMMOPlayer.calculateTimeRemaining(ability); if (seconds <= 0) { - player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName())); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Cooldowns.Row.Y", ability.getName())); } else { - player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds)); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Cooldowns.Row.N", ability.getName(), seconds)); } } diff --git a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java index b1cad04b7..05b0f5f25 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.player; import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask; import com.gmail.nossr50.util.Permissions; @@ -21,6 +20,13 @@ import java.util.ArrayList; import java.util.List; public class McrankCommand implements TabExecutor { + + private mcMMO pluginRef; + + public McrankCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { @@ -89,32 +95,32 @@ public class McrankCommand implements TabExecutor { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName()); if (mcMMOPlayer == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return; } long cooldownMillis = 5000; if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) { - sender.sendMessage(LocaleLoader.getString("Commands.Database.CooldownMS", getCDSeconds(mcMMOPlayer, cooldownMillis))); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Database.CooldownMS", getCDSeconds(mcMMOPlayer, cooldownMillis))); return; } if (((Player) sender).hasMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY)) { - sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Database.Processing")); return; } else { - ((Player) sender).setMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(mcMMO.p, null)); + ((Player) sender).setMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(pluginRef, null)); } mcMMOPlayer.actualizeDatabaseATS(); } - boolean useBoard = mcMMO.getScoreboardSettings().getScoreboardsEnabled() && (sender instanceof Player) - && (mcMMO.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.RANK_BOARD)); - boolean useChat = !useBoard || mcMMO.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.RANK_BOARD); + 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); - new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); + new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(pluginRef); } private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) { diff --git a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java index c5d3895ad..d811fc05f 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.player; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; @@ -14,6 +13,13 @@ import org.bukkit.entity.Player; import java.util.List; public class McstatsCommand implements TabExecutor { + + private mcMMO pluginRef; + + public McstatsCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { @@ -27,33 +33,33 @@ public class McstatsCommand implements TabExecutor { switch (args.length) { case 0: if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } Player player = (Player) sender; - if (mcMMO.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.STATS_BOARD) && mcMMO.getScoreboardSettings().getScoreboardsEnabled()) { + if (pluginRef.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.STATS_BOARD) && pluginRef.getScoreboardSettings().getScoreboardsEnabled()) { ScoreboardManager.enablePlayerStatsScoreboard(player); - if (!mcMMO.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.STATS_BOARD)) { + if (!pluginRef.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.STATS_BOARD)) { return true; } } - player.sendMessage(LocaleLoader.getString("Stats.Own.Stats")); - player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); + player.sendMessage(pluginRef.getLocaleManager().getString("Stats.Own.Stats")); + player.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoSkillNote")); CommandUtils.printGatheringSkills(player); CommandUtils.printCombatSkills(player); CommandUtils.printMiscSkills(player); - int powerLevelCap = mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().getLevelCap(); + int powerLevelCap = pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().getLevelCap(); - if (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().isLevelCapEnabled()) { - player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap)); + if (pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().isLevelCapEnabled()) { + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap)); } else { - player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel())); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel())); } return true; diff --git a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java index 18f43f377..440f4f151 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.player; import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask; import com.gmail.nossr50.util.Permissions; @@ -23,6 +22,13 @@ import java.util.ArrayList; import java.util.List; public class MctopCommand implements TabExecutor { + + private mcMMO pluginRef; + + public MctopCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { PrimarySkillType skill = null; @@ -96,15 +102,15 @@ public class MctopCommand implements TabExecutor { seconds = 1; } - sender.sendMessage(LocaleLoader.formatString(LocaleLoader.getString("Commands.Database.Cooldown"), seconds)); + sender.sendMessage(pluginRef.getLocaleManager().formatString(pluginRef.getLocaleManager().getString("Commands.Database.Cooldown"), seconds)); return; } if (((Player) sender).hasMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY)) { - sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Database.Processing")); return; } else { - ((Player) sender).setMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(mcMMO.p, null)); + ((Player) sender).setMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, new FixedMetadataValue(pluginRef, null)); } mcMMOPlayer.actualizeDatabaseATS(); @@ -114,10 +120,10 @@ public class MctopCommand implements TabExecutor { } private void display(int page, PrimarySkillType skill, CommandSender sender) { - boolean useBoard = (sender instanceof Player) && (mcMMO.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.TOP_BOARD)); - boolean useChat = !useBoard || mcMMO.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.TOP_BOARD); + boolean useBoard = (sender instanceof Player) && (pluginRef.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.TOP_BOARD)); + boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.TOP_BOARD); - new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); + new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(pluginRef); } private PrimarySkillType extractSkill(CommandSender sender, String skillName) { diff --git a/src/main/java/com/gmail/nossr50/commands/server/Mcmmoupgrade.java b/src/main/java/com/gmail/nossr50/commands/server/Mcmmoupgrade.java deleted file mode 100644 index 8fe4ef496..000000000 --- a/src/main/java/com/gmail/nossr50/commands/server/Mcmmoupgrade.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.gmail.nossr50.commands.server; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -/** - * This command facilitates switching the skill system scale between classic and modern scale - */ -public class Mcmmoupgrade implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - return false; - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/server/ReloadCommand.java b/src/main/java/com/gmail/nossr50/commands/server/ReloadCommand.java index 3956c9554..7d14628dd 100644 --- a/src/main/java/com/gmail/nossr50/commands/server/ReloadCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/server/ReloadCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.server; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import org.bukkit.Bukkit; @@ -12,10 +11,10 @@ import org.jetbrains.annotations.NotNull; public class ReloadCommand implements CommandExecutor { - private mcMMO plugin; + private mcMMO pluginRef; public ReloadCommand(mcMMO plugin) { - this.plugin = plugin; + this.pluginRef = plugin; } @Override @@ -25,9 +24,9 @@ public class ReloadCommand implements CommandExecutor { return false; } - Bukkit.broadcastMessage(LocaleLoader.getString("Commands.Reload.Start")); - plugin.reload(); - Bukkit.broadcastMessage(LocaleLoader.getString("Commands.Reload.Finished")); + Bukkit.broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Reload.Start")); + pluginRef.reload(); + Bukkit.broadcastMessage(pluginRef.getLocaleManager().getString("Commands.Reload.Finished")); return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java index c75e01532..a788d73df 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AcrobaticsCommand.java @@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.listeners.InteractionManager; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.random.RandomChanceUtil; @@ -21,8 +21,8 @@ public class AcrobaticsCommand extends SkillCommand { private boolean canDodge; private boolean canRoll; - public AcrobaticsCommand() { - super(PrimarySkillType.ACROBATICS); + public AcrobaticsCommand(mcMMO pluginRef) { + super(PrimarySkillType.ACROBATICS, pluginRef); } @Override @@ -47,7 +47,7 @@ public class AcrobaticsCommand extends SkillCommand { if (canDodge) { messages.add(getStatMessage(SubSkillType.ACROBATICS_DODGE, dodgeChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dodgeChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", dodgeChanceLucky) : "")); } if (canRoll) { @@ -76,10 +76,10 @@ public class AcrobaticsCommand extends SkillCommand { double graceChanceLucky = graceChance * 1.333D; messages.add(getStatMessage(SubSkillType.ACROBATICS_ROLL, rollStrings[0]) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollStrings[1]) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", rollStrings[1]) : "")); /*messages.add(getStatMessage(true, false, SubSkillType.ACROBATICS_ROLL, String.valueOf(graceChance)) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", String.valueOf(graceChanceLucky)) : ""));*/ + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", String.valueOf(graceChanceLucky)) : ""));*/ } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java index e483392e8..f7f9cd105 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java @@ -26,7 +26,7 @@ //// protected String[] calculateAbilityDisplayValues(Player player) { //// //TODO: Needed? //// if (UserManager.getPlayer(player) == null) { -//// player.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); +//// player.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); //// return new String[]{"DATA NOT LOADED", "DATA NOT LOADED"}; //// } //// @@ -71,15 +71,15 @@ // //// if (canCatalysis) { //// messages.add(getStatMessage(SubSkillType.ALCHEMY_CATALYSIS, brewSpeed) -//// + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", brewSpeedLucky) : "")); +//// + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", brewSpeedLucky) : "")); //// } //// //// if (canConcoctions) { //// messages.add(getStatMessage(false, true, SubSkillType.ALCHEMY_CONCOCTIONS, String.valueOf(tier), String.valueOf(RankUtils.getHighestRank(SubSkillType.ALCHEMY_CONCOCTIONS)))); //// messages.add(getStatMessage(true, true, SubSkillType.ALCHEMY_CONCOCTIONS, String.valueOf(ingredientCount), ingredientList)); //// -//// //messages.add(LocaleLoader.getString("Alchemy.Concoctions.Rank", tier, RankUtils.getHighestRank(SubSkillType.ALCHEMY_CONCOCTIONS))); -//// //messages.add(LocaleLoader.getString("Alchemy.Concoctions.Ingredients", ingredientCount, ingredientList)); +//// //messages.add(pluginRef.getLocaleManager().getString("Alchemy.Concoctions.Rank", tier, RankUtils.getHighestRank(SubSkillType.ALCHEMY_CONCOCTIONS))); +//// //messages.add(pluginRef.getLocaleManager().getString("Alchemy.Concoctions.Ingredients", ingredientCount, ingredientList)); //// } // // return messages; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java index bc5bfc1f4..923443234 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ArcheryCommand.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.CombatUtils; @@ -23,8 +23,8 @@ public class ArcheryCommand extends SkillCommand { private boolean canDaze; private boolean canRetrieve; - public ArcheryCommand() { - super(PrimarySkillType.ARCHERY); + public ArcheryCommand(mcMMO pluginRef) { + super(PrimarySkillType.ARCHERY, pluginRef); } @Override @@ -62,12 +62,12 @@ public class ArcheryCommand extends SkillCommand { if (canRetrieve) { messages.add(getStatMessage(SubSkillType.ARCHERY_ARROW_RETRIEVAL, retrieveChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", retrieveChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", retrieveChanceLucky) : "")); } if (canDaze) { messages.add(getStatMessage(SubSkillType.ARCHERY_DAZE, dazeChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dazeChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", dazeChanceLucky) : "")); } if (canSkillShot) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java index e7ae245d8..b780873fe 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/AxesCommand.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.axes.Axes; import com.gmail.nossr50.util.Permissions; @@ -30,8 +29,8 @@ public class AxesCommand extends SkillCommand { private boolean canImpact; private boolean canGreaterImpact; - public AxesCommand() { - super(PrimarySkillType.AXES); + public AxesCommand(mcMMO pluginRef) { + super(PrimarySkillType.AXES, pluginRef); } @Override @@ -75,25 +74,25 @@ public class AxesCommand extends SkillCommand { List messages = new ArrayList<>(); if (canImpact) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage))); + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Axes.Ability.Bonus.2"), pluginRef.getLocaleManager().getString("Axes.Ability.Bonus.3", impactDamage))); } if (canAxeMastery) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", axeMasteryDamage))); + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Axes.Ability.Bonus.0"), pluginRef.getLocaleManager().getString("Axes.Ability.Bonus.1", axeMasteryDamage))); } if (canCritical) { messages.add(getStatMessage(SubSkillType.AXES_CRITICAL_STRIKES, critChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", critChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", critChanceLucky) : "")); } if (canGreaterImpact) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", mcMMO.getConfigManager().getConfigAxes().getGreaterImpactBonusDamage()))); + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Axes.Ability.Bonus.4"), pluginRef.getLocaleManager().getString("Axes.Ability.Bonus.5", pluginRef.getConfigManager().getConfigAxes().getGreaterImpactBonusDamage()))); } if (canSkullSplitter) { messages.add(getStatMessage(SubSkillType.AXES_SKULL_SPLITTER, skullSplitterLength) - + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : "")); + + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : "")); } if (canUseSubskill(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java index a7141da77..67e7aa1a3 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/ExcavationCommand.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.excavation.ExcavationManager; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; @@ -21,8 +21,8 @@ public class ExcavationCommand extends SkillCommand { private boolean canGigaDrill; private boolean canTreasureHunt; - public ExcavationCommand() { - super(PrimarySkillType.EXCAVATION); + public ExcavationCommand(mcMMO pluginRef) { + super(PrimarySkillType.EXCAVATION, pluginRef); } @Override @@ -49,9 +49,9 @@ public class ExcavationCommand extends SkillCommand { if (canGigaDrill) { messages.add(getStatMessage(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, gigaDrillBreakerLength) - + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : "")); + + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : "")); - //messages.add(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : "")); + //messages.add(pluginRef.getLocaleManager().getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : "")); } if(canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY)) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java index 26a266d13..ca7b37261 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/FishingCommand.java @@ -5,7 +5,7 @@ import com.gmail.nossr50.config.treasure.FishingTreasureConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.treasure.Rarity; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.util.Permissions; @@ -46,8 +46,8 @@ public class FishingCommand extends SkillCommand { private boolean canIceFish; private boolean canInnerPeace; - public FishingCommand() { - super(PrimarySkillType.FISHING); + public FishingCommand(mcMMO pluginRef) { + super(PrimarySkillType.FISHING, pluginRef); } @Override @@ -155,7 +155,7 @@ public class FishingCommand extends SkillCommand { if (canShake) { messages.add(getStatMessage(SubSkillType.FISHING_SHAKE, shakeChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", shakeChanceLucky) : "")); } if (canTreasureHunt) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java index 3866df005..dcdb34686 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/HerbalismCommand.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.RankUtils; @@ -35,8 +35,8 @@ public class HerbalismCommand extends SkillCommand { private boolean canDoubleDrop; private boolean canShroomThumb; - public HerbalismCommand() { - super(PrimarySkillType.HERBALISM); + public HerbalismCommand(mcMMO pluginRef) { + super(PrimarySkillType.HERBALISM, pluginRef); } @Override @@ -102,7 +102,7 @@ public class HerbalismCommand extends SkillCommand { if (canDoubleDrop) { messages.add(getStatMessage(SubSkillType.HERBALISM_DOUBLE_DROPS, doubleDropChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : "")); } if (canFarmersDiet) { @@ -111,15 +111,15 @@ public class HerbalismCommand extends SkillCommand { if (canGreenTerra) { messages.add(getStatMessage(SubSkillType.HERBALISM_GREEN_TERRA, greenTerraLength) - + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : "")); + + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : "")); - //messages.add(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : "")); + //messages.add(pluginRef.getLocaleManager().getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : "")); } if (canGreenThumbBlocks || canGreenThumbPlants) { messages.add(getStatMessage(SubSkillType.HERBALISM_GREEN_THUMB, greenThumbChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : "")); - //messages.add(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : "")); + //messages.add(pluginRef.getLocaleManager().getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : "")); } if (canGreenThumbPlants) { @@ -128,12 +128,12 @@ public class HerbalismCommand extends SkillCommand { if (hasHylianLuck) { messages.add(getStatMessage(SubSkillType.HERBALISM_HYLIAN_LUCK, hylianLuckChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : "")); } if (canShroomThumb) { messages.add(getStatMessage(SubSkillType.HERBALISM_SHROOM_THUMB, shroomThumbChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : "")); } return messages; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java index 9a031c0fa..2d44fe04f 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; @@ -33,8 +33,8 @@ public class MiningCommand extends SkillCommand { private boolean canBiggerBombs; private boolean canDemoExpert; - public MiningCommand() { - super(PrimarySkillType.MINING); + public MiningCommand(mcMMO pluginRef) { + super(PrimarySkillType.MINING, pluginRef); } @Override @@ -81,29 +81,29 @@ public class MiningCommand extends SkillCommand { if (canBiggerBombs) { messages.add(getStatMessage(true, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastRadiusIncrease))); - //messages.add(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease)); + //messages.add(pluginRef.getLocaleManager().getString("Mining.Blast.Radius.Increase", blastRadiusIncrease)); } if (canBlast) { - messages.add(getStatMessage(false, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastMiningRank), String.valueOf(RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING)), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops))); - //messages.add(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops))); + messages.add(getStatMessage(false, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastMiningRank), String.valueOf(RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING)), pluginRef.getLocaleManager().getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops))); + //messages.add(pluginRef.getLocaleManager().getString("Mining.Blast.Rank", blastMiningRank, RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING), pluginRef.getLocaleManager().getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops))); } if (canDemoExpert) { messages.add(getStatMessage(SubSkillType.MINING_DEMOLITIONS_EXPERTISE, blastDamageDecrease)); - //messages.add(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease)); + //messages.add(pluginRef.getLocaleManager().getString("Mining.Effect.Decrease", blastDamageDecrease)); } if (canDoubleDrop) { messages.add(getStatMessage(SubSkillType.MINING_DOUBLE_DROPS, doubleDropChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : "")); - //messages.add(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : "")); + //messages.add(pluginRef.getLocaleManager().getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : "")); } if (canSuperBreaker) { messages.add(getStatMessage(SubSkillType.MINING_SUPER_BREAKER, superBreakerLength) - + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : "")); - //messages.add(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : "")); + + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : "")); + //messages.add(pluginRef.getLocaleManager().getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : "")); } return messages; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java index f6582ab93..a5ab86a2e 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/MmoInfoCommand.java @@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.listeners.InteractionManager; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; import com.google.common.collect.ImmutableList; @@ -22,6 +22,12 @@ import java.util.List; */ public class MmoInfoCommand implements TabExecutor { + private mcMMO pluginRef; + + public MmoInfoCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { /* @@ -37,10 +43,10 @@ public class MmoInfoCommand implements TabExecutor { return false; if (args[0].equalsIgnoreCase("???")) { - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header")); - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", "???")); - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader")); - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mystery")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.Header")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.SubSkillHeader", "???")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.DetailsHeader")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.Mystery")); return true; } else if (InteractionManager.getAbstractByName(args[0]) != null || PrimarySkillType.SUBSKILL_NAMES.contains(args[0])) { displayInfo(player, args[0]); @@ -48,7 +54,7 @@ public class MmoInfoCommand implements TabExecutor { } //Not a real skill - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.NoMatch")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.NoMatch")); return true; } } @@ -77,10 +83,10 @@ public class MmoInfoCommand implements TabExecutor { /* * Skill is only in the old system */ - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header")); - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", subSkillName)); - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader")); - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.OldSkill")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.Header")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.SubSkillHeader", subSkillName)); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.DetailsHeader")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.OldSkill")); } for (SubSkillType subSkillType : SubSkillType.values()) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index 9d5a028f4..430a66b05 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.repairables.Repairable; @@ -39,17 +38,17 @@ public class RepairCommand extends SkillCommand { // private int ironLevel; // private int stoneLevel; - public RepairCommand() { - super(PrimarySkillType.REPAIR); + public RepairCommand(mcMMO pluginRef) { + super(PrimarySkillType.REPAIR, pluginRef); } @Override protected void dataCalculations(Player player, double skillValue) { // We're using pickaxes here, not the best but it works - Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE); - Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLDEN_PICKAXE); - Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE); - Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE); + Repairable diamondRepairable = pluginRef.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE); + Repairable goldRepairable = pluginRef.getRepairableManager().getRepairable(Material.GOLDEN_PICKAXE); + Repairable ironRepairable = pluginRef.getRepairableManager().getRepairable(Material.IRON_PICKAXE); + Repairable stoneRepairable = pluginRef.getRepairableManager().getRepairable(Material.STONE_PICKAXE); // TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0 // diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel(); @@ -59,8 +58,8 @@ public class RepairCommand extends SkillCommand { // REPAIR MASTERY if (canMasterRepair) { - double maxBonus = mcMMO.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonus(SubSkillType.REPAIR_REPAIR_MASTERY); - int maxBonusLevel = mcMMO.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY); + double maxBonus = pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonus(SubSkillType.REPAIR_REPAIR_MASTERY); + int maxBonusLevel = pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY); repairMasteryBonus = percent.format(Math.min(((maxBonus / maxBonusLevel) * skillValue), maxBonus) / 100D); } @@ -100,7 +99,7 @@ public class RepairCommand extends SkillCommand { String.valueOf(RankUtils.getRank(player, SubSkillType.REPAIR_ARCANE_FORGING)), RankUtils.getHighestRankStr(SubSkillType.REPAIR_ARCANE_FORGING))); - if (mcMMO.getConfigManager().getConfigRepair().getArcaneForging().isDowngradesEnabled() || mcMMO.getConfigManager().getConfigRepair().getArcaneForging().isMayLoseEnchants()) { + if (pluginRef.getConfigManager().getConfigRepair().getArcaneForging().isDowngradesEnabled() || pluginRef.getConfigManager().getConfigRepair().getArcaneForging().isMayLoseEnchants()) { messages.add(getStatMessage(true, true, SubSkillType.REPAIR_ARCANE_FORGING, String.valueOf(arcaneBypass ? 100 : repairManager.getKeepEnchantChance()), String.valueOf(arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance()))); //Jesus those parentheses @@ -113,7 +112,7 @@ public class RepairCommand extends SkillCommand { if (canSuperRepair) { messages.add(getStatMessage(SubSkillType.REPAIR_SUPER_REPAIR, superRepairChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", superRepairChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", superRepairChanceLucky) : "")); } return messages; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java index 82b6544d1..a71130657 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SalvageCommand.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; +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; @@ -18,8 +18,8 @@ public class SalvageCommand extends SkillCommand { private boolean canScrapCollector; private boolean canArcaneSalvage; - public SalvageCommand() { - super(PrimarySkillType.SALVAGE); + public SalvageCommand(mcMMO pluginRef) { + super(PrimarySkillType.SALVAGE, pluginRef); } @Override @@ -52,11 +52,11 @@ public class SalvageCommand extends SkillCommand { String.valueOf(RankUtils.getHighestRank(SubSkillType.SALVAGE_ARCANE_SALVAGE)))); if (Salvage.arcaneSalvageEnchantLoss) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Arcane.ExtractFull"), percent.format(salvageManager.getExtractFullEnchantChance() / 100))); + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Salvage.Arcane.ExtractFull"), percent.format(salvageManager.getExtractFullEnchantChance() / 100))); } if (Salvage.arcaneSalvageDowngrades) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Arcane.ExtractPartial"), percent.format(salvageManager.getExtractPartialEnchantChance() / 100))); + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Salvage.Arcane.ExtractPartial"), percent.format(salvageManager.getExtractPartialEnchantChance() / 100))); } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 635c95602..370079903 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.util.Permissions; @@ -36,8 +35,10 @@ public abstract class SkillCommand implements TabExecutor { protected DecimalFormat decimal = new DecimalFormat("##0.00"); private String skillName; private CommandExecutor skillGuideCommand; + protected mcMMO pluginRef; - public SkillCommand(PrimarySkillType skill) { + public SkillCommand(PrimarySkillType skill, mcMMO pluginRef) { + this.pluginRef = pluginRef; this.skill = skill; skillName = skill.getName(); skillGuideCommand = new SkillGuideCommand(skill); @@ -63,7 +64,7 @@ public abstract class SkillCommand implements TabExecutor { } if (UserManager.getPlayer((Player) sender) == null) { - sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Profile.PendingLoad")); return true; } @@ -77,7 +78,7 @@ public abstract class SkillCommand implements TabExecutor { double skillValue = mcMMOPlayer.getSkillLevel(skill); //Send the players a few blank lines to make finding the top of the skill command easier - if (mcMMO.getConfigManager().getConfigCommands().isSendBlankLines()) + if (pluginRef.getConfigManager().getConfigCommands().isSendBlankLines()) for (int i = 0; i < 2; i++) { player.sendMessage(""); } @@ -91,7 +92,7 @@ public abstract class SkillCommand implements TabExecutor { List subskillTextComponents = getTextComponents(player); //Subskills Header - player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", LocaleLoader.getString("Effects.SubSkills.Overhaul"))); + player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Overhaul.Header", pluginRef.getLocaleManager().getString("Effects.SubSkills.Overhaul"))); //Send JSON text components @@ -109,14 +110,14 @@ public abstract class SkillCommand implements TabExecutor { //Link Header - if (mcMMO.getConfigManager().getConfigAds().isShowWebsiteLinks()) { - player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header")); + if (pluginRef.getConfigManager().getConfigAds().isShowWebsiteLinks()) { + player.sendMessage(pluginRef.getLocaleManager().getString("Overhaul.mcMMO.Header")); TextComponentFactory.sendPlayerUrlHeader(player); } - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() - && mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes() + if (pluginRef.getScoreboardSettings().getScoreboardsEnabled() + && pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes() .getConfigSectionSkillBoard().isUseThisBoard()) { ScoreboardManager.enablePlayerSkillScoreboard(player, skill); } @@ -131,14 +132,14 @@ public abstract class SkillCommand implements TabExecutor { List statsMessages = statsDisplay(player, skillValue, hasEndurance, isLucky); if (!statsMessages.isEmpty()) { - player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", LocaleLoader.getString("Commands.Stats.Self.Overhaul"))); + player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Overhaul.Header", pluginRef.getLocaleManager().getString("Commands.Stats.Self.Overhaul"))); for (String message : statsMessages) { player.sendMessage(message); } } - player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase())); + player.sendMessage(pluginRef.getLocaleManager().getString("Guides.Available", skillName, skillName.toLowerCase())); } private void sendSkillCommandHeader(Player player, McMMOPlayer mcMMOPlayer, int skillValue) { @@ -147,7 +148,7 @@ public abstract class SkillCommand implements TabExecutor { ChatColor c2 = ChatColor.RED; - player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", skillName)); + player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Overhaul.Header", skillName)); if (!skill.isChildSkill()) { /* @@ -155,10 +156,10 @@ public abstract class SkillCommand implements TabExecutor { */ //XP GAIN METHOD - player.sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString())))); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.XPGain.Overhaul", pluginRef.getLocaleManager().getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString())))); //LEVEL - player.sendMessage(LocaleLoader.getString("Effects.Level.Overhaul", skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill))); + player.sendMessage(pluginRef.getLocaleManager().getString("Effects.Level.Overhaul", skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill))); } else { /* @@ -170,26 +171,26 @@ public abstract class SkillCommand implements TabExecutor { ArrayList parentList = new ArrayList<>(); //TODO: Add JSON here - /*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/ + /*player.sendMessage(parent.getName() + " - " + pluginRef.getLocaleManager().getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/ parentList.addAll(parents); StringBuilder parentMessage = new StringBuilder(); for (int i = 0; i < parentList.size(); i++) { if (i + 1 < parentList.size()) { - parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); + parentMessage.append(pluginRef.getLocaleManager().getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); parentMessage.append(ChatColor.GRAY + ", "); } else { - parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); + parentMessage.append(pluginRef.getLocaleManager().getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)))); } } //XP GAIN METHOD - player.sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain.Child"))); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.XPGain.Overhaul", pluginRef.getLocaleManager().getString("Commands.XPGain.Child"))); - player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, parentMessage.toString())); + player.sendMessage(pluginRef.getLocaleManager().getString("Effects.Child.Overhaul", skillValue, parentMessage.toString())); //LEVEL - //player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, skillValue)); + //player.sendMessage(pluginRef.getLocaleManager().getString("Effects.Child.Overhaul", skillValue, skillValue)); } } @@ -230,10 +231,10 @@ public abstract class SkillCommand implements TabExecutor { String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription() : subSkillType.getLocaleKeyStatExtraDescription(); if (isCustom) - return LocaleLoader.getString(templateKey, LocaleLoader.getString(statDescriptionKey, vars)); + return pluginRef.getLocaleManager().getString(templateKey, pluginRef.getLocaleManager().getString(statDescriptionKey, vars)); else { - String[] mergedList = mcMMO.getNotificationManager().addItemToFirstPositionOfArray(LocaleLoader.getString(statDescriptionKey), vars); - return LocaleLoader.getString(templateKey, mergedList); + String[] mergedList = pluginRef.getNotificationManager().addItemToFirstPositionOfArray(pluginRef.getLocaleManager().getString(statDescriptionKey), vars); + return pluginRef.getLocaleManager().getString(templateKey, mergedList); } } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java index e85846e6f..324ce9e60 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillGuideCommand.java @@ -1,7 +1,7 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -13,12 +13,14 @@ import java.util.Arrays; public class SkillGuideCommand implements CommandExecutor { private String header; private ArrayList guide; + private String invalidPage; + private mcMMO pluginRef; - private String invalidPage = LocaleLoader.getString("Guides.Page.Invalid"); - - public SkillGuideCommand(PrimarySkillType skill) { - header = LocaleLoader.getString("Guides.Header", skill.getName()); + public SkillGuideCommand(PrimarySkillType skill, mcMMO pluginRef) { + header = pluginRef.getLocaleManager().getString("Guides.Header", skill.getName()); guide = getGuide(skill); + invalidPage = pluginRef.getLocaleManager().getString("Guides.Page.Invalid"); + this.pluginRef = pluginRef; } @Override @@ -43,7 +45,7 @@ public class SkillGuideCommand implements CommandExecutor { int pageNumber = Integer.parseInt(args[1]); if (pageNumber > totalPages || pageNumber <= 0) { - sender.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Guides.Page.OutOfRange", totalPages)); return true; } @@ -88,7 +90,7 @@ public class SkillGuideCommand implements CommandExecutor { ArrayList guide = new ArrayList<>(); for (int i = 0; i < 10; i++) { - String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skill.toString()) + ".Section." + i).split("\n"); + String[] section = pluginRef.getLocaleManager().getString("Guides." + StringUtils.getCapitalized(skill.toString()) + ".Section." + i).split("\n"); if (section[0].startsWith("!")) { break; diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java index 4cafc214f..be2636a17 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SmeltingCommand.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.player.UserManager; @@ -25,8 +25,8 @@ public class SmeltingCommand extends SkillCommand { private boolean canFluxMine; private boolean canUnderstandTheArt; - public SmeltingCommand() { - super(PrimarySkillType.SMELTING); + public SmeltingCommand(mcMMO pluginRef) { + super(PrimarySkillType.SMELTING, pluginRef); } @Override @@ -65,8 +65,8 @@ public class SmeltingCommand extends SkillCommand { /*if (canFluxMine) { messages.add(getStatMessage(SubSkillType.SMELTING_FLUX_MINING, str_fluxMiningChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", str_fluxMiningChanceLucky) : "")); - //messages.add(LocaleLoader.getString("Smelting.Ability.FluxMining", str_fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", str_fluxMiningChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", str_fluxMiningChanceLucky) : "")); + //messages.add(pluginRef.getLocaleManager().getString("Smelting.Ability.FluxMining", str_fluxMiningChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", str_fluxMiningChanceLucky) : "")); }*/ if (canFuelEfficiency) { @@ -75,7 +75,7 @@ public class SmeltingCommand extends SkillCommand { if (canSecondSmelt) { messages.add(getStatMessage(SubSkillType.SMELTING_SECOND_SMELT, str_secondSmeltChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", str_secondSmeltChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", str_secondSmeltChanceLucky) : "")); } if (canUnderstandTheArt) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java index eb6f945b5..5e73f56c4 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SwordsCommand.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; @@ -28,8 +27,8 @@ public class SwordsCommand extends SkillCommand { private boolean canSerratedStrike; private boolean canBleed; - public SwordsCommand() { - super(PrimarySkillType.SWORDS); + public SwordsCommand(mcMMO pluginRef) { + super(PrimarySkillType.SWORDS, pluginRef); } @Override @@ -70,31 +69,31 @@ public class SwordsCommand extends SkillCommand { List messages = new ArrayList<>(); int ruptureTicks = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks(); - double ruptureDamagePlayer = mcMMO.getConfigManager().getConfigSwords().getRuptureDamagePlayer(); - double pveRupture = mcMMO.getConfigManager().getConfigSwords().getRuptureDamageMobs(); + double ruptureDamagePlayer = pluginRef.getConfigManager().getConfigSwords().getRuptureDamagePlayer(); + double pveRupture = pluginRef.getConfigManager().getConfigSwords().getRuptureDamageMobs(); double pvpDamageRupture = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? ruptureDamagePlayer * 1.5D : ruptureDamagePlayer; double ruptureDamageMobs = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? pveRupture * 1.5D : pveRupture; if (canCounter) { messages.add(getStatMessage(SubSkillType.SWORDS_COUNTER_ATTACK, counterChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", counterChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", counterChanceLucky) : "")); } if (canBleed) { messages.add(getStatMessage(SubSkillType.SWORDS_RUPTURE, bleedChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", bleedChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", bleedChanceLucky) : "")); messages.add(getStatMessage(true, true, SubSkillType.SWORDS_RUPTURE, String.valueOf(ruptureTicks), String.valueOf(pvpDamageRupture), String.valueOf(ruptureDamageMobs))); - messages.add(LocaleLoader.getString("Swords.Combat.Rupture.Note")); + messages.add(pluginRef.getLocaleManager().getString("Swords.Combat.Rupture.Note")); } if (canSerratedStrike) { messages.add(getStatMessage(SubSkillType.SWORDS_SERRATED_STRIKES, serratedStrikesLength) - + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : "")); + + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : "")); } if (canUseSubskill(player, SubSkillType.SWORDS_STAB)) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java index 24a074d38..6e8a9f972 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/TamingCommand.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.taming.Taming; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; @@ -27,8 +27,8 @@ public class TamingCommand extends SkillCommand { private boolean canFastFood; private boolean canHolyHound; - public TamingCommand() { - super(PrimarySkillType.TAMING); + public TamingCommand(mcMMO pluginRef) { + super(PrimarySkillType.TAMING, pluginRef); } @Override @@ -58,46 +58,46 @@ public class TamingCommand extends SkillCommand { List messages = new ArrayList<>(); if (canEnvironmentallyAware) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1"))); + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.0"), pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.1"))); } if (canFastFood) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", - LocaleLoader.getString("Taming.Ability.Bonus.8"), - LocaleLoader.getString("Taming.Ability.Bonus.9", + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", + pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.8"), + pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.9", percent.format(Taming.getInstance().getFastFoodServiceActivationChance() / 100D)))); } if (canGore) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", - LocaleLoader.getString("Taming.Combat.Chance.Gore"), - goreChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", goreChanceLucky) : "")); + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", + pluginRef.getLocaleManager().getString("Taming.Combat.Chance.Gore"), + goreChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", goreChanceLucky) : "")); } if (canHolyHound) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", - LocaleLoader.getString("Taming.Ability.Bonus.10"), - LocaleLoader.getString("Taming.Ability.Bonus.11"))); + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", + pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.10"), + pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.11"))); } if (canSharpenedClaws) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", - LocaleLoader.getString("Taming.Ability.Bonus.6"), - LocaleLoader.getString("Taming.Ability.Bonus.7", + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", + pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.6"), + pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.7", Taming.getInstance().getSharpenedClawsBonusDamage()))); } if (canShockProof) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", - LocaleLoader.getString("Taming.Ability.Bonus.4"), - LocaleLoader.getString("Taming.Ability.Bonus.5", + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", + pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.4"), + pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.5", Taming.getInstance().getShockProofModifier()))); } if (canThickFur) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", - LocaleLoader.getString("Taming.Ability.Bonus.2"), - LocaleLoader.getString("Taming.Ability.Bonus.3", + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", + pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.2"), + pluginRef.getLocaleManager().getString("Taming.Ability.Bonus.3", Taming.getInstance().getThickFurModifier()))); } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java index 296a9594e..5f4fb4f11 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/UnarmedCommand.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.player.UserManager; @@ -31,8 +31,8 @@ public class UnarmedCommand extends SkillCommand { private boolean canDeflect; private boolean canIronGrip; - public UnarmedCommand() { - super(PrimarySkillType.UNARMED); + public UnarmedCommand(mcMMO pluginRef) { + super(PrimarySkillType.UNARMED, pluginRef); } @Override @@ -87,30 +87,30 @@ public class UnarmedCommand extends SkillCommand { if (canDeflect) { messages.add(getStatMessage(SubSkillType.UNARMED_ARROW_DEFLECT, deflectChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : "")); - //messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", deflectChanceLucky) : "")); + //messages.add(pluginRef.getLocaleManager().getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", deflectChanceLucky) : "")); } if (canBerserk) { messages.add(getStatMessage(SubSkillType.UNARMED_BERSERK, berserkLength) - + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : "")); - //messages.add(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : "")); + + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : "")); + //messages.add(pluginRef.getLocaleManager().getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : "")); } if (canDisarm) { messages.add(getStatMessage(SubSkillType.UNARMED_DISARM, disarmChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : "")); - //messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", disarmChanceLucky) : "")); + //messages.add(pluginRef.getLocaleManager().getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", disarmChanceLucky) : "")); } if (canIronArm) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus))); + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Unarmed.Ability.Bonus.0"), pluginRef.getLocaleManager().getString("Unarmed.Ability.Bonus.1", ironArmBonus))); } if (canIronGrip) { messages.add(getStatMessage(SubSkillType.UNARMED_IRON_GRIP, ironGripChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : "")); - //messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", ironGripChanceLucky) : "")); + //messages.add(pluginRef.getLocaleManager().getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", ironGripChanceLucky) : "")); } if (canUseSubskill(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java index ef50e3fdf..bea0da632 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java @@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.skills.RankUtils; @@ -25,8 +25,8 @@ public class WoodcuttingCommand extends SkillCommand { private boolean canBarkSurgeon; private boolean canNaturesBounty; - public WoodcuttingCommand() { - super(PrimarySkillType.WOODCUTTING); + public WoodcuttingCommand(mcMMO pluginRef) { + super(PrimarySkillType.WOODCUTTING, pluginRef); } @Override @@ -66,16 +66,16 @@ public class WoodcuttingCommand extends SkillCommand { if (canDoubleDrop) { messages.add(getStatMessage(SubSkillType.WOODCUTTING_HARVEST_LUMBER, doubleDropChance) - + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : "")); + + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : "")); } if (canLeafBlow) { - messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1"))); + messages.add(pluginRef.getLocaleManager().getString("Ability.Generic.Template", pluginRef.getLocaleManager().getString("Woodcutting.Ability.0"), pluginRef.getLocaleManager().getString("Woodcutting.Ability.1"))); } if (canTreeFell) { messages.add(getStatMessage(SubSkillType.WOODCUTTING_TREE_FELLER, treeFellerLength) - + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : "")); + + (hasEndurance ? pluginRef.getLocaleManager().getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : "")); } return messages; diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 8c2aac8a4..32847d303 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -123,7 +123,7 @@ public class AdvancedConfig extends ConfigValidated { public AdvancedConfig() { //super(mcMMO.getDataFolderPath().getAbsoluteFile(), "advanced.yml", true); - super("advanced", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, true); + super("advanced", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, true); } /** @@ -136,7 +136,7 @@ public class AdvancedConfig extends ConfigValidated { */ @Deprecated public static AdvancedConfig getInstance() { - return mcMMO.getConfigManager().getAdvancedConfig(); + return pluginRef.getConfigManager().getAdvancedConfig(); } /** diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index fcc474e65..b3d020e4f 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.config; -import com.gmail.nossr50.mcMMO; import com.google.common.io.Files; import com.google.common.reflect.TypeToken; import ninja.leaping.configurate.commented.CommentedConfigurationNode; @@ -112,7 +111,7 @@ public abstract class Config implements VersionedConfig { * Used for backing up configs with our zip library */ private void registerFileBackup() { - mcMMO.getConfigManager().registerUserFile(getUserConfigFile()); + pluginRef.getConfigManager().registerUserFile(getUserConfigFile()); } /** @@ -172,7 +171,7 @@ public abstract class Config implements VersionedConfig { * @return the File for the newly created config */ private File generateDefaultFile() { - mcMMO.p.getLogger().info("Attempting to create a default config for " + fileName); + pluginRef.getLogger().info("Attempting to create a default config for " + fileName); //Not sure if this will work properly... Path potentialFile = Paths.get(getDefaultConfigCopyRelativePath()); @@ -180,7 +179,7 @@ public abstract class Config implements VersionedConfig { = HoconConfigurationLoader.builder().setPath(potentialFile).build(); try { - mcMMO.p.getLogger().info("Config File Full Path: " + getDefaultConfigFile().getAbsolutePath()); + pluginRef.getLogger().info("Config File Full Path: " + getDefaultConfigFile().getAbsolutePath()); //Delete any existing default config if (getDefaultConfigFile().exists()) getDefaultConfigFile().delete(); @@ -194,9 +193,9 @@ public abstract class Config implements VersionedConfig { //Save to a new file generation_loader.save(defaultRootNode); - mcMMO.p.getLogger().info("Generated a default file for " + fileName); + pluginRef.getLogger().info("Generated a default file for " + fileName); } catch (IOException e) { - mcMMO.p.getLogger().severe("Error when trying to generate a default configuration file for " + getDefaultConfigCopyRelativePath()); + pluginRef.getLogger().severe("Error when trying to generate a default configuration file for " + getDefaultConfigCopyRelativePath()); e.printStackTrace(); } @@ -251,9 +250,9 @@ public abstract class Config implements VersionedConfig { /* * Gen a Default config from inside the JAR */ - mcMMO.p.getLogger().info("Preparing to copy internal resource file (in JAR) - " + FILE_RELATIVE_PATH); + pluginRef.getLogger().info("Preparing to copy internal resource file (in JAR) - " + FILE_RELATIVE_PATH); //InputStream inputStream = McmmoCore.getResource(FILE_RELATIVE_PATH); - InputStream inputStream = mcMMO.p.getResource(FILE_RELATIVE_PATH); + InputStream inputStream = pluginRef.getResource(FILE_RELATIVE_PATH); byte[] buffer = new byte[inputStream.available()]; inputStream.read(buffer); @@ -263,7 +262,7 @@ public abstract class Config implements VersionedConfig { //Wipe old default file on disk if (targetFile.exists() && deleteOld) { - mcMMO.p.getLogger().info("Updating file " + relativeOutputPath); + pluginRef.getLogger().info("Updating file " + relativeOutputPath); targetFile.delete(); //Necessary? } @@ -273,7 +272,7 @@ public abstract class Config implements VersionedConfig { } Files.write(buffer, targetFile); - mcMMO.p.getLogger().info("Created config file - " + relativeOutputPath); + pluginRef.getLogger().info("Created config file - " + relativeOutputPath); inputStream.close(); //Close the input stream @@ -322,10 +321,10 @@ public abstract class Config implements VersionedConfig { * MainConfig will have any missing nodes inserted with their default value */ public void readConfig() { - mcMMO.p.getLogger().info("Attempting to read " + FILE_RELATIVE_PATH + "."); + pluginRef.getLogger().info("Attempting to read " + FILE_RELATIVE_PATH + "."); int version = this.userRootNode.getNode("ConfigVersion").getInt(); - mcMMO.p.getLogger().info(FILE_RELATIVE_PATH + " version is " + version); + pluginRef.getLogger().info(FILE_RELATIVE_PATH + " version is " + version); //Update our config updateConfig(); @@ -335,8 +334,8 @@ public abstract class Config implements VersionedConfig { * Compares the users config file to the default and adds any missing nodes and applies any necessary updates */ private void updateConfig() { - mcMMO.p.getLogger().info(defaultRootNode.getChildrenMap().size() + " items in default children map"); - mcMMO.p.getLogger().info(userRootNode.getChildrenMap().size() + " items in default root map"); + pluginRef.getLogger().info(defaultRootNode.getChildrenMap().size() + " items in default children map"); + pluginRef.getLogger().info(userRootNode.getChildrenMap().size() + " items in default root map"); // Merge Values from default if (mergeNewKeys) @@ -374,7 +373,7 @@ public abstract class Config implements VersionedConfig { * @throws IOException */ private void saveUserCopy() throws IOException { - mcMMO.p.getLogger().info("Saving new node"); + pluginRef.getLogger().info("Saving new node"); userCopyLoader.save(userRootNode); } @@ -384,7 +383,7 @@ public abstract class Config implements VersionedConfig { private void updateConfigVersion() { // Set a version for our config this.userRootNode.getNode("ConfigVersion").setValue(getConfigVersion()); - mcMMO.p.getLogger().info("Updated config to [" + getConfigVersion() + "] - " + FILE_RELATIVE_PATH); + pluginRef.getLogger().info("Updated config to [" + getConfigVersion() + "] - " + FILE_RELATIVE_PATH); } /** diff --git a/src/main/java/com/gmail/nossr50/config/ConfigConstants.java b/src/main/java/com/gmail/nossr50/config/ConfigConstants.java index 86149b31f..94cc19919 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigConstants.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigConstants.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.config; -import com.gmail.nossr50.mcMMO; - import java.io.File; import java.util.ArrayList; @@ -48,7 +46,7 @@ public class ConfigConstants { * @return the File for the data folder used by mcMMO */ public static File getDataFolder() { - return mcMMO.p.getDataFolder(); + return pluginRef.getDataFolder(); } public static File getConfigFolder() { diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index 90beb157f..01ba84fc1 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -82,6 +82,8 @@ import java.util.Set; * Settings in configs are sometimes not platform-ready, you can find platform ready implementations in the {@link com.gmail.nossr50.core.DynamicSettingsManager DynamicSettingsManager} */ public final class ConfigManager { + private mcMMO pluginRef; + /* File array - Used for backups */ private ArrayList userFiles; @@ -150,7 +152,8 @@ public final class ConfigManager { private ArrayList configErrors; //Collect errors to whine about to server admins - public ConfigManager() { + public ConfigManager(mcMMO pluginRef) { + this.pluginRef = pluginRef; userFiles = new ArrayList<>(); } @@ -265,7 +268,7 @@ public final class ConfigManager { */ customSerializers = TypeSerializers.getDefaultSerializers().newChild(); - mcMMO.p.getLogger().info("Registering custom type serializers for Configurate..."); + pluginRef.getLogger().info("Registering custom type serializers for Configurate..."); customSerializers.registerType(new TypeToken() {}, new CustomEnumValueSerializer()); customSerializers.registerType(new TypeToken() {}, new CustomEnumValueSerializer()); customSerializers.registerType(new TypeToken() {}, new CustomEnumValueSerializer()); @@ -321,7 +324,7 @@ public final class ConfigManager { * Technically this reloads a lot of stuff, not just configs */ public void reloadConfigs() { - mcMMO.p.getLogger().info("Reloading config values..."); + pluginRef.getLogger().info("Reloading config values..."); loadConfigs(); //Load everything again } diff --git a/src/main/java/com/gmail/nossr50/config/MainConfig.java b/src/main/java/com/gmail/nossr50/config/MainConfig.java index 276aa09a2..c0af8622e 100644 --- a/src/main/java/com/gmail/nossr50/config/MainConfig.java +++ b/src/main/java/com/gmail/nossr50/config/MainConfig.java @@ -17,7 +17,7 @@ public class MainConfig extends ConfigValidated { public static final String GENERAL = "General"; public static final String RETRO_MODE = "RetroMode"; public static final String ENABLED = "Enabled"; - public static final String LOCALE = "Locale"; + public static final String LOCALE = "LocaleManager"; public static final String EN_US = "en_us"; public static final String SHOW_PROFILE_LOADED = "Show_Profile_Loaded"; public static final String DONATE_MESSAGE = "Donate_Message"; @@ -200,7 +200,7 @@ public class MainConfig extends ConfigValidated { public MainConfig() { //super(McmmoCore.getDataFolderPath().getAbsoluteFile(), "config.yml", true); - super("main", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, true); + super("main", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, true, true, true); } /** @@ -213,7 +213,7 @@ public class MainConfig extends ConfigValidated { */ @Deprecated public static MainConfig getInstance() { - return mcMMO.getConfigManager().getMainConfig(); + return pluginRef.getConfigManager().getMainConfig(); } /** diff --git a/src/main/java/com/gmail/nossr50/config/UnsafeValueValidation.java b/src/main/java/com/gmail/nossr50/config/UnsafeValueValidation.java index 175a19834..9a5e569b9 100644 --- a/src/main/java/com/gmail/nossr50/config/UnsafeValueValidation.java +++ b/src/main/java/com/gmail/nossr50/config/UnsafeValueValidation.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.config; -import com.gmail.nossr50.mcMMO; - import java.util.List; /** @@ -22,7 +20,7 @@ public interface UnsafeValueValidation { if (validKeyErrors != null && validKeyErrors.size() > 0) { for (String error : validKeyErrors) { - mcMMO.p.getLogger().severe(error); + pluginRef.getLogger().severe(error); } } } diff --git a/src/main/java/com/gmail/nossr50/config/WorldBlacklist.java b/src/main/java/com/gmail/nossr50/config/WorldBlacklist.java index 48a6ab780..8566d3525 100644 --- a/src/main/java/com/gmail/nossr50/config/WorldBlacklist.java +++ b/src/main/java/com/gmail/nossr50/config/WorldBlacklist.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.config; -import com.gmail.nossr50.mcMMO; import org.bukkit.World; /** @@ -10,7 +9,7 @@ import org.bukkit.World; public class WorldBlacklist { public static boolean isWorldBlacklisted(World world) { - for (String s : mcMMO.getConfigManager().getConfigWorldBlacklist().getBlackListedWorlds()) { + for (String s : pluginRef.getConfigManager().getConfigWorldBlacklist().getBlackListedWorlds()) { if (world.getName().equalsIgnoreCase(s)) return true; } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/SerializedConfigLoader.java b/src/main/java/com/gmail/nossr50/config/hocon/SerializedConfigLoader.java index 4f82fa1bc..fb6c9cb6c 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/SerializedConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/SerializedConfigLoader.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.config.hocon; import com.gmail.nossr50.config.ConfigConstants; -import com.gmail.nossr50.mcMMO; import ninja.leaping.configurate.ConfigurationOptions; import ninja.leaping.configurate.ValueType; import ninja.leaping.configurate.commented.CommentedConfigurationNode; @@ -92,7 +91,7 @@ public class SerializedConfigLoader { Files.createFile(path); } - configurationOptions = ConfigurationOptions.defaults().setSerializers(mcMMO.getConfigManager().getCustomSerializers()).setHeader(CONFIG_HEADER); + configurationOptions = ConfigurationOptions.defaults().setSerializers(pluginRef.getConfigManager().getCustomSerializers()).setHeader(CONFIG_HEADER); data = SimpleCommentedConfigurationNode.root(configurationOptions); fileData = SimpleCommentedConfigurationNode.root(configurationOptions); @@ -114,7 +113,7 @@ public class SerializedConfigLoader { reload(); save(); } catch (Exception e) { - mcMMO.p.getLogger().severe("Failed to initialize config - " + path.toString()); + pluginRef.getLogger().severe("Failed to initialize config - " + path.toString()); e.printStackTrace(); } } @@ -146,7 +145,7 @@ public class SerializedConfigLoader { this.loader.save(saveNode); return true; } catch (IOException | ObjectMappingException e) { - mcMMO.p.getLogger().severe("Failed to save configuration - " + path.toString()); + pluginRef.getLogger().severe("Failed to save configuration - " + path.toString()); e.printStackTrace(); return false; } @@ -172,7 +171,7 @@ public class SerializedConfigLoader { // populate the config object populateInstance(); } catch (Exception e) { - mcMMO.p.getLogger().severe("Failed to load configuration - " + path.toString()); + pluginRef.getLogger().severe("Failed to load configuration - " + path.toString()); e.printStackTrace(); } } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceBars.java b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceBars.java index 8d84eb806..a7bd7580c 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceBars.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceBars.java @@ -78,7 +78,7 @@ public class ConfigExperienceBars { @Setting(value = "Extra-Details", comment = "Adds extra details to the XP bar, these cause a bit more performance overhead and may not look very pretty" + "\nYou can customize the more detailed XP bar in the locale" + - "\nLocale key - XPBar.Complex.Template" + + "\nLocaleManager key - XPBar.Complex.Template" + "\nThe default extra detailed XP bar will include quite a few extra things, you can actually remove each thing you don't want displayed in the locale" + "\nFor tips on editing the locale check - https://mcmmo.org/wiki/Locale" + "\nDefault value: " + DETAILED_XP_BARS_DEFAULT) diff --git a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java index b2bfd0316..3f895cfe2 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.config.hocon.playerleveling; import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.mcMMO; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; import org.bukkit.boss.BarColor; @@ -247,7 +246,7 @@ public class ConfigLeveling { case SALVAGE: return configSectionLevelCaps.getConfigSectionSkillLevelCaps().getSalvage().getLevelCap(); default: - mcMMO.p.getLogger().severe("No defined level cap for " + primarySkillType.toString() + " - Contact the mcMMO dev team!"); + pluginRef.getLogger().severe("No defined level cap for " + primarySkillType.toString() + " - Contact the mcMMO dev team!"); return Integer.MAX_VALUE; } } @@ -285,7 +284,7 @@ public class ConfigLeveling { case SALVAGE: return configSectionLevelCaps.getConfigSectionSkillLevelCaps().getSalvage().isLevelCapEnabled(); default: - mcMMO.p.getLogger().severe("No defined level cap for " + primarySkillType.toString() + " - Contact the mcMMO dev team!"); + pluginRef.getLogger().severe("No defined level cap for " + primarySkillType.toString() + " - Contact the mcMMO dev team!"); return false; } } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/serializers/ItemStackSerializer.java b/src/main/java/com/gmail/nossr50/config/hocon/serializers/ItemStackSerializer.java index 58d91f1b1..fce3f6845 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/serializers/ItemStackSerializer.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/serializers/ItemStackSerializer.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.config.hocon.serializers; import com.gmail.nossr50.datatypes.items.BukkitMMOItem; import com.gmail.nossr50.datatypes.items.MMOItem; -import com.gmail.nossr50.mcMMO; import com.google.common.reflect.TypeToken; import ninja.leaping.configurate.ConfigurationNode; import ninja.leaping.configurate.ValueType; @@ -25,7 +24,7 @@ public class ItemStackSerializer implements TypeSerializer> { Material itemMatch = Material.matchMaterial(itemIdentifier); if(itemMatch == null) { - mcMMO.p.getLogger().info("Could not find a match for "+itemIdentifier); + pluginRef.getLogger().info("Could not find a match for "+itemIdentifier); return null; } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/serializers/SkillRankPropertySerializer.java b/src/main/java/com/gmail/nossr50/config/hocon/serializers/SkillRankPropertySerializer.java index 911981e90..53c170f7e 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/serializers/SkillRankPropertySerializer.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/serializers/SkillRankPropertySerializer.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.config.hocon.serializers; import com.gmail.nossr50.config.hocon.skills.ranks.SkillRankProperty; -import com.gmail.nossr50.mcMMO; import com.google.common.reflect.TypeToken; import ninja.leaping.configurate.ConfigurationNode; import ninja.leaping.configurate.objectmapping.ObjectMappingException; @@ -31,7 +30,7 @@ public class SkillRankPropertySerializer implements TypeSerializer(retroMap); } catch (ObjectMappingException e) { - mcMMO.p.getLogger().severe("Unable to deserialize rank property information from the config, make sure the ranks are correctly set in the config. You can delete the rank config to generate a new one if problems persist."); + pluginRef.getLogger().severe("Unable to deserialize rank property information from the config, make sure the ranks are correctly set in the config. You can delete the rank config to generate a new one if problems persist."); throw e; } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSuperAbilities.java b/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSuperAbilities.java index a3392d869..b6d99db71 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSuperAbilities.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/superabilities/ConfigSuperAbilities.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.config.hocon.superabilities; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; -import com.gmail.nossr50.mcMMO; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @@ -78,7 +77,7 @@ public class ConfigSuperAbilities { case GIGA_DRILL_BREAKER: return superAbilityCooldowns.getGigaDrillBreaker(); default: - mcMMO.p.getLogger().severe("Cooldown Parameter not found for " + superAbilityType.toString()); + pluginRef.getLogger().severe("Cooldown Parameter not found for " + superAbilityType.toString()); return 240; } } @@ -100,7 +99,7 @@ public class ConfigSuperAbilities { case GIGA_DRILL_BREAKER: return superAbilityMaxLength.getGigaDrillBreaker(); default: - mcMMO.p.getLogger().severe("Max Length Parameter not found for " + superAbilityType.toString()); + pluginRef.getLogger().severe("Max Length Parameter not found for " + superAbilityType.toString()); return 60; } } diff --git a/src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java index 562ca7089..d0feca459 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/ExcavationTreasureConfig.java @@ -20,7 +20,7 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid public HashMap> excavationMap = new HashMap<>(); public ExcavationTreasureConfig() { - super("excavation_drops", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false); + super("excavation_drops", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false); } /** @@ -33,7 +33,7 @@ public class ExcavationTreasureConfig extends Config implements UnsafeValueValid */ @Deprecated public static ExcavationTreasureConfig getInstance() { - return mcMMO.getConfigManager().getExcavationTreasureConfig(); + return pluginRef.getConfigManager().getExcavationTreasureConfig(); } @Override diff --git a/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java index 7c03dfae8..2dbe26418 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/FishingTreasureConfig.java @@ -44,7 +44,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati public HashMap> fishingEnchantments = new HashMap<>(); public FishingTreasureConfig() { - super("fishing_drops", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false); + super("fishing_drops", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false); } /** @@ -57,7 +57,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati */ @Deprecated public static FishingTreasureConfig getInstance() { - return mcMMO.getConfigManager().getFishingTreasureConfig(); + return pluginRef.getConfigManager().getFishingTreasureConfig(); } private void loadShake(EntityType entityType) { @@ -95,34 +95,34 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati //VALIDATE AMOUNT if (amount <= 0) { - mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has an amount of 0 or below, is this intentional?"); - mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); + pluginRef.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has an amount of 0 or below, is this intentional?"); + pluginRef.getLogger().severe("Skipping " + treasureName + " for being invalid"); continue; } //VALIDATE XP if (xp <= 0) { - mcMMO.p.getLogger().info("Excavation Treasure named " + treasureName + " in the config has xp set to 0 or below, is this intentional?"); + pluginRef.getLogger().info("Excavation Treasure named " + treasureName + " in the config has xp set to 0 or below, is this intentional?"); xp = 0; } //VALIDATE DROP CHANCE if (dropChance <= 0) { - mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has a drop chance of 0 or below, is this intentional?"); - mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); + pluginRef.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has a drop chance of 0 or below, is this intentional?"); + pluginRef.getLogger().severe("Skipping " + treasureName + " for being invalid"); continue; } //VALIDATE DROP LEVEL if (dropLevel < 0) { - mcMMO.p.getLogger().info("Excavation Treasure named " + treasureName + " in the config has a drop level below 0, is this intentional?"); + pluginRef.getLogger().info("Excavation Treasure named " + treasureName + " in the config has a drop level below 0, is this intentional?"); dropLevel = 0; } //VALIDATE DROP SOURCES if (dropsFrom == null || dropsFrom.isEmpty()) { - mcMMO.p.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has no drop targets, which would make it impossible to obtain, is this intentional?"); - mcMMO.p.getLogger().severe("Skipping " + treasureName + " for being invalid"); + pluginRef.getLogger().severe("Excavation Treasure named " + treasureName + " in the config has no drop targets, which would make it impossible to obtain, is this intentional?"); + pluginRef.getLogger().severe("Skipping " + treasureName + " for being invalid"); continue; } @@ -148,7 +148,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati shakeMap.get(entityType).add(shakeTreasure); } else { - mcMMO.p.getLogger().severe("Excavation Treasure Config - Material named " + treasureName + " does not match any known material."); + pluginRef.getLogger().severe("Excavation Treasure Config - Material named " + treasureName + " does not match any known material."); } } } catch (ObjectMappingException e) { @@ -169,7 +169,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati ConfigurationNode enchantmentSection = getUserRootNode().getNode(ENCHANTMENTS_RARITY, rarity.toString()); if (enchantmentSection == null) { - mcMMO.p.getLogger().info("No enchantment information for fishing treasures, is this intentional?"); + pluginRef.getLogger().info("No enchantment information for fishing treasures, is this intentional?"); return; } @@ -180,7 +180,7 @@ public class FishingTreasureConfig extends Config implements UnsafeValueValidati Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName); if (enchantment == null) { - mcMMO.p.getLogger().severe("Skipping invalid enchantment in treasures.yml: " + enchantmentName); + pluginRef.getLogger().severe("Skipping invalid enchantment in treasures.yml: " + enchantmentName); continue; } diff --git a/src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java index 185e2be07..6e3f8761f 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/HerbalismTreasureConfig.java @@ -22,7 +22,7 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida public HashMap> hylianMap = new HashMap<>(); public HerbalismTreasureConfig() { - super("hylian_luck_drops", mcMMO.p.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false); + super("hylian_luck_drops", pluginRef.getDataFolder().getAbsoluteFile(), ConfigConstants.RELATIVE_PATH_CONFIG_DIR, true, false, true, false); } /** @@ -35,7 +35,7 @@ public class HerbalismTreasureConfig extends Config implements UnsafeValueValida */ @Deprecated public static HerbalismTreasureConfig getInstance() { - return mcMMO.getConfigManager().getHerbalismTreasureConfig(); + return pluginRef.getConfigManager().getHerbalismTreasureConfig(); } @Override diff --git a/src/main/java/com/gmail/nossr50/core/BonusDropManager.java b/src/main/java/com/gmail/nossr50/core/BonusDropManager.java index 198a6844f..1f24a4ed4 100644 --- a/src/main/java/com/gmail/nossr50/core/BonusDropManager.java +++ b/src/main/java/com/gmail/nossr50/core/BonusDropManager.java @@ -13,8 +13,10 @@ import java.util.List; public class BonusDropManager { private HashMap bonusDropWhitelist; + private mcMMO pluginRef; - public BonusDropManager() { + public BonusDropManager(mcMMO pluginRef) { + this.pluginRef = pluginRef; bonusDropWhitelist = new HashMap<>(); //Start by setting all Materials to false to avoid null checks @@ -48,7 +50,7 @@ public class BonusDropManager { Material m = Material.matchMaterial(material); if (m == null) { //TODO: reduce to info level? - mcMMO.p.getLogger().severe("Error registering Bonus Drop -- Invalid Minecraft Name ID: " + material); + pluginRef.getLogger().severe("Error registering Bonus Drop -- Invalid Minecraft Name ID: " + material); continue; } diff --git a/src/main/java/com/gmail/nossr50/core/DynamicSettingsManager.java b/src/main/java/com/gmail/nossr50/core/DynamicSettingsManager.java index 8911b4b54..57ea5f6b9 100644 --- a/src/main/java/com/gmail/nossr50/core/DynamicSettingsManager.java +++ b/src/main/java/com/gmail/nossr50/core/DynamicSettingsManager.java @@ -24,6 +24,8 @@ import java.util.HashMap; */ public class DynamicSettingsManager { + private mcMMO pluginRef; + /* UNLOAD REGISTER */ private SkillPropertiesManager skillPropertiesManager; @@ -39,7 +41,8 @@ public class DynamicSettingsManager { private HashMap partyItemWeights; private HashMap partyFeatureUnlocks; - public DynamicSettingsManager() { + public DynamicSettingsManager(mcMMO pluginRef) { + this.pluginRef = pluginRef; /* * Managers */ @@ -54,12 +57,12 @@ public class DynamicSettingsManager { } private void initPartySettings() { - partyItemWeights = Maps.newHashMap(mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap()); //Item Share Weights - partyFeatureUnlocks = Maps.newHashMap(mcMMO.getConfigManager().getConfigParty().getPartyXP().getPartyLevel().getPartyFeatureUnlockMap()); //Party Progression + partyItemWeights = Maps.newHashMap(pluginRef.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap()); //Item Share Weights + partyFeatureUnlocks = Maps.newHashMap(pluginRef.getConfigManager().getConfigParty().getPartyXP().getPartyLevel().getPartyFeatureUnlockMap()); //Party Progression } private void initSkillPropertiesManager() { - skillPropertiesManager = new SkillPropertiesManager(); + skillPropertiesManager = new SkillPropertiesManager(pluginRef); skillPropertiesManager.fillRegisters(); } @@ -67,11 +70,11 @@ public class DynamicSettingsManager { * Misc managers */ private void initMiscManagers() { - experienceManager = new ExperienceManager(); + experienceManager = new ExperienceManager(pluginRef); //Set the global XP val - experienceManager.setGlobalXpMult(mcMMO.getConfigManager().getConfigExperience().getGlobalXPMultiplier()); + experienceManager.setGlobalXpMult(pluginRef.getConfigManager().getConfigExperience().getGlobalXPMultiplier()); experienceManager.buildBlockXPMaps(); //Block XP value maps - experienceManager.fillCombatXPMultiplierMap(mcMMO.getConfigManager().getConfigExperience().getCombatExperienceMap()); + experienceManager.fillCombatXPMultiplierMap(pluginRef.getConfigManager().getConfigExperience().getCombatExperienceMap()); // potionManager = new PotionManager(); } @@ -86,7 +89,7 @@ public class DynamicSettingsManager { salvageableManager = new SalvageableManager(getSalvageables()); // Handles registration of bonus drops - bonusDropManager = new BonusDropManager(); + bonusDropManager = new BonusDropManager(pluginRef); //Register Bonus Drops registerBonusDrops(); @@ -98,7 +101,7 @@ public class DynamicSettingsManager { * @return the currently loaded repairables */ public ArrayList getRepairables() { - return mcMMO.getConfigManager().getConfigRepair().getConfigRepairablesList(); + return pluginRef.getConfigManager().getConfigRepair().getConfigRepairablesList(); } /** @@ -107,15 +110,15 @@ public class DynamicSettingsManager { * @return the currently loaded salvageables */ public ArrayList getSalvageables() { - return mcMMO.getConfigManager().getConfigSalvage().getConfigSalvageablesList(); + return pluginRef.getConfigManager().getConfigSalvage().getConfigSalvageablesList(); } /** * Registers bonus drops from several skill configs */ public void registerBonusDrops() { - bonusDropManager.addToWhitelistByNameID(mcMMO.getConfigManager().getConfigMining().getBonusDrops()); - bonusDropManager.addToWhitelistByNameID(mcMMO.getConfigManager().getConfigHerbalism().getBonusDrops()); + bonusDropManager.addToWhitelistByNameID(pluginRef.getConfigManager().getConfigMining().getBonusDrops()); + bonusDropManager.addToWhitelistByNameID(pluginRef.getConfigManager().getConfigHerbalism().getBonusDrops()); // bonusDropManager.addToWhitelistByNameID(mcMMO.getConfigManager().getConfigWoodcutting().getBonusDrops()); } diff --git a/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java b/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java index 6e77559df..6d4e81389 100644 --- a/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java +++ b/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java @@ -16,13 +16,15 @@ import java.util.HashMap; * Hacky way to do this until I rewrite the skill system fully */ public class SkillPropertiesManager { + private mcMMO pluginRef; private HashMap maxChanceMap; private HashMap staticActivationChanceMap; private HashMap maxBonusLevelMap; private HashMap maxBonusMap; - public SkillPropertiesManager() { + public SkillPropertiesManager(mcMMO pluginRef) { + this.pluginRef = pluginRef; maxChanceMap = new HashMap<>(); maxBonusLevelMap = new HashMap<>(); maxBonusMap = new HashMap<>(); @@ -30,7 +32,7 @@ public class SkillPropertiesManager { } public void registerMaxBonusLevel(SubSkillType subSkillType, MaxBonusLevel maxBonusLevel) { - maxBonusLevelMap.put(subSkillType, mcMMO.isRetroModeEnabled() ? maxBonusLevel.getRetroScaleValue() : maxBonusLevel.getStandardScaleValue()); + maxBonusLevelMap.put(subSkillType, pluginRef.isRetroModeEnabled() ? maxBonusLevel.getRetroScaleValue() : maxBonusLevel.getStandardScaleValue()); } public void registerMaxBonus(SubSkillType subSkillType, double maxBonus) { @@ -73,7 +75,7 @@ public class SkillPropertiesManager { //The path to a subskill's properties will always be like this //Skill Config Root Node -> Sub-Skill -> Hocon-Friendly-Name (of the subskill) -> PropertyFieldName (camelCase of the interface type) for(PrimarySkillType primarySkillType : PrimarySkillType.values()) { - CommentedConfigurationNode rootNode = mcMMO.getConfigManager().getSkillConfigLoader(primarySkillType).getRootNode(); + CommentedConfigurationNode rootNode = pluginRef.getConfigManager().getSkillConfigLoader(primarySkillType).getRootNode(); //Attempt to grab node CommentedConfigurationNode subSkillCategoryNode = getNodeIfReal(rootNode, ConfigConstants.SUB_SKILL_NODE); @@ -132,7 +134,7 @@ public class SkillPropertiesManager { private void attemptRegisterMaxBonusLevel(SubSkillType subSkillType, CommentedConfigurationNode childNode) { try { - mcMMO.p.getLogger().info("Registering MaxBonusLevel for "+subSkillType.toString()); + pluginRef.getLogger().info("Registering MaxBonusLevel for "+subSkillType.toString()); MaxBonusLevel maxBonusLevel = childNode.getValue(TypeToken.of(MaxBonusLevel.class)); registerMaxBonusLevel(subSkillType, maxBonusLevel); } catch (ObjectMappingException e) { @@ -142,7 +144,7 @@ public class SkillPropertiesManager { private void attemptRegisterMaxChance(SubSkillType subSkillType, CommentedConfigurationNode childNode) { try { - mcMMO.p.getLogger().info("Registering MaxChance for "+subSkillType.toString()); + pluginRef.getLogger().info("Registering MaxChance for "+subSkillType.toString()); Double maxChance = childNode.getValue(TypeToken.of(Double.class)); registerMaxChance(subSkillType, maxChance); } catch (ObjectMappingException e) { @@ -152,7 +154,7 @@ public class SkillPropertiesManager { private void attemptRegisterStaticChance(SubSkillType subSkillType, CommentedConfigurationNode childNode) { try { - mcMMO.p.getLogger().info("Registering Static Chance for "+subSkillType.toString()); + pluginRef.getLogger().info("Registering Static Chance for "+subSkillType.toString()); Double staticChance = childNode.getValue(TypeToken.of(Double.class)); registerStaticChance(subSkillType, staticChance); } catch (ObjectMappingException e) { @@ -162,7 +164,7 @@ public class SkillPropertiesManager { private void attemptRegisterMaxBonusPercentage(SubSkillType subSkillType, CommentedConfigurationNode childNode) { try { - mcMMO.p.getLogger().info("Registering MaxBonus for "+subSkillType.toString()); + pluginRef.getLogger().info("Registering MaxBonus for "+subSkillType.toString()); Double maxChance = childNode.getValue(TypeToken.of(Double.class)); registerMaxBonus(subSkillType, maxChance); } catch (ObjectMappingException e) { diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java index 818495067..13dd4b3dc 100644 --- a/src/main/java/com/gmail/nossr50/database/DatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/DatabaseManager.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.database.DatabaseType; import com.gmail.nossr50.datatypes.database.PlayerStat; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.mcMMO; import java.util.List; import java.util.Map; @@ -12,7 +11,7 @@ import java.util.UUID; public interface DatabaseManager { // One month in milliseconds - long PURGE_TIME = 2630000000L * mcMMO.getDatabaseCleaningSettings().getOldUserCutoffMonths(); + long PURGE_TIME = 2630000000L * pluginRef.getDatabaseCleaningSettings().getOldUserCutoffMonths(); // During convertUsers, how often to output a status int progressInterval = 200; diff --git a/src/main/java/com/gmail/nossr50/database/DatabaseManagerFactory.java b/src/main/java/com/gmail/nossr50/database/DatabaseManagerFactory.java index faa98e7c3..6e76500ca 100644 --- a/src/main/java/com/gmail/nossr50/database/DatabaseManagerFactory.java +++ b/src/main/java/com/gmail/nossr50/database/DatabaseManagerFactory.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.database; import com.gmail.nossr50.datatypes.database.DatabaseType; -import com.gmail.nossr50.mcMMO; public class DatabaseManagerFactory { private static Class customManager = null; @@ -11,16 +10,16 @@ public class DatabaseManagerFactory { try { return createDefaultCustomDatabaseManager(); } catch (Exception e) { - mcMMO.p.debug("Could not create custom database manager"); + pluginRef.debug("Could not create custom database manager"); e.printStackTrace(); } catch (Throwable e) { - mcMMO.p.debug("Failed to create custom database manager"); + pluginRef.debug("Failed to create custom database manager"); e.printStackTrace(); } - mcMMO.p.debug("Falling back on " + (mcMMO.getMySQLConfigSettings().isMySQLEnabled() ? "SQL" : "Flatfile") + " database"); + pluginRef.debug("Falling back on " + (pluginRef.getMySQLConfigSettings().isMySQLEnabled() ? "SQL" : "Flatfile") + " database"); } - return mcMMO.getMySQLConfigSettings().isMySQLEnabled() ? new SQLDatabaseManager() : new FlatfileDatabaseManager(); + return pluginRef.getMySQLConfigSettings().isMySQLEnabled() ? new SQLDatabaseManager() : new FlatfileDatabaseManager(); } public static Class getCustomDatabaseManagerClass() { diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index 9e4217de4..673298634 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java @@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.UniqueDataType; 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.gmail.nossr50.util.StringUtils; import org.bukkit.OfflinePlayer; @@ -64,8 +63,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager { private long updateWaitTime; protected FlatfileDatabaseManager() { - updateWaitTime = mcMMO.getConfigManager().getConfigDatabase().getConfigDatabaseFlatFile().getLeaderboardUpdateIntervalMinutes() * (1000 * 60); - usersFile = new File(mcMMO.getUsersFilePath()); + updateWaitTime = pluginRef.getConfigManager().getConfigDatabase().getConfigDatabaseFlatFile().getLeaderboardUpdateIntervalMinutes() * (1000 * 60); + usersFile = new File(pluginRef.getUsersFilePath()); checkStructure(); updateLeaderboards(); @@ -77,11 +76,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager { public void purgePowerlessUsers() { int purgedUsers = 0; - mcMMO.p.getLogger().info("Purging powerless users..."); + pluginRef.getLogger().info("Purging powerless users..."); BufferedReader in = null; FileWriter out = null; - String usersFilePath = mcMMO.getUsersFilePath(); + String usersFilePath = pluginRef.getUsersFilePath(); // This code is O(n) instead of O(n²) synchronized (fileWritingLock) { @@ -96,7 +95,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { boolean powerless = true; for (int skill : skills.values()) { - if (skill > mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel()) { + if (skill > pluginRef.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel()) { powerless = false; break; } @@ -114,7 +113,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { out = new FileWriter(usersFilePath); out.write(writer.toString()); } catch (IOException e) { - mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); + pluginRef.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); } finally { if (in != null) { try { @@ -133,18 +132,18 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } } - mcMMO.p.getLogger().info("Purged " + purgedUsers + " users from the database."); + pluginRef.getLogger().info("Purged " + purgedUsers + " users from the database."); } public void purgeOldUsers() { int removedPlayers = 0; long currentTime = System.currentTimeMillis(); - mcMMO.p.getLogger().info("Purging old users..."); + pluginRef.getLogger().info("Purging old users..."); BufferedReader in = null; FileWriter out = null; - String usersFilePath = mcMMO.getUsersFilePath(); + String usersFilePath = pluginRef.getUsersFilePath(); // This code is O(n) instead of O(n²) synchronized (fileWritingLock) { @@ -164,7 +163,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { e.printStackTrace(); } if (lastPlayed == 0) { - OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(name); + OfflinePlayer player = pluginRef.getServer().getOfflinePlayer(name); lastPlayed = player.getLastPlayed(); rewrite = true; } @@ -187,7 +186,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { out = new FileWriter(usersFilePath); out.write(writer.toString()); } catch (IOException e) { - mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); + pluginRef.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); } finally { if (in != null) { try { @@ -206,7 +205,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } } - mcMMO.p.getLogger().info("Purged " + removedPlayers + " users from the database."); + pluginRef.getLogger().info("Purged " + removedPlayers + " users from the database."); } public boolean removeUser(String playerName, UUID uuid) { @@ -215,7 +214,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { BufferedReader in = null; FileWriter out = null; - String usersFilePath = mcMMO.getUsersFilePath(); + String usersFilePath = pluginRef.getUsersFilePath(); synchronized (fileWritingLock) { try { @@ -226,7 +225,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { while ((line = in.readLine()) != null) { // Write out the same file but when we get to the player we want to remove, we skip his line. if (!worked && line.split(":")[USERNAME].equalsIgnoreCase(playerName)) { - mcMMO.p.getLogger().info("User found, removing..."); + pluginRef.getLogger().info("User found, removing..."); worked = true; continue; // Skip the player } @@ -237,7 +236,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { out = new FileWriter(usersFilePath); // Write out the new file out.write(writer.toString()); } catch (Exception e) { - mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); + pluginRef.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); } finally { if (in != null) { try { @@ -272,7 +271,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { BufferedReader in = null; FileWriter out = null; - String usersFilePath = mcMMO.getUsersFilePath(); + String usersFilePath = pluginRef.getUsersFilePath(); synchronized (fileWritingLock) { try { @@ -368,7 +367,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { writer.append((int) profile.getAbilityDATS(SuperAbilityType.BLAST_MINING)).append(":"); writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":"); MobHealthbarType mobHealthbarType = profile.getMobHealthbarType(); - writer.append(mobHealthbarType == null ? mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString() : mobHealthbarType.toString()).append(":"); + writer.append(mobHealthbarType == null ? pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString() : mobHealthbarType.toString()).append(":"); writer.append(profile.getSkillLevel(PrimarySkillType.ALCHEMY)).append(":"); writer.append(profile.getSkillXpLevel(PrimarySkillType.ALCHEMY)).append(":"); writer.append(uuid != null ? uuid.toString() : "NULL").append(":"); @@ -404,9 +403,9 @@ public final class FlatfileDatabaseManager implements DatabaseManager { synchronized (fileWritingLock) { try { // Open the file to write the player - out = new BufferedWriter(new FileWriter(mcMMO.getUsersFilePath(), true)); + out = new BufferedWriter(new FileWriter(pluginRef.getUsersFilePath(), true)); - String startingLevel = mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel() + ":"; + String startingLevel = pluginRef.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel() + ":"; // Add the player to the end out.append(playerName).append(":"); @@ -447,7 +446,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { out.append("0:"); // FishingXp out.append("0:"); // Blast Mining out.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":"); // LastLogin - out.append(mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString()).append(":"); // Mob Healthbar HUD + out.append(pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString()).append(":"); // Mob Healthbar HUD out.append(startingLevel); // Alchemy out.append("0:"); // AlchemyXp out.append(uuid != null ? uuid.toString() : "NULL").append(":"); // UUID @@ -480,7 +479,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { public PlayerProfile loadPlayerProfile(String playerName, UUID uuid, boolean create) { BufferedReader in = null; - String usersFilePath = mcMMO.getUsersFilePath(); + String usersFilePath = pluginRef.getUsersFilePath(); synchronized (fileWritingLock) { try { @@ -506,7 +505,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { // Update playerName in database after name change if (!character[USERNAME].equalsIgnoreCase(playerName)) { - mcMMO.p.debug("Name change detected: " + character[USERNAME] + " => " + playerName); + pluginRef.debug("Name change detected: " + character[USERNAME] + " => " + playerName); character[USERNAME] = playerName; } @@ -548,7 +547,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { public void convertUsers(DatabaseManager destination) { BufferedReader in = null; - String usersFilePath = mcMMO.getUsersFilePath(); + String usersFilePath = pluginRef.getUsersFilePath(); int convertedUsers = 0; long startMillis = System.currentTimeMillis(); @@ -589,7 +588,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { int i = 0; BufferedReader in = null; FileWriter out = null; - String usersFilePath = mcMMO.getUsersFilePath(); + String usersFilePath = pluginRef.getUsersFilePath(); synchronized (fileWritingLock) { try { @@ -601,8 +600,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager { String[] character = line.split(":"); if (!worked && character[USERNAME].equalsIgnoreCase(userName)) { if (character.length < 42) { - mcMMO.p.getLogger().severe("Could not update UUID for " + userName + "!"); - mcMMO.p.getLogger().severe("Database entry is invalid."); + pluginRef.getLogger().severe("Could not update UUID for " + userName + "!"); + pluginRef.getLogger().severe("Database entry is invalid."); continue; } @@ -617,9 +616,9 @@ public final class FlatfileDatabaseManager implements DatabaseManager { out = new FileWriter(usersFilePath); // Write out the new file out.write(writer.toString()); } catch (Exception e) { - mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); + pluginRef.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); } finally { - mcMMO.p.getLogger().info(i + " entries written while saving UUID for " + userName); + pluginRef.getLogger().info(i + " entries written while saving UUID for " + userName); if (in != null) { try { in.close(); @@ -643,7 +642,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { public boolean saveUserUUIDs(Map fetchedUUIDs) { BufferedReader in = null; FileWriter out = null; - String usersFilePath = mcMMO.getUsersFilePath(); + String usersFilePath = pluginRef.getUsersFilePath(); int i = 0; synchronized (fileWritingLock) { @@ -656,8 +655,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager { String[] character = line.split(":"); if (!fetchedUUIDs.isEmpty() && fetchedUUIDs.containsKey(character[USERNAME])) { if (character.length < 42) { - mcMMO.p.getLogger().severe("Could not update UUID for " + character[USERNAME] + "!"); - mcMMO.p.getLogger().severe("Database entry is invalid."); + pluginRef.getLogger().severe("Could not update UUID for " + character[USERNAME] + "!"); + pluginRef.getLogger().severe("Database entry is invalid."); continue; } @@ -672,9 +671,9 @@ public final class FlatfileDatabaseManager implements DatabaseManager { out = new FileWriter(usersFilePath); // Write out the new file out.write(writer.toString()); } catch (Exception e) { - mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); + pluginRef.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); } finally { - mcMMO.p.getLogger().info(i + " entries written while saving UUID batch"); + pluginRef.getLogger().info(i + " entries written while saving UUID batch"); if (in != null) { try { in.close(); @@ -698,7 +697,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { public List getStoredUsers() { ArrayList users = new ArrayList<>(); BufferedReader in = null; - String usersFilePath = mcMMO.getUsersFilePath(); + String usersFilePath = pluginRef.getUsersFilePath(); synchronized (fileWritingLock) { try { @@ -734,7 +733,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { return; } - String usersFilePath = mcMMO.getUsersFilePath(); + String usersFilePath = pluginRef.getUsersFilePath(); lastUpdate = System.currentTimeMillis(); // Log when the last update was run powerLevels.clear(); // Clear old values from the power levels @@ -785,7 +784,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { putStat(powerLevels, playerName, powerLevel); } } catch (Exception e) { - mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " during user " + playerName + " (Are you sure you formatted it correctly?) " + e.toString()); + pluginRef.getLogger().severe("Exception while reading " + usersFilePath + " during user " + playerName + " (Are you sure you formatted it correctly?) " + e.toString()); } finally { if (in != null) { try { @@ -836,7 +835,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { if (usersFile.exists()) { BufferedReader in = null; FileWriter out = null; - String usersFilePath = mcMMO.getUsersFilePath(); + String usersFilePath = pluginRef.getUsersFilePath(); synchronized (fileWritingLock) { try { @@ -875,7 +874,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { if (character.length < 33) { // Before Version 1.0 - Drop - mcMMO.p.getLogger().warning("Dropping malformed or before version 1.0 line from database - " + line); + pluginRef.getLogger().warning("Dropping malformed or before version 1.0 line from database - " + line); continue; } @@ -892,17 +891,17 @@ public final class FlatfileDatabaseManager implements DatabaseManager { updated = true; } - if (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getReducePlayerSkillsAboveCap()) { + if (pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getReducePlayerSkillsAboveCap()) { for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) { int index = getSkillIndex(skill); if (index >= character.length) { continue; } //Level Cap - if (mcMMO.getPlayerLevelingSettings().isSkillLevelCapEnabled(skill)) { - int cap = mcMMO.getPlayerLevelingSettings().getSkillLevelCap(skill); + if (pluginRef.getPlayerLevelingSettings().isSkillLevelCapEnabled(skill)) { + int cap = pluginRef.getPlayerLevelingSettings().getSkillLevelCap(skill); if (Integer.valueOf(character[index]) > cap) { - mcMMO.p.getLogger().warning("Truncating " + skill.getName() + " to configured max level for player " + character[USERNAME]); + pluginRef.getLogger().warning("Truncating " + skill.getName() + " to configured max level for player " + character[USERNAME]); character[index] = cap + ""; updated = true; } @@ -962,7 +961,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { // Version 1.4.06 // commit da29185b7dc7e0d992754bba555576d48fa08aa6 character = Arrays.copyOf(character, character.length + 1); - character[character.length - 1] = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString(); + character[character.length - 1] = pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString(); if (oldVersion == null) { oldVersion = "1.4.06"; } @@ -1005,7 +1004,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { if (i == 37) { character[i] = String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); } else if (i == 38) { - character[i] = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString(); + character[i] = pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString(); } else { character[i] = "0"; } @@ -1013,7 +1012,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { if (StringUtils.isInt(character[i]) && i == 38) { corrupted = true; - character[i] = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString(); + character[i] = pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString(); } if (!StringUtils.isInt(character[i]) && !(i == 0 || i == 2 || i == 3 || i == 23 || i == 33 || i == 38 || i == 41)) { @@ -1023,17 +1022,17 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } if (corrupted) { - mcMMO.p.debug("Updating corrupted database line for player " + character[USERNAME]); + pluginRef.debug("Updating corrupted database line for player " + character[USERNAME]); } if (oldVersion != null) { - mcMMO.p.debug("Updating database line from before version " + oldVersion + " for player " + character[USERNAME]); + pluginRef.debug("Updating database line from before version " + oldVersion + " for player " + character[USERNAME]); } updated |= corrupted; updated |= oldVersion != null; - if (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getReducePlayerSkillsAboveCap()) { + if (pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getReducePlayerSkillsAboveCap()) { Map skills = getSkillMapFromLine(character); for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) { int cap = Integer.MAX_VALUE; @@ -1054,7 +1053,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { out = new FileWriter(usersFilePath); out.write(writer.toString()); } catch (IOException e) { - mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); + pluginRef.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); } finally { if (in != null) { try { @@ -1086,8 +1085,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager { usersFile.getParentFile().mkdir(); try { - mcMMO.p.debug("Creating mcmmo.users file..."); - new File(mcMMO.getUsersFilePath()).createNewFile(); + pluginRef.debug("Creating mcmmo.users file..."); + new File(pluginRef.getUsersFilePath()).createNewFile(); } catch (IOException e) { e.printStackTrace(); } @@ -1156,7 +1155,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { try { mobHealthbarType = MobHealthbarType.valueOf(character[HEALTHBAR]); } catch (Exception e) { - mobHealthbarType = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType(); + mobHealthbarType = pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType(); } UUID uuid; @@ -1246,7 +1245,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { public void resetMobHealthSettings() { BufferedReader in = null; FileWriter out = null; - String usersFilePath = mcMMO.getUsersFilePath(); + String usersFilePath = pluginRef.getUsersFilePath(); synchronized (fileWritingLock) { try { @@ -1261,7 +1260,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { } String[] character = line.split(":"); - character[HEALTHBAR] = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString(); + character[HEALTHBAR] = pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString(); line = org.apache.commons.lang.StringUtils.join(character, ":") + ":"; @@ -1272,7 +1271,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { out = new FileWriter(usersFilePath); out.write(writer.toString()); } catch (IOException e) { - mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); + pluginRef.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString()); } finally { if (in != null) { try { diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index dac762f73..3cc1a9a7f 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.UniqueDataType; 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 org.apache.tomcat.jdbc.pool.DataSource; import org.apache.tomcat.jdbc.pool.PoolProperties; @@ -22,7 +21,7 @@ public final class SQLDatabaseManager implements DatabaseManager { public static final String COM_MYSQL_JDBC_DRIVER = "com.mysql.jdbc.Driver"; private static final String ALL_QUERY_VERSION = "total"; private final Map cachedUserIDs = new HashMap<>(); - private String tablePrefix = mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getTablePrefix(); + private String tablePrefix = pluginRef.getMySQLConfigSettings().getConfigSectionDatabase().getTablePrefix(); private DataSource miscPool; private DataSource loadPool; private DataSource savePool; @@ -30,10 +29,10 @@ public final class SQLDatabaseManager implements DatabaseManager { private ReentrantLock massUpdateLock = new ReentrantLock(); protected SQLDatabaseManager() { - String connectionString = "jdbc:mysql://" + mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().getServerAddress() - + ":" + mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().getServerPort() + "/" + mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName(); + String connectionString = "jdbc:mysql://" + pluginRef.getMySQLConfigSettings().getUserConfigSectionServer().getServerAddress() + + ":" + pluginRef.getMySQLConfigSettings().getUserConfigSectionServer().getServerPort() + "/" + pluginRef.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName(); - if (mcMMO.getMySQLConfigSettings().getUserConfigSectionServer().isUseSSL()) + if (pluginRef.getMySQLConfigSettings().getUserConfigSectionServer().isUseSSL()) connectionString += "?verifyServerCertificate=false" + "&useSSL=true" + @@ -81,17 +80,17 @@ public final class SQLDatabaseManager implements DatabaseManager { poolProperties.setUrl(connectionString); //MySQL User Name - poolProperties.setUsername(mcMMO.getMySQLConfigSettings().getConfigSectionUser().getUsername()); + poolProperties.setUsername(pluginRef.getMySQLConfigSettings().getConfigSectionUser().getUsername()); //MySQL User Password - poolProperties.setPassword(mcMMO.getMySQLConfigSettings().getConfigSectionUser().getPassword()); + poolProperties.setPassword(pluginRef.getMySQLConfigSettings().getConfigSectionUser().getPassword()); //Initial Size poolProperties.setInitialSize(0); //Max Pool Size for Misc - poolProperties.setMaxIdle(mcMMO.getMySQLConfigSettings().getMaxPoolSize(poolIdentifier)); + poolProperties.setMaxIdle(pluginRef.getMySQLConfigSettings().getMaxPoolSize(poolIdentifier)); //Max Connections for Misc - poolProperties.setMaxActive(mcMMO.getMySQLConfigSettings().getMaxConnections(poolIdentifier)); + poolProperties.setMaxActive(pluginRef.getMySQLConfigSettings().getMaxConnections(poolIdentifier)); poolProperties.setMaxWait(-1); poolProperties.setRemoveAbandoned(true); @@ -105,7 +104,7 @@ public final class SQLDatabaseManager implements DatabaseManager { public void purgePowerlessUsers() { massUpdateLock.lock(); - mcMMO.p.getLogger().info("Purging powerless users..."); + pluginRef.getLogger().info("Purging powerless users..."); Connection connection = null; Statement statement = null; @@ -115,7 +114,7 @@ public final class SQLDatabaseManager implements DatabaseManager { connection = getConnection(PoolIdentifier.MISC); statement = connection.createStatement(); - String startingLevel = String.valueOf(mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel()); + String startingLevel = String.valueOf(pluginRef.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel()); //Purge users who have not leveled from the default level purged = statement.executeUpdate("DELETE FROM " + tablePrefix + "skills WHERE " @@ -144,12 +143,12 @@ public final class SQLDatabaseManager implements DatabaseManager { massUpdateLock.unlock(); } - mcMMO.p.getLogger().info("Purged " + purged + " users from the database."); + pluginRef.getLogger().info("Purged " + purged + " users from the database."); } public void purgeOldUsers() { massUpdateLock.lock(); - mcMMO.p.getLogger().info("Purging inactive users older than " + (PURGE_TIME / 2630000000L) + " months..."); + pluginRef.getLogger().info("Purging inactive users older than " + (PURGE_TIME / 2630000000L) + " months..."); Connection connection = null; Statement statement = null; @@ -173,7 +172,7 @@ public final class SQLDatabaseManager implements DatabaseManager { massUpdateLock.unlock(); } - mcMMO.p.getLogger().info("Purged " + purged + " users from the database."); + pluginRef.getLogger().info("Purged " + purged + " users from the database."); } public boolean removeUser(String playerName, UUID uuid) { @@ -229,7 +228,7 @@ public final class SQLDatabaseManager implements DatabaseManager { if (id == -1) { id = newUser(connection, profile.getPlayerName(), profile.getUniqueId()); if (id == -1) { - mcMMO.p.getLogger().severe("Failed to create new account for " + profile.getPlayerName()); + pluginRef.getLogger().severe("Failed to create new account for " + profile.getPlayerName()); return false; } } @@ -239,7 +238,7 @@ public final class SQLDatabaseManager implements DatabaseManager { success &= (statement.executeUpdate() != 0); statement.close(); if (!success) { - mcMMO.p.getLogger().severe("Failed to update last login for " + profile.getPlayerName()); + pluginRef.getLogger().severe("Failed to update last login for " + profile.getPlayerName()); return false; } @@ -269,7 +268,7 @@ public final class SQLDatabaseManager implements DatabaseManager { success &= (statement.executeUpdate() != 0); statement.close(); if (!success) { - mcMMO.p.getLogger().severe("Failed to update skills for " + profile.getPlayerName()); + pluginRef.getLogger().severe("Failed to update skills for " + profile.getPlayerName()); return false; } @@ -295,7 +294,7 @@ public final class SQLDatabaseManager implements DatabaseManager { success &= (statement.executeUpdate() != 0); statement.close(); if (!success) { - mcMMO.p.getLogger().severe("Failed to update experience for " + profile.getPlayerName()); + pluginRef.getLogger().severe("Failed to update experience for " + profile.getPlayerName()); return false; } @@ -316,18 +315,18 @@ public final class SQLDatabaseManager implements DatabaseManager { success = (statement.executeUpdate() != 0); statement.close(); if (!success) { - mcMMO.p.getLogger().severe("Failed to update cooldowns for " + profile.getPlayerName()); + pluginRef.getLogger().severe("Failed to update cooldowns for " + profile.getPlayerName()); return false; } statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ?, scoreboardtips = ? WHERE user_id = ?"); - statement.setString(1, profile.getMobHealthbarType() == null ? mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().name() : profile.getMobHealthbarType().name()); + statement.setString(1, profile.getMobHealthbarType() == null ? pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().name() : profile.getMobHealthbarType().name()); statement.setInt(2, profile.getScoreboardTipsShown()); statement.setInt(3, id); success = (statement.executeUpdate() != 0); statement.close(); if (!success) { - mcMMO.p.getLogger().severe("Failed to update hud settings for " + profile.getPlayerName()); + pluginRef.getLogger().severe("Failed to update hud settings for " + profile.getPlayerName()); return false; } } catch (SQLException ex) { @@ -503,7 +502,7 @@ public final class SQLDatabaseManager implements DatabaseManager { resultSet = statement.getGeneratedKeys(); if (!resultSet.next()) { - mcMMO.p.getLogger().severe("Unable to create new user account in DB"); + pluginRef.getLogger().severe("Unable to create new user account in DB"); return -1; } @@ -770,7 +769,7 @@ public final class SQLDatabaseManager implements DatabaseManager { + " WHERE table_schema = ?" + " AND table_name = ?"); //Database name - statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName()); + statement.setString(1, pluginRef.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName()); statement.setString(2, tablePrefix + "users"); resultSet = statement.executeQuery(); if (!resultSet.next()) { @@ -787,14 +786,14 @@ public final class SQLDatabaseManager implements DatabaseManager { } tryClose(resultSet); //Database name - statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName()); + statement.setString(1, pluginRef.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName()); statement.setString(2, tablePrefix + "huds"); resultSet = statement.executeQuery(); if (!resultSet.next()) { createStatement = connection.createStatement(); createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` (" + "`user_id` int(10) unsigned NOT NULL," - + "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType() + "'," + + "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType() + "'," + "`scoreboardtips` int(10) NOT NULL DEFAULT '0'," + "PRIMARY KEY (`user_id`)) " + "DEFAULT CHARSET=latin1;"); @@ -802,7 +801,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } tryClose(resultSet); //Database name - statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName()); + statement.setString(1, pluginRef.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName()); statement.setString(2, tablePrefix + "cooldowns"); resultSet = statement.executeQuery(); if (!resultSet.next()) { @@ -828,12 +827,12 @@ public final class SQLDatabaseManager implements DatabaseManager { } tryClose(resultSet); //Database name - statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName()); + statement.setString(1, pluginRef.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName()); statement.setString(2, tablePrefix + "skills"); resultSet = statement.executeQuery(); if (!resultSet.next()) { - String startingLevel = "'" + mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel() + "'"; - String totalLevel = "'" + (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel() * (PrimarySkillType.values().length - PrimarySkillType.CHILD_SKILLS.size())) + "'"; + String startingLevel = "'" + pluginRef.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel() + "'"; + String totalLevel = "'" + (pluginRef.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel() * (PrimarySkillType.values().length - PrimarySkillType.CHILD_SKILLS.size())) + "'"; createStatement = connection.createStatement(); createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "skills` (" + "`user_id` int(10) unsigned NOT NULL," @@ -857,7 +856,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } tryClose(resultSet); //Database name - statement.setString(1, mcMMO.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName()); + statement.setString(1, pluginRef.getMySQLConfigSettings().getConfigSectionDatabase().getDatabaseName()); statement.setString(2, tablePrefix + "experience"); resultSet = statement.executeQuery(); if (!resultSet.next()) { @@ -889,20 +888,20 @@ public final class SQLDatabaseManager implements DatabaseManager { } //Level Cap Stuff - if (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getReducePlayerSkillsAboveCap()) { + if (pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getReducePlayerSkillsAboveCap()) { for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) { - if (!mcMMO.getPlayerLevelingSettings().isSkillLevelCapEnabled(skill)) + if (!pluginRef.getPlayerLevelingSettings().isSkillLevelCapEnabled(skill)) continue; //Shrink skills above the cap - int cap = mcMMO.getPlayerLevelingSettings().getSkillLevelCap(skill); + int cap = pluginRef.getPlayerLevelingSettings().getSkillLevelCap(skill); statement = connection.prepareStatement("UPDATE `" + tablePrefix + "skills` SET `" + skill.name().toLowerCase() + "` = " + cap + " WHERE `" + skill.name().toLowerCase() + "` > " + cap); statement.executeUpdate(); tryClose(statement); } } - mcMMO.p.getLogger().info("Killing orphans"); + pluginRef.getLogger().info("Killing orphans"); createStatement = connection.createStatement(); createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "experience` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "experience`.`user_id` = `u`.`id`)"); createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "huds` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "huds`.`user_id` = `u`.`id`)"); @@ -1036,7 +1035,7 @@ public final class SQLDatabaseManager implements DatabaseManager { statement = connection.prepareStatement("INSERT IGNORE INTO " + tablePrefix + "huds (user_id, mobhealthbar, scoreboardtips) VALUES (?, ?, ?)"); statement.setInt(1, id); - statement.setString(2, mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().name()); + statement.setString(2, pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().name()); statement.setInt(3, 0); statement.execute(); statement.close(); @@ -1108,7 +1107,7 @@ public final class SQLDatabaseManager implements DatabaseManager { try { mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 1)); } catch (Exception e) { - mobHealthbarType = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType(); + mobHealthbarType = pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType(); } try { @@ -1128,10 +1127,10 @@ public final class SQLDatabaseManager implements DatabaseManager { private void printErrors(SQLException ex) { StackTraceElement element = ex.getStackTrace()[0]; - mcMMO.p.getLogger().severe("Location: " + element.getClassName() + " " + element.getMethodName() + " " + element.getLineNumber()); - mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage()); - mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState()); - mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode()); + pluginRef.getLogger().severe("Location: " + element.getClassName() + " " + element.getMethodName() + " " + element.getLineNumber()); + pluginRef.getLogger().severe("SQLException: " + ex.getMessage()); + pluginRef.getLogger().severe("SQLState: " + ex.getSQLState()); + pluginRef.getLogger().severe("VendorError: " + ex.getErrorCode()); } public DatabaseType getDatabaseType() { @@ -1149,7 +1148,7 @@ public final class SQLDatabaseManager implements DatabaseManager { return; } resultSet.close(); - mcMMO.p.getLogger().info("Updating mcMMO MySQL tables to drop name uniqueness..."); + pluginRef.getLogger().info("Updating mcMMO MySQL tables to drop name uniqueness..."); statement.execute("ALTER TABLE `" + tablePrefix + "users` " + "DROP INDEX `user`," + "ADD INDEX `user` (`user`(20) ASC)"); @@ -1164,7 +1163,7 @@ public final class SQLDatabaseManager implements DatabaseManager { try { statement.executeQuery("SELECT `alchemy` FROM `" + tablePrefix + "skills` LIMIT 1"); } catch (SQLException ex) { - mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Alchemy..."); + pluginRef.getLogger().info("Updating mcMMO MySQL tables for Alchemy..."); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD `alchemy` int(10) NOT NULL DEFAULT '0'"); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "experience` ADD `alchemy` int(10) NOT NULL DEFAULT '0'"); } @@ -1174,7 +1173,7 @@ public final class SQLDatabaseManager implements DatabaseManager { try { statement.executeQuery("SELECT `blast_mining` FROM `" + tablePrefix + "cooldowns` LIMIT 1"); } catch (SQLException ex) { - mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Blast Mining..."); + pluginRef.getLogger().info("Updating mcMMO MySQL tables for Blast Mining..."); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0'"); } } @@ -1183,7 +1182,7 @@ public final class SQLDatabaseManager implements DatabaseManager { try { statement.executeQuery("SELECT `chimaera_wing` FROM `" + tablePrefix + "cooldowns` LIMIT 1"); } catch (SQLException ex) { - mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Chimaera Wing..."); + pluginRef.getLogger().info("Updating mcMMO MySQL tables for Chimaera Wing..."); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "cooldowns` ADD `chimaera_wing` int(32) NOT NULL DEFAULT '0'"); } } @@ -1192,7 +1191,7 @@ public final class SQLDatabaseManager implements DatabaseManager { try { statement.executeQuery("SELECT `fishing` FROM `" + tablePrefix + "skills` LIMIT 1"); } catch (SQLException ex) { - mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Fishing..."); + pluginRef.getLogger().info("Updating mcMMO MySQL tables for Fishing..."); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0'"); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0'"); } @@ -1202,8 +1201,8 @@ public final class SQLDatabaseManager implements DatabaseManager { try { statement.executeQuery("SELECT `mobhealthbar` FROM `" + tablePrefix + "huds` LIMIT 1"); } catch (SQLException ex) { - mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for mob healthbars..."); - statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `mobhealthbar` varchar(50) NOT NULL DEFAULT '" + mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType() + "'"); + pluginRef.getLogger().info("Updating mcMMO MySQL tables for mob healthbars..."); + statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `mobhealthbar` varchar(50) NOT NULL DEFAULT '" + pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType() + "'"); } } @@ -1211,7 +1210,7 @@ public final class SQLDatabaseManager implements DatabaseManager { try { statement.executeQuery("SELECT `scoreboardtips` FROM `" + tablePrefix + "huds` LIMIT 1"); } catch (SQLException ex) { - mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for scoreboard tips..."); + pluginRef.getLogger().info("Updating mcMMO MySQL tables for scoreboard tips..."); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `scoreboardtips` int(10) NOT NULL DEFAULT '0' ;"); } } @@ -1224,7 +1223,7 @@ public final class SQLDatabaseManager implements DatabaseManager { resultSet.last(); if (resultSet.getRow() != PrimarySkillType.NON_CHILD_SKILLS.size()) { - mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases"); + pluginRef.getLogger().info("Indexing tables, this may take a while on larger databases"); for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) { String skill_name = skill.name().toLowerCase(); @@ -1260,7 +1259,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } if (!column_exists) { - mcMMO.p.getLogger().info("Adding UUIDs to mcMMO MySQL user table..."); + pluginRef.getLogger().info("Adding UUIDs to mcMMO MySQL user table..."); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` ADD `uuid` varchar(36) NULL DEFAULT NULL"); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` ADD UNIQUE INDEX `uuid` (`uuid`) USING BTREE"); } @@ -1323,7 +1322,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } if (column_exists) { - mcMMO.p.getLogger().info("Removing party name from users table..."); + pluginRef.getLogger().info("Removing party name from users table..."); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party`"); } } catch (SQLException ex) { @@ -1353,7 +1352,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } if (!column_exists) { - mcMMO.p.getLogger().info("Adding skill total column to skills table..."); + pluginRef.getLogger().info("Adding skill total column to skills table..."); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD COLUMN `total` int NOT NULL DEFAULT '0'"); statement.executeUpdate("UPDATE `" + tablePrefix + "skills` SET `total` = (taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy)"); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_total` (`total`) USING BTREE"); @@ -1385,7 +1384,7 @@ public final class SQLDatabaseManager implements DatabaseManager { } if (column_exists) { - mcMMO.p.getLogger().info("Removing Spout HUD type from huds table..."); + pluginRef.getLogger().info("Removing Spout HUD type from huds table..."); statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` DROP COLUMN `hudtype`"); } } catch (SQLException ex) { @@ -1464,7 +1463,7 @@ public final class SQLDatabaseManager implements DatabaseManager { @Override public void onDisable() { - mcMMO.p.debug("Releasing connection pool resource..."); + pluginRef.debug("Releasing connection pool resource..."); miscPool.close(); loadPool.close(); savePool.close(); @@ -1477,7 +1476,7 @@ public final class SQLDatabaseManager implements DatabaseManager { try { connection = getConnection(PoolIdentifier.MISC); statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ?"); - statement.setString(1, mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString()); + statement.setString(1, pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString()); statement.executeUpdate(); } catch (SQLException ex) { printErrors(ex); diff --git a/src/main/java/com/gmail/nossr50/datatypes/chat/ChatMode.java b/src/main/java/com/gmail/nossr50/datatypes/chat/ChatMode.java index 9fb25cb37..9170b18c6 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/chat/ChatMode.java +++ b/src/main/java/com/gmail/nossr50/datatypes/chat/ChatMode.java @@ -1,10 +1,8 @@ package com.gmail.nossr50.datatypes.chat; -import com.gmail.nossr50.locale.LocaleLoader; - public enum ChatMode { - ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")), - PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off")); + ADMIN(pluginRef.getLocaleManager().getString("Commands.AdminChat.On"), pluginRef.getLocaleManager().getString("Commands.AdminChat.Off")), + PARTY(pluginRef.getLocaleManager().getString("Commands.Party.Chat.On"), pluginRef.getLocaleManager().getString("Commands.Party.Chat.Off")); private String enabledMessage; private String disabledMessage; diff --git a/src/main/java/com/gmail/nossr50/datatypes/experience/SkillXpGain.java b/src/main/java/com/gmail/nossr50/datatypes/experience/SkillXpGain.java index d617cb441..9e8339b29 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/experience/SkillXpGain.java +++ b/src/main/java/com/gmail/nossr50/datatypes/experience/SkillXpGain.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.datatypes.experience; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.mcMMO; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; @@ -18,7 +17,7 @@ public class SkillXpGain implements Delayed { } private static long getDuration() { - return TimeUnit.MINUTES.toMillis(mcMMO.getConfigManager().getConfigLeveling().getDimishedReturnTimeInterval()); + return TimeUnit.MINUTES.toMillis(pluginRef.getConfigManager().getConfigLeveling().getDimishedReturnTimeInterval()); } public PrimarySkillType getSkill() { diff --git a/src/main/java/com/gmail/nossr50/datatypes/items/ItemMatch.java b/src/main/java/com/gmail/nossr50/datatypes/items/ItemMatch.java index 4b8fec75b..9910b66f2 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/items/ItemMatch.java +++ b/src/main/java/com/gmail/nossr50/datatypes/items/ItemMatch.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.datatypes.items; -import com.gmail.nossr50.mcMMO; - import java.util.HashSet; import java.util.Objects; import java.util.Set; @@ -80,7 +78,7 @@ public class ItemMatch> implements DefinedMatch> */ private boolean isStrictMatch(MMOItem otherItem) { for(ItemMatchProperty itemMatchProperty : itemMatchProperties) { - if(!mcMMO.getNbtManager().hasNBT(otherItem.getRawNBT().getNbtData(), itemMatchProperty.getNbtData())) { + if(!pluginRef.getNbtManager().hasNBT(otherItem.getRawNBT().getNbtData(), itemMatchProperty.getNbtData())) { return false; } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/json/McMMOWebLinks.java b/src/main/java/com/gmail/nossr50/datatypes/json/McMMOWebLinks.java index 0fb3714df..beee41a28 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/json/McMMOWebLinks.java +++ b/src/main/java/com/gmail/nossr50/datatypes/json/McMMOWebLinks.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.datatypes.json; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.StringUtils; public enum McMMOWebLinks { @@ -22,17 +21,17 @@ public enum McMMOWebLinks { public String getLocaleDescription() { switch (this) { case WEBSITE: - return LocaleLoader.getString("JSON.URL.Website"); + return pluginRef.getLocaleManager().getString("JSON.URL.Website"); case DISCORD: - return LocaleLoader.getString("JSON.URL.Discord"); + return pluginRef.getLocaleManager().getString("JSON.URL.Discord"); case PATREON: - return LocaleLoader.getString("JSON.URL.Patreon"); + return pluginRef.getLocaleManager().getString("JSON.URL.Patreon"); case HELP_TRANSLATE: - return LocaleLoader.getString("JSON.URL.Translation"); + return pluginRef.getLocaleManager().getString("JSON.URL.Translation"); case SPIGOT: - return LocaleLoader.getString("JSON.URL.Spigot"); + return pluginRef.getLocaleManager().getString("JSON.URL.Spigot"); case WIKI: - return LocaleLoader.getString("JSON.URL.Wiki"); + return pluginRef.getLocaleManager().getString("JSON.URL.Wiki"); default: return ""; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/ItemShareType.java b/src/main/java/com/gmail/nossr50/datatypes/party/ItemShareType.java index ee7a132db..f9deab78a 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/ItemShareType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/ItemShareType.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.datatypes.party; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.StringUtils; import org.bukkit.inventory.ItemStack; @@ -22,7 +20,7 @@ public enum ItemShareType { return HERBALISM; } else if (ItemUtils.isWoodcuttingDrop(itemStack)) { return WOODCUTTING; - } else if (mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(itemStack.getType()) != null) { + } else if (pluginRef.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(itemStack.getType()) != null) { return MISC; } @@ -30,6 +28,6 @@ public enum ItemShareType { } public String getLocaleString() { - return LocaleLoader.getString("Party.ItemShare.Category." + StringUtils.getCapitalized(this.toString())); + return pluginRef.getLocaleManager().getString("Party.ItemShare.Category." + StringUtils.getCapitalized(this.toString())); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java index 4a82fc736..1141648ff 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -1,9 +1,6 @@ package com.gmail.nossr50.datatypes.party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.player.UserManager; @@ -192,7 +189,7 @@ public class Party { } public int getXpToLevel() { - return mcMMO.getFormulaManager().getXPtoNextLevel(level); + return pluginRef.getFormulaManager().getXPtoNextLevel(level); } public String getXpToLevelPercentage() { @@ -231,18 +228,18 @@ public class Party { return; } - if (!mcMMO.getConfigManager().getConfigParty().getPartyXP().getPartyLevel().isInformPartyMembersOnLevelup()) { - Player leader = mcMMO.p.getServer().getPlayer(this.leader.getUniqueId()); + if (!pluginRef.getConfigManager().getConfigParty().getPartyXP().getPartyLevel().isInformPartyMembersOnLevelup()) { + Player leader = pluginRef.getServer().getPlayer(this.leader.getUniqueId()); if (leader != null) { - leader.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, getLevel())); + leader.sendMessage(pluginRef.getLocaleManager().getString("Party.LevelUp", levelsGained, getLevel())); SoundManager.sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP); } return; } - PartyManager.informPartyMembersLevelUp(this, levelsGained, getLevel()); + pluginRef.getPartyManager().informPartyMembersLevelUp(this, levelsGained, getLevel()); } public ShareMode getXpShareMode() { @@ -376,7 +373,7 @@ public class Party { List nearbyPlayerList = getNearMembers(UserManager.getPlayer(player)); - boolean useDisplayNames = mcMMO.getConfigManager().getConfigParty().isPartyDisplayNamesEnabled(); + boolean useDisplayNames = pluginRef.getConfigManager().getConfigParty().isPartyDisplayNamesEnabled(); if (isPartyLeaderOfflineOrHidden) { if (isNotSamePerson(player.getUniqueId(), leader.getUniqueId())) @@ -491,7 +488,7 @@ public class Party { if (party != null) { Player player = mcMMOPlayer.getPlayer(); - double range = mcMMO.getConfigManager().getConfigParty().getPartyXP().getPartyExperienceSharing().getPartyShareRange(); + double range = pluginRef.getConfigManager().getConfigParty().getPartyXP().getPartyExperienceSharing().getPartyShareRange(); for (Player member : party.getOnlineMembers()) { if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/PartyFeature.java b/src/main/java/com/gmail/nossr50/datatypes/party/PartyFeature.java index e8a67b4df..82cf83e32 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/PartyFeature.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/PartyFeature.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.datatypes.party; import com.gmail.nossr50.commands.party.PartySubcommandType; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; import org.bukkit.entity.Player; @@ -15,14 +13,14 @@ public enum PartyFeature { XP_SHARE; public String getLocaleString() { - return LocaleLoader.getString("Party.Feature." + StringUtils.getPrettyPartyFeatureString(this).replace(" ", "")); + return pluginRef.getLocaleManager().getString("Party.Feature." + StringUtils.getPrettyPartyFeatureString(this).replace(" ", "")); } public String getFeatureLockedLocaleString() { - return LocaleLoader.getString("Ability.Generic.Template.Lock", - LocaleLoader.getString("Party.Feature.Locked." + return pluginRef.getLocaleManager().getString("Ability.Generic.Template.Lock", + pluginRef.getLocaleManager().getString("Party.Feature.Locked." + StringUtils.getPrettyPartyFeatureString(this).replace(" ", ""), - PartyManager.getPartyFeatureUnlockLevel(this))); + pluginRef.getPartyManager().getPartyFeatureUnlockLevel(this))); } public boolean hasPermission(Player player) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/PartyTeleportRecord.java b/src/main/java/com/gmail/nossr50/datatypes/party/PartyTeleportRecord.java index a6499d722..3d50cfc14 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/PartyTeleportRecord.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/PartyTeleportRecord.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.datatypes.party; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import org.bukkit.entity.Player; @@ -12,7 +11,7 @@ public class PartyTeleportRecord { public PartyTeleportRecord() { requestor = null; enabled = true; - confirmRequired = mcMMO.getConfigManager().getConfigParty().getPTP().isPtpAcceptRequired(); + confirmRequired = pluginRef.getConfigManager().getConfigParty().getPTP().isPtpAcceptRequired(); timeout = 0; lastUse = 0; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 7dfd0bb45..ab274b101 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -10,9 +10,7 @@ import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; 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.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.runnables.skills.AbilityDisableTask; import com.gmail.nossr50.runnables.skills.BleedTimerTask; @@ -93,7 +91,7 @@ public class McMMOPlayer { UUID uuid = player.getUniqueId(); this.player = player; - playerMetadata = new FixedMetadataValue(mcMMO.p, playerName); + playerMetadata = new FixedMetadataValue(pluginRef, playerName); this.profile = profile; if (profile.getUniqueId() == null) { @@ -111,7 +109,7 @@ public class McMMOPlayer { } } catch (Exception e) { e.printStackTrace(); - mcMMO.p.getPluginLoader().disablePlugin(mcMMO.p); + pluginRef.getPluginLoader().disablePlugin(pluginRef); } for (SuperAbilityType superAbilityType : SuperAbilityType.values()) { @@ -141,7 +139,7 @@ public class McMMOPlayer { continue; //Set the players custom XP modifier, defaults to 1.0D on missing entries - personalXPModifiers.put(primarySkillType, mcMMO.getPlayerLevelUtils().determineXpPerkValue(player, primarySkillType)); + personalXPModifiers.put(primarySkillType, pluginRef.getPlayerLevelUtils().determineXpPerkValue(player, primarySkillType)); } } @@ -169,17 +167,17 @@ public class McMMOPlayer { { //Check if they've reached the power level cap just now if(hasReachedPowerLevelCap()) { - mcMMO.getNotificationManager().sendPlayerInformationChatOnly(player, "LevelCap.PowerLevel", String.valueOf(mcMMO.getConfigManager().getConfigLeveling().getPowerLevelCap())); + pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "LevelCap.PowerLevel", String.valueOf(pluginRef.getConfigManager().getConfigLeveling().getPowerLevelCap())); } else if(hasReachedLevelCap(primarySkillType)) { - mcMMO.getNotificationManager().sendPlayerInformationChatOnly(player, "LevelCap.Skill", String.valueOf(mcMMO.getConfigManager().getConfigLeveling().getSkillLevelCap(primarySkillType)), primarySkillType.getName()); + pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "LevelCap.Skill", String.valueOf(pluginRef.getConfigManager().getConfigLeveling().getSkillLevelCap(primarySkillType)), primarySkillType.getName()); } //Updates from Party sources - if (xpGainSource == XPGainSource.PARTY_MEMBERS && !mcMMO.getConfigManager().getConfigLeveling().isPartyExperienceTriggerXpBarDisplay()) + if (xpGainSource == XPGainSource.PARTY_MEMBERS && !pluginRef.getConfigManager().getConfigLeveling().isPartyExperienceTriggerXpBarDisplay()) return; //Updates from passive sources (Alchemy, Smelting, etc...) - if (xpGainSource == XPGainSource.PASSIVE && !mcMMO.getConfigManager().getConfigLeveling().isPassiveGainXPBars()) + if (xpGainSource == XPGainSource.PASSIVE && !pluginRef.getConfigManager().getConfigLeveling().isPassiveGainXPBars()) return; updateXPBar(primarySkillType, plugin); @@ -418,7 +416,7 @@ public class McMMOPlayer { } public void actualizeTeleportATS() { - teleportATS = System.currentTimeMillis() + (mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().getTeleportCooldownSeconds() * 1000); + teleportATS = System.currentTimeMillis() + (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().getTeleportCooldownSeconds() * 1000); } public long getDatabaseATS() { @@ -492,7 +490,7 @@ public class McMMOPlayer { if(hasReachedPowerLevelCap()) return true; - if(getSkillLevel(primarySkillType) >= mcMMO.getConfigManager().getConfigLeveling().getSkillLevelCap(primarySkillType)) + if(getSkillLevel(primarySkillType) >= pluginRef.getConfigManager().getConfigLeveling().getSkillLevelCap(primarySkillType)) return true; return false; @@ -504,7 +502,7 @@ public class McMMOPlayer { * @return true if they have reached the power level cap */ public boolean hasReachedPowerLevelCap() { - return this.getPowerLevel() >= mcMMO.getConfigManager().getConfigLeveling().getPowerLevelCap(); + return this.getPowerLevel() >= pluginRef.getConfigManager().getConfigLeveling().getPowerLevelCap(); } /** @@ -557,7 +555,7 @@ public class McMMOPlayer { return; } - if (!mcMMO.getConfigManager().getConfigParty().getPartyXP().getPartyLevel().isPartyLevelingNeedsNearbyMembers() || !PartyManager.getNearMembers(this).isEmpty()) { + if (!pluginRef.getConfigManager().getConfigParty().getPartyXP().getPartyLevel().isPartyLevelingNeedsNearbyMembers() || !pluginRef.getPartyManager().getNearMembers(this).isEmpty()) { party.applyXpGain(modifyXpGain(skill, xp)); } } @@ -601,7 +599,7 @@ public class McMMOPlayer { return; if (getSkillXpLevelRaw(primarySkillType) < getXpToLevel(primarySkillType)) { - processPostXpEvent(primarySkillType, mcMMO.p, xpGainSource); + processPostXpEvent(primarySkillType, pluginRef, xpGainSource); return; } @@ -609,7 +607,7 @@ public class McMMOPlayer { double xpRemoved = 0; while (getSkillXpLevelRaw(primarySkillType) >= getXpToLevel(primarySkillType)) { - if (mcMMO.getPlayerLevelingSettings().isSkillLevelCapEnabled(primarySkillType) + if (pluginRef.getPlayerLevelingSettings().isSkillLevelCapEnabled(primarySkillType) && hasReachedLevelCap(primarySkillType)) { setSkillXpLevel(primarySkillType, 0); break; @@ -629,10 +627,10 @@ public class McMMOPlayer { * Check to see if the player unlocked any new skills */ - mcMMO.getNotificationManager().sendPlayerLevelUpNotification(this, primarySkillType, levelsGained, profile.getSkillLevel(primarySkillType)); + pluginRef.getNotificationManager().sendPlayerLevelUpNotification(this, primarySkillType, levelsGained, profile.getSkillLevel(primarySkillType)); //UPDATE XP BARS - processPostXpEvent(primarySkillType, mcMMO.p, xpGainSource); + processPostXpEvent(primarySkillType, pluginRef, xpGainSource); } /* @@ -652,7 +650,7 @@ public class McMMOPlayer { */ public void setupPartyData() { - party = PartyManager.getPlayerParty(player.getName(), player.getUniqueId()); + party = pluginRef.getPartyManager().getPlayerParty(player.getName(), player.getUniqueId()); ptpRecord = new PartyTeleportRecord(); if (inParty()) { @@ -805,12 +803,12 @@ public class McMMOPlayer { */ private double modifyXpGain(PrimarySkillType primarySkillType, double xp) { if (((primarySkillType.getMaxLevel() <= getSkillLevel(primarySkillType)) - && mcMMO.getPlayerLevelingSettings().isSkillLevelCapEnabled(primarySkillType)) - || (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().getLevelCap() <= getPowerLevel())) { + && pluginRef.getPlayerLevelingSettings().isSkillLevelCapEnabled(primarySkillType)) + || (pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().getLevelCap() <= getPowerLevel())) { return 0; } - xp = (double) (xp / primarySkillType.getXpModifier() * mcMMO.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()); + xp = (double) (xp / primarySkillType.getXpModifier() * pluginRef.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()); //Multiply by the players personal XP rate return xp * personalXPModifiers.get(primarySkillType); @@ -820,14 +818,14 @@ public class McMMOPlayer { if (godMode && !Permissions.mcgod(player) || godMode && WorldBlacklist.isWorldBlacklisted(player.getWorld())) { toggleGodMode(); - player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.GodMode.Forbidden")); } } public void checkParty() { if (inParty() && !Permissions.party(player)) { removeParty(); - player.sendMessage(LocaleLoader.getString("Party.Forbidden")); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Forbidden")); } } @@ -850,7 +848,7 @@ public class McMMOPlayer { int diff = RankUtils.getSuperAbilityUnlockRequirement(skill.getSuperAbility()) - getSkillLevel(skill); //Inform the player they are not yet skilled enough - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.AbilityGateRequirementFail", String.valueOf(diff), skill.getName()); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.AbilityGateRequirementFail", String.valueOf(diff), skill.getName()); return; } @@ -862,7 +860,7 @@ public class McMMOPlayer { * We show them the too tired message when they take action. */ if (skill == PrimarySkillType.WOODCUTTING || skill == PrimarySkillType.AXES) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); //SoundManager.sendSound(player, player.getLocation(), SoundType.TIRED); } @@ -874,7 +872,7 @@ public class McMMOPlayer { } if (useChatNotifications()) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUPER_ABILITY, ability.getAbilityOn()); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUPER_ABILITY, ability.getAbilityOn()); //player.sendMessage(ability.getAbilityOn()); } @@ -894,11 +892,11 @@ public class McMMOPlayer { } setToolPreparationMode(tool, false); - new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, abilityLength * Misc.TICK_CONVERSION_FACTOR); + new AbilityDisableTask(this, ability).runTaskLater(pluginRef, abilityLength * Misc.TICK_CONVERSION_FACTOR); } public void processAbilityActivation(PrimarySkillType skill) { - if (mcMMO.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() && !player.isSneaking()) { + if (pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() && !player.isSneaking()) { return; } @@ -930,18 +928,18 @@ public class McMMOPlayer { int timeRemaining = calculateTimeRemaining(ability); if (!getAbilityMode(ability) && timeRemaining > 0) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); return; } } - if (mcMMO.getConfigManager().getConfigNotifications().isSuperAbilityToolMessage()) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.TOOL, tool.getRaiseTool()); + if (pluginRef.getConfigManager().getConfigNotifications().isSuperAbilityToolMessage()) { + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.TOOL, tool.getRaiseTool()); SoundManager.sendSound(player, player.getLocation(), SoundType.TOOL_READY); } setToolPreparationMode(tool, true); - new ToolLowerTask(this, tool).runTaskLater(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR); + new ToolLowerTask(this, tool).runTaskLater(pluginRef, 4 * Misc.TICK_CONVERSION_FACTOR); } } @@ -1025,7 +1023,7 @@ public class McMMOPlayer { UserManager.remove(thisPlayer); - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled()) + if (pluginRef.getScoreboardSettings().getScoreboardsEnabled()) ScoreboardManager.teardownPlayer(thisPlayer); if (inParty()) { @@ -1033,6 +1031,6 @@ public class McMMOPlayer { } //Remove user from cache - mcMMO.getDatabaseManager().cleanupUser(thisPlayer.getUniqueId()); + pluginRef.getDatabaseManager().cleanupUser(thisPlayer.getUniqueId()); } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java index 908c64515..28f8b8612 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.experience.SkillXpGain; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask; import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.util.player.UserManager; @@ -43,7 +42,7 @@ public class PlayerProfile { this.uuid = uuid; this.playerName = playerName; - mobHealthbarType = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType(); + mobHealthbarType = pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType(); scoreboardTipsShown = 0; for (SuperAbilityType superAbilityType : SuperAbilityType.values()) { @@ -51,7 +50,7 @@ public class PlayerProfile { } for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { - skills.put(primarySkillType, mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel()); + skills.put(primarySkillType, pluginRef.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel()); skillsXp.put(primarySkillType, 0.0); } @@ -85,20 +84,20 @@ public class PlayerProfile { } public void scheduleAsyncSave() { - new PlayerProfileSaveTask(this, false).runTaskAsynchronously(mcMMO.p); + new PlayerProfileSaveTask(this, false).runTaskAsynchronously(pluginRef); } public void scheduleSyncSave() { - new PlayerProfileSaveTask(this, true).runTask(mcMMO.p); + new PlayerProfileSaveTask(this, true).runTask(pluginRef); } public void scheduleAsyncSaveDelay() { - new PlayerProfileSaveTask(this, false).runTaskLaterAsynchronously(mcMMO.p, 20); + new PlayerProfileSaveTask(this, false).runTaskLaterAsynchronously(pluginRef, 20); } @Deprecated public void scheduleSyncSaveDelay() { - new PlayerProfileSaveTask(this, true).runTaskLater(mcMMO.p, 20); + new PlayerProfileSaveTask(this, true).runTaskLater(pluginRef, 20); } public void save(boolean useSync) { @@ -109,13 +108,13 @@ public class PlayerProfile { // TODO should this part be synchronized? PlayerProfile profileCopy = new PlayerProfile(playerName, uuid, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType, scoreboardTipsShown, ImmutableMap.copyOf(uniquePlayerData)); - changed = !mcMMO.getDatabaseManager().saveUser(profileCopy); + changed = !pluginRef.getDatabaseManager().saveUser(profileCopy); if (changed) { - mcMMO.p.getLogger().severe("PlayerProfile saving failed for player: " + playerName + " " + uuid); + pluginRef.getLogger().severe("PlayerProfile saving failed for player: " + playerName + " " + uuid); if (saveAttempts > 0) { - mcMMO.p.getLogger().severe("Attempted to save profile for player " + getPlayerName() + pluginRef.getLogger().severe("Attempted to save profile for player " + getPlayerName() + " resulted in failure. " + saveAttempts + " have been made so far."); } @@ -129,7 +128,7 @@ public class PlayerProfile { return; } else { - mcMMO.p.getLogger().severe("mcMMO has failed to save the profile for " + pluginRef.getLogger().severe("mcMMO has failed to save the profile for " + getPlayerName() + " numerous times." + " mcMMO will now stop attempting to save this profile." + " Check your console for errors and inspect your DB for issues."); @@ -409,9 +408,9 @@ public class PlayerProfile { * @return the total amount of Xp until next level */ public int getXpToLevel(PrimarySkillType primarySkillType) { - int level = (mcMMO.getConfigManager().getConfigLeveling().getConfigExperienceFormula().isCumulativeCurveEnabled()) ? UserManager.getPlayer(playerName).getPowerLevel() : skills.get(primarySkillType); + int level = (pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceFormula().isCumulativeCurveEnabled()) ? UserManager.getPlayer(playerName).getPowerLevel() : skills.get(primarySkillType); - return mcMMO.getFormulaManager().getXPtoNextLevel(level); + return pluginRef.getFormulaManager().getXPtoNextLevel(level); } private int getChildSkillLevel(PrimarySkillType primarySkillType) { @@ -419,7 +418,7 @@ public class PlayerProfile { int sum = 0; for (PrimarySkillType parent : parents) { - if (mcMMO.getPlayerLevelingSettings().isSkillLevelCapEnabled(parent)) + if (pluginRef.getPlayerLevelingSettings().isSkillLevelCapEnabled(parent)) sum += Math.min(getSkillLevel(parent), parent.getMaxLevel()); else sum += getSkillLevel(parent); diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java index cce250d00..84cbccbe3 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.datatypes.skills; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; import com.gmail.nossr50.skills.alchemy.AlchemyManager; @@ -123,9 +121,9 @@ public enum PrimarySkillType { } public static PrimarySkillType getSkill(String skillName) { - if (!mcMMO.getConfigManager().getConfigLanguage().getTargetLanguage().equalsIgnoreCase("en_US")) { + if (!pluginRef.getConfigManager().getConfigLanguage().getTargetLanguage().equalsIgnoreCase("en_US")) { for (PrimarySkillType type : values()) { - if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(type.name()) + ".SkillName"))) { + if (skillName.equalsIgnoreCase(pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(type.name()) + ".SkillName"))) { return type; } } @@ -138,7 +136,7 @@ public enum PrimarySkillType { } if (!skillName.equalsIgnoreCase("all")) { - mcMMO.p.getLogger().warning("Invalid mcMMO skill (" + skillName + ")"); //TODO: Localize + pluginRef.getLogger().warning("Invalid mcMMO skill (" + skillName + ")"); //TODO: Localize } return null; @@ -151,7 +149,7 @@ public enum PrimarySkillType { } } - mcMMO.p.getLogger().severe("Unable to locate parent for "+subSkillType.toString()); + pluginRef.getLogger().severe("Unable to locate parent for "+subSkillType.toString()); return null; } @@ -179,7 +177,7 @@ public enum PrimarySkillType { * @return the max level of this skill */ public int getMaxLevel() { - return mcMMO.getPlayerLevelingSettings().getSkillLevelCap(this); + return pluginRef.getPlayerLevelingSettings().getSkillLevelCap(this); } /*public boolean getDoubleDropsDisabled() { @@ -195,7 +193,7 @@ public enum PrimarySkillType { }*/ public boolean getPVPEnabled() { - return mcMMO.getConfigManager().getConfigCoreSkills().isPVPEnabled(this); + return pluginRef.getConfigManager().getConfigCoreSkills().isPVPEnabled(this); } /*public void setHardcoreVampirismEnabled(boolean enable) { @@ -203,15 +201,15 @@ public enum PrimarySkillType { }*/ public boolean getPVEEnabled() { - return mcMMO.getConfigManager().getConfigCoreSkills().isPVEEnabled(this); + return pluginRef.getConfigManager().getConfigCoreSkills().isPVEEnabled(this); } public boolean getHardcoreStatLossEnabled() { - return mcMMO.getConfigManager().getConfigHardcore().getDeathPenalty().getSkillToggleMap().get(this); + return pluginRef.getConfigManager().getConfigHardcore().getDeathPenalty().getSkillToggleMap().get(this); } public boolean getHardcoreVampirismEnabled() { - return mcMMO.getConfigManager().getConfigHardcore().getVampirism().getSkillToggleMap().get(this); + return pluginRef.getConfigManager().getConfigHardcore().getVampirism().getSkillToggleMap().get(this); } public ToolType getTool() { @@ -223,7 +221,7 @@ public enum PrimarySkillType { } public double getXpModifier() { - return mcMMO.getConfigManager().getConfigLeveling().getSkillXpFormulaModifier(this); + return pluginRef.getConfigManager().getConfigLeveling().getSkillXpFormulaModifier(this); } // TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them @@ -239,8 +237,8 @@ public enum PrimarySkillType { } public String getName() { - //return MainConfig.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName")); - return StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName")); + //return MainConfig.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(this.toString()) + ".SkillName")); + return StringUtils.getCapitalized(pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(this.toString()) + ".SkillName")); } public boolean getPermissions(Player player) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java index 3d55405ed..16b61470b 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SubSkillType.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.datatypes.skills; import com.gmail.nossr50.config.hocon.HOCONUtil; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.StringUtils; public enum SubSkillType { @@ -265,12 +264,12 @@ public enum SubSkillType { } /** - * Returns the name of the parent skill from the Locale file + * Returns the name of the parent skill from the LocaleManager file * * @return The parent skill as defined in the locale */ public String getParentNiceNameLocale() { - return LocaleLoader.getString(StringUtils.getCapitalized(getParentSkill().toString()) + ".SkillName"); + return pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(getParentSkill().toString()) + ".SkillName"); } /** @@ -333,17 +332,17 @@ public enum SubSkillType { } public String getLocaleStat(String... vars) { - String statMsg = LocaleLoader.getString("Ability.Generic.Template", (Object[]) vars); + String statMsg = pluginRef.getLocaleManager().getString("Ability.Generic.Template", (Object[]) vars); return statMsg; } public String getCustomLocaleStat(String... vars) { - String statMsg = LocaleLoader.getString("Ability.Generic.Template.Custom", (Object[]) vars); + String statMsg = pluginRef.getLocaleManager().getString("Ability.Generic.Template.Custom", (Object[]) vars); return statMsg; } private String getFromLocaleSubAddress(String s) { - return LocaleLoader.getString(getLocaleKeyRoot() + s); + return pluginRef.getLocaleManager().getString(getLocaleKeyRoot() + s); } private String getLocaleKeyFromSubAddress(String s) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java index 438b98818..4ed788e78 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/SuperAbilityType.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.datatypes.skills; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; @@ -100,11 +99,11 @@ public enum SuperAbilityType { } public int getCooldown() { - return mcMMO.getConfigManager().getConfigSuperAbilities().getCooldownForSuper(this); + return pluginRef.getConfigManager().getConfigSuperAbilities().getCooldownForSuper(this); } public int getMaxLength() { - return mcMMO.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(this); + return pluginRef.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(this); } public String getAbilityOn() { diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/AbstractSubSkill.java b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/AbstractSubSkill.java index ddea1c65d..e4e7f4092 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/AbstractSubSkill.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/AbstractSubSkill.java @@ -5,12 +5,11 @@ import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Interaction; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.Rank; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.SubSkill; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.SubSkillProperties; -import com.gmail.nossr50.locale.LocaleLoader; import org.bukkit.entity.Player; public abstract class AbstractSubSkill implements SubSkill, Interaction, Rank, SubSkillProperties { /* - * The name of the subskill is important is used to pull Locale strings and config settings + * The name of the subskill is important is used to pull LocaleManager strings and config settings */ protected String configKeySubSkill; protected String configKeyPrimary; @@ -29,7 +28,7 @@ public abstract class AbstractSubSkill implements SubSkill, Interaction, Rank, S */ @Override public String getDescription() { - return LocaleLoader.getString(getPrimaryKeyName() + ".SubSkill." + getConfigKeyName() + ".Description"); + return pluginRef.getLocaleManager().getString(getPrimaryKeyName() + ".SubSkill." + getConfigKeyName() + ".Description"); } /** @@ -42,9 +41,9 @@ public abstract class AbstractSubSkill implements SubSkill, Interaction, Rank, S /* DEFAULT SETTINGS PRINT THE BARE MINIMUM */ //TextComponentFactory.sendPlayerUrlHeader(player); - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header")); - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", getConfigKeyName())); - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.Header")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.SubSkillHeader", getConfigKeyName())); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.DetailsHeader")); } public SubSkillType getSubSkillType() { diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/AcrobaticsSubSkill.java b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/AcrobaticsSubSkill.java index 1f951dd30..7ac827933 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/AcrobaticsSubSkill.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/AcrobaticsSubSkill.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; import org.bukkit.event.Event; @@ -22,13 +21,13 @@ public abstract class AcrobaticsSubSkill extends AbstractSubSkill { /** * The name of this subskill - * Core mcMMO skills will pull the name from Locale with this method + * Core mcMMO skills will pull the name from LocaleManager with this method * * @return the subskill name */ @Override public String getNiceName() { - return LocaleLoader.getString(getPrimaryKeyName() + ".SubSkill." + getConfigKeyName() + ".Name"); + return pluginRef.getLocaleManager().getString(getPrimaryKeyName() + ".SubSkill." + getConfigKeyName() + ".Name"); } /** @@ -48,7 +47,7 @@ public abstract class AcrobaticsSubSkill extends AbstractSubSkill { */ @Override public String getTips() { - return LocaleLoader.getString("JSON." + StringUtils.getCapitalized(getPrimarySkill().toString()) + ".SubSkill." + getConfigKeyName() + ".Details.Tips"); + return pluginRef.getLocaleManager().getString("JSON." + StringUtils.getCapitalized(getPrimarySkill().toString()) + ".SubSkill." + getConfigKeyName() + ".Details.Tips"); } /** diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java index 9850fb5ca..0c800fc7f 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Permissions; @@ -146,24 +145,24 @@ public class Roll extends AcrobaticsSubSkill { * Append the messages */ - /*componentBuilder.append(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3"))); + /*componentBuilder.append(pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Acrobatics.Effect.2"), pluginRef.getLocaleManager().getString("Acrobatics.Effect.3"))); componentBuilder.append("\n");*/ //Acrobatics.SubSkill.Roll.Chance - componentBuilder.append(LocaleLoader.getString("Acrobatics.SubSkill.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : "")); + componentBuilder.append(pluginRef.getLocaleManager().getString("Acrobatics.SubSkill.Roll.Chance", rollChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", rollChanceLucky) : "")); componentBuilder.append("\n"); - componentBuilder.append(LocaleLoader.getString("Acrobatics.SubSkill.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : "")); + componentBuilder.append(pluginRef.getLocaleManager().getString("Acrobatics.SubSkill.Roll.GraceChance", gracefulRollChance) + (isLucky ? pluginRef.getLocaleManager().getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : "")); //Activation Tips - componentBuilder.append("\n").append(LocaleLoader.getString("JSON.Hover.Tips")).append("\n"); + componentBuilder.append("\n").append(pluginRef.getLocaleManager().getString("JSON.Hover.Tips")).append("\n"); componentBuilder.append(getTips()); componentBuilder.append("\n"); //Advanced //Lucky Notice if (isLucky) { - componentBuilder.append(LocaleLoader.getString("JSON.JWrapper.Perks.Header")); + componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.JWrapper.Perks.Header")); componentBuilder.append("\n"); - componentBuilder.append(LocaleLoader.getString("JSON.JWrapper.Perks.Lucky", "33")); + componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.JWrapper.Perks.Lucky", "33")); } } @@ -201,14 +200,14 @@ public class Roll extends AcrobaticsSubSkill { return gracefulRollCheck(player, mcMMOPlayer, damage, skillLevel); } - double modifiedDamage = calculateModifiedRollDamage(damage, mcMMO.getConfigManager().getConfigAcrobatics().getRollDamageTheshold()); + double modifiedDamage = calculateModifiedRollDamage(damage, pluginRef.getConfigManager().getConfigAcrobatics().getRollDamageTheshold()); if (!isFatal(player, modifiedDamage) && RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_ROLL, player)) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Roll.Text"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Roll.Text"); SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS); - if (!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) + if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); else if (!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP()) SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); @@ -216,7 +215,7 @@ public class Roll extends AcrobaticsSubSkill { addFallLocation(player); return modifiedDamage; } else if (!isFatal(player, damage)) { - if (!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) + if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); else if (!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP()) SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE); @@ -237,17 +236,17 @@ public class Roll extends AcrobaticsSubSkill { * @return the modified event damage if the ability was successful, the original event damage otherwise */ private double gracefulRollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage, int skillLevel) { - double modifiedDamage = calculateModifiedRollDamage(damage, mcMMO.getConfigManager().getConfigAcrobatics().getRollDamageTheshold() * 2); + double modifiedDamage = calculateModifiedRollDamage(damage, pluginRef.getConfigManager().getConfigAcrobatics().getRollDamageTheshold() * 2); RandomChanceSkill rcs = new RandomChanceSkill(player, subSkillType); rcs.setSkillLevel(rcs.getSkillLevel() * 2); //Double the effective odds if (!isFatal(player, modifiedDamage) && RandomChanceUtil.checkRandomChanceExecutionSuccess(rcs)) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc"); SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS, 0.5F); - if (!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) + if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); else if (!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP()) SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); @@ -255,7 +254,7 @@ public class Roll extends AcrobaticsSubSkill { addFallLocation(player); return modifiedDamage; } else if (!isFatal(player, damage)) { - if (!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) + if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE); else if (!isExploiting(player) && mcMMOPlayer.getAcrobaticsManager().canGainRollXP()) SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE); @@ -273,7 +272,7 @@ public class Roll extends AcrobaticsSubSkill { * @return true if exploits are detected, false otherwise */ private boolean isExploiting(Player player) { - if (!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) { + if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) { return false; } @@ -293,10 +292,10 @@ public class Roll extends AcrobaticsSubSkill { private float calculateRollXP(Player player, double damage, boolean isRoll) { ItemStack boots = player.getInventory().getBoots(); - float xp = (float) (damage * (isRoll ? mcMMO.getConfigManager().getConfigExperience().getRollXP() : mcMMO.getConfigManager().getConfigExperience().getFallXP())); + float xp = (float) (damage * (isRoll ? pluginRef.getConfigManager().getConfigExperience().getRollXP() : pluginRef.getConfigManager().getConfigExperience().getFallXP())); if (boots != null && boots.containsEnchantment(Enchantment.PROTECTION_FALL)) { - xp *= mcMMO.getConfigManager().getConfigExperience().getFeatherFallMultiplier(); + xp *= pluginRef.getConfigManager().getConfigExperience().getFeatherFallMultiplier(); } return xp; @@ -329,11 +328,11 @@ public class Roll extends AcrobaticsSubSkill { //Start the description string. //player.sendMessage(getDescription()); //Player stats - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Stats", - LocaleLoader.getString("Acrobatics.SubSkill.Roll.Stats", getStats(player)[0], getStats(player)[1]))); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.Stats", + pluginRef.getLocaleManager().getString("Acrobatics.SubSkill.Roll.Stats", getStats(player)[0], getStats(player)[1]))); //Mechanics - player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mechanics")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.MmoInfo.Mechanics")); player.sendMessage(getMechanics()); } @@ -363,7 +362,7 @@ public class Roll extends AcrobaticsSubSkill { //Chance to roll at half max skill RandomChanceSkill rollHalfMaxSkill = new RandomChanceSkill(null, subSkillType); - int halfMaxSkillValue = mcMMO.isRetroModeEnabled() ? 500 : 50; + int halfMaxSkillValue = pluginRef.isRetroModeEnabled() ? 500 : 50; rollHalfMaxSkill.setSkillLevel(halfMaxSkillValue); //Chance to graceful roll at full skill @@ -377,13 +376,13 @@ public class Roll extends AcrobaticsSubSkill { //Chance Stat Calculations rollChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollHalfMaxSkill); graceChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollGraceHalfMaxSkill); - damageThreshold = mcMMO.getConfigManager().getConfigAcrobatics().getRollDamageTheshold(); + damageThreshold = pluginRef.getConfigManager().getConfigAcrobatics().getRollDamageTheshold(); chancePerLevel = RandomChanceUtil.getRandomChanceExecutionChance(rollOneSkillLevel); - double maxLevel = mcMMO.getDynamicSettingsManager().getSkillMaxBonusLevel(SubSkillType.ACROBATICS_ROLL); + double maxLevel = pluginRef.getDynamicSettingsManager().getSkillMaxBonusLevel(SubSkillType.ACROBATICS_ROLL); - return LocaleLoader.getString("Acrobatics.SubSkill.Roll.Mechanics", rollChanceHalfMax, graceChanceHalfMax, maxLevel, chancePerLevel, damageThreshold, damageThreshold * 2); + return pluginRef.getLocaleManager().getString("Acrobatics.SubSkill.Roll.Mechanics", rollChanceHalfMax, graceChanceHalfMax, maxLevel, chancePerLevel, damageThreshold, damageThreshold * 2); } /** diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java index af7fb7563..a24d1934f 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java +++ b/src/main/java/com/gmail/nossr50/datatypes/treasure/Treasure.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.datatypes.treasure; -import com.gmail.nossr50.mcMMO; import org.bukkit.inventory.ItemStack; public abstract class Treasure { @@ -42,7 +41,7 @@ public abstract class Treasure { public int getDropLevel() { //If they are in retro mode all requirements are scaled up by 10 - if (mcMMO.isRetroModeEnabled()) + if (pluginRef.isRetroModeEnabled()) return dropLevel * 10; return dropLevel; diff --git a/src/main/java/com/gmail/nossr50/dumpster/HolidayManager.java b/src/main/java/com/gmail/nossr50/dumpster/HolidayManager.java index faa25dac4..b9de4f2e8 100644 --- a/src/main/java/com/gmail/nossr50/dumpster/HolidayManager.java +++ b/src/main/java/com/gmail/nossr50/dumpster/HolidayManager.java @@ -4,7 +4,7 @@ //import com.gmail.nossr50.config.Config; //import com.gmail.nossr50.datatypes.interactions.NotificationType; //import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -//import com.gmail.nossr50.locale.LocaleLoader; +//import com.gmail.nossr50.locale.LocaleManager; //import com.gmail.nossr50.mcMMO; //import com.gmail.nossr50.util.player.NotificationManager; //import com.gmail.nossr50.util.player.UserManager; @@ -221,7 +221,7 @@ // return; // } // -// sender.sendMessage(LocaleLoader.getString("Holiday.Anniversary", (currentYear - START_YEAR))); +// sender.sendMessage(pluginRef.getLocaleManager().getString("Holiday.Anniversary", (currentYear - START_YEAR))); // /*if (sender instanceof Player) { // final int firework_amount = 10; // for (int i = 0; i < firework_amount; i++) { diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java index 089a5917f..2d33c4d1b 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOAdminChatEvent.java @@ -9,8 +9,4 @@ public class McMMOAdminChatEvent extends McMMOChatEvent { public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message) { super(plugin, sender, displayName, message); } - - public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) { - super(plugin, sender, displayName, message, isAsync); - } } diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java index ce13caf12..5ff211362 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOChatEvent.java @@ -23,14 +23,6 @@ public abstract class McMMOChatEvent extends Event implements Cancellable { this.message = message; } - protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) { - super(isAsync); - this.plugin = plugin; - this.sender = sender; - this.displayName = displayName; - this.message = message; - } - public static HandlerList getHandlerList() { return handlers; } diff --git a/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java b/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java index ffa54f815..a91e59b9b 100644 --- a/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java +++ b/src/main/java/com/gmail/nossr50/events/chat/McMMOPartyChatEvent.java @@ -1,27 +1,23 @@ package com.gmail.nossr50.events.chat; +import com.gmail.nossr50.datatypes.party.Party; import org.bukkit.plugin.Plugin; /** * Called when a chat is sent to a party channel */ public class McMMOPartyChatEvent extends McMMOChatEvent { - private String party; + private Party party; - public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, String party, String message) { + public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, Party party, String message) { super(plugin, sender, displayName, message); this.party = party; } - public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, String party, String message, boolean isAsync) { - super(plugin, sender, displayName, message, isAsync); - this.party = party; - } - /** * @return String name of the party the message will be sent to */ - public String getParty() { + public Party getParty() { return party; } } diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index fe4f9c195..1a2bfc6c6 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -24,10 +24,8 @@ 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.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; import org.bukkit.GameMode; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.block.Block; @@ -60,7 +58,7 @@ public class BlockListener implements Listener { if (is.getAmount() <= 0) continue; - if (!mcMMO.getDynamicSettingsManager().getBonusDropManager().isBonusDropWhitelisted(is.getType())) + if (!pluginRef.getDynamicSettingsManager().getBonusDropManager().isBonusDropWhitelisted(is.getType())) continue; if (event.getBlock().getMetadata(MetadataConstants.BONUS_DROPS_METAKEY).size() > 0) { @@ -120,8 +118,8 @@ public class BlockListener implements Listener { if (BlockUtils.shouldBeWatched(b.getState())) { movedBlock = b.getRelative(direction); - if (mcMMO.getConfigManager().getConfigExploitPrevention().doPistonsMarkBlocksUnnatural()) - mcMMO.getPlaceStore().setTrue(movedBlock); + if (pluginRef.getConfigManager().getConfigExploitPrevention().doPistonsMarkBlocksUnnatural()) + pluginRef.getPlaceStore().setTrue(movedBlock); } } } @@ -140,11 +138,11 @@ public class BlockListener implements Listener { // Get opposite direction so we get correct block BlockFace direction = event.getDirection(); Block movedBlock = event.getBlock().getRelative(direction); - mcMMO.getPlaceStore().setTrue(movedBlock); + pluginRef.getPlaceStore().setTrue(movedBlock); for (Block block : event.getBlocks()) { movedBlock = block.getRelative(direction); - mcMMO.getPlaceStore().setTrue(movedBlock); + pluginRef.getPlaceStore().setTrue(movedBlock); } } @@ -160,7 +158,7 @@ public class BlockListener implements Listener { return; if (BlockUtils.shouldBeWatched(event.getBlock().getState())) { - mcMMO.getPlaceStore().setTrue(event.getBlock()); + pluginRef.getPlaceStore().setTrue(event.getBlock()); } } @@ -173,11 +171,11 @@ public class BlockListener implements Listener { Block newBlock = event.getNewState().getBlock(); Material material = newBlock.getType(); - if (mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitSkills().isPreventCobblestoneStoneGeneratorXP()) { + if (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitSkills().isPreventCobblestoneStoneGeneratorXP()) { if (material != Material.OBSIDIAN && BlockUtils.shouldBeWatched(material) - && mcMMO.getDynamicSettingsManager().getExperienceManager().hasMiningXp(material)) { //Hacky fix to prevent trees growing from being marked as unnatural - mcMMO.getPlaceStore().setTrue(newBlock); + && pluginRef.getDynamicSettingsManager().getExperienceManager().hasMiningXp(material)) { //Hacky fix to prevent trees growing from being marked as unnatural + pluginRef.getPlaceStore().setTrue(newBlock); } } } @@ -205,7 +203,7 @@ public class BlockListener implements Listener { if (BlockUtils.shouldBeWatched(blockState)) { // Don't count de-barking wood if (!Tag.LOGS.isTagged(event.getBlockReplacedState().getType()) || !Tag.LOGS.isTagged(event.getBlockPlaced().getType())) - mcMMO.getPlaceStore().setTrue(blockState); + pluginRef.getPlaceStore().setTrue(blockState); } McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); @@ -247,7 +245,7 @@ public class BlockListener implements Listener { /* Check if the blocks placed should be monitored so they do not give out XP in the future */ if (BlockUtils.shouldBeWatched(blockState)) { - mcMMO.getPlaceStore().setTrue(blockState); + pluginRef.getPlaceStore().setTrue(blockState); } } } @@ -264,7 +262,7 @@ public class BlockListener implements Listener { return; } - mcMMO.getPlaceStore().setFalse(blockState); + pluginRef.getPlaceStore().setFalse(blockState); } /** @@ -332,13 +330,13 @@ public class BlockListener implements Listener { } /* MINING */ - else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && PrimarySkillType.MINING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) { + else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && PrimarySkillType.MINING.getPermissions(player) && !pluginRef.getPlaceStore().isTrue(blockState)) { MiningManager miningManager = mcMMOPlayer.getMiningManager(); miningManager.miningBlockCheck(blockState); } /* WOOD CUTTING */ - else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && PrimarySkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) { + else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && PrimarySkillType.WOODCUTTING.getPermissions(player) && !pluginRef.getPlaceStore().isTrue(blockState)) { WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager(); if (woodcuttingManager.canUseTreeFeller(heldItem)) { woodcuttingManager.processTreeFeller(blockState); @@ -348,7 +346,7 @@ public class BlockListener implements Listener { } /* EXCAVATION */ - else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && PrimarySkillType.EXCAVATION.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) { + else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && PrimarySkillType.EXCAVATION.getPermissions(player) && !pluginRef.getPlaceStore().isTrue(blockState)) { ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager(); excavationManager.excavationBlockCheck(blockState); @@ -358,7 +356,7 @@ public class BlockListener implements Listener { } /* Remove metadata from placed watched blocks */ - mcMMO.getPlaceStore().setFalse(blockState); + pluginRef.getPlaceStore().setFalse(blockState); } /** @@ -578,7 +576,7 @@ public class BlockListener implements Listener { public void debugStickDump(Player player, BlockState blockState) { - if (mcMMO.getPlaceStore().isTrue(blockState)) + if (pluginRef.getPlaceStore().isTrue(blockState)) 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"); @@ -609,7 +607,7 @@ public class BlockListener implements Listener { player.sendMessage("[mcMMO DEBUG] This furnace does not have a registered owner"); } - if (mcMMO.getConfigManager().getConfigLeveling().isEnableXPBars()) + if (pluginRef.getConfigManager().getConfigLeveling().isEnableXPBars()) player.sendMessage("[mcMMO DEBUG] XP bars are enabled, however you should check per-skill settings to make sure those are enabled."); } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 00c161ea1..ae7d3b8bf 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -9,7 +9,6 @@ import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.events.fake.FakeEntityTameEvent; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.mining.BlastMining; import com.gmail.nossr50.skills.mining.MiningManager; @@ -23,7 +22,6 @@ 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; -import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; import org.bukkit.Material; import org.bukkit.OfflinePlayer; @@ -62,7 +60,7 @@ public class EntityListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEntityTargetEntity(EntityTargetLivingEntityEvent event) { - if (!mcMMO.getConfigManager().getConfigExploitPrevention().getEndermenEndermiteFix()) + if (!pluginRef.getConfigManager().getConfigExploitPrevention().getEndermenEndermiteFix()) return; //It's rare but targets can be null sometimes @@ -109,7 +107,7 @@ public class EntityListener implements Listener { projectile.setMetadata(MetadataConstants.BOW_FORCE_METAKEY, new FixedMetadataValue(plugin, Math.min(event.getForce() - * mcMMO.getConfigManager().getConfigExperience().getExperienceArchery().getForceMultiplier(), 1.0))); + * pluginRef.getConfigManager().getConfigExperience().getExperienceArchery().getForceMultiplier(), 1.0))); projectile.setMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY, new FixedMetadataValue(plugin, projectile.getLocation())); } @@ -175,16 +173,16 @@ public class EntityListener implements Listener { if (entity instanceof FallingBlock || entity instanceof Enderman) { boolean isTracked = entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY); - if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) { - mcMMO.getPlaceStore().setFalse(block); + if (pluginRef.getPlaceStore().isTrue(block) && !isTracked) { + pluginRef.getPlaceStore().setFalse(block); entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue); } else if (isTracked) { - mcMMO.getPlaceStore().setTrue(block); + pluginRef.getPlaceStore().setTrue(block); } } else if ((block.getType() == Material.REDSTONE_ORE)) { } else { - if (mcMMO.getPlaceStore().isTrue(block)) { - mcMMO.getPlaceStore().setFalse(block); + if (pluginRef.getPlaceStore().isTrue(block)) { + pluginRef.getPlaceStore().setFalse(block); } } } @@ -436,9 +434,9 @@ public class EntityListener implements Listener { } //Party Friendly Fire - if(!mcMMO.getConfigManager().getConfigParty().isPartyFriendlyFireEnabled()) - if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) - || PartyManager.areAllies(defendingPlayer, attackingPlayer)) + if(!pluginRef.getConfigManager().getConfigParty().isPartyFriendlyFireEnabled()) + if ((pluginRef.getPartyManager().inSameParty(defendingPlayer, attackingPlayer) + || pluginRef.getPartyManager().areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { event.setCancelled(true); @@ -683,7 +681,7 @@ public class EntityListener implements Listener { case NETHER_PORTAL: case SPAWNER: case SPAWNER_EGG: - if (mcMMO.getConfigManager().getConfigExploitPrevention().doSpawnedEntitiesGiveModifiedXP()) { + if (pluginRef.getConfigManager().getConfigExploitPrevention().doSpawnedEntitiesGiveModifiedXP()) { entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue); Entity passenger = entity.getPassenger(); @@ -855,9 +853,9 @@ public class EntityListener implements Listener { //The main hand is used over the off hand if they both have food, so check the main hand first Material foodInHand; - if(mcMMO.getMaterialMapStore().isFood(player.getInventory().getItemInMainHand().getType())) { + if(pluginRef.getMaterialMapStore().isFood(player.getInventory().getItemInMainHand().getType())) { foodInHand = player.getInventory().getItemInMainHand().getType(); - } else if(mcMMO.getMaterialMapStore().isFood(player.getInventory().getItemInOffHand().getType())) { + } else if(pluginRef.getMaterialMapStore().isFood(player.getInventory().getItemInOffHand().getType())) { foodInHand = player.getInventory().getItemInOffHand().getType(); } else { return; //Not Food @@ -946,7 +944,7 @@ public class EntityListener implements Listener { return; } - if (mcMMO.getConfigManager().getConfigExploitPrevention().doTamedEntitiesGiveXP()) + if (pluginRef.getConfigManager().getConfigExploitPrevention().doTamedEntitiesGiveXP()) entity.setMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY, MetadataConstants.metadataValue); //Profile not loaded diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index 6fba3e1b0..b6d7a4cf5 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -11,7 +11,6 @@ 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.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; import org.bukkit.Material; import org.bukkit.block.Block; @@ -199,7 +198,7 @@ public class InventoryListener implements Listener { if (furnaceBlock != null) { if (furnaceBlock.getMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY).size() > 0) - furnaceBlock.removeMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, mcMMO.p); + furnaceBlock.removeMetadata(MetadataConstants.FURNACE_TRACKING_METAKEY, pluginRef); //Profile not loaded if (UserManager.getPlayer(player) == null) { diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 91d8893d8..dad66ce2f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.listeners; import com.gmail.nossr50.chat.ChatManager; -import com.gmail.nossr50.chat.ChatManagerFactory; -import com.gmail.nossr50.chat.PartyChatManager; import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.WorldBlacklist; import com.gmail.nossr50.core.MetadataConstants; @@ -12,7 +10,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; @@ -30,7 +27,6 @@ import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; -import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -51,10 +47,10 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; public class PlayerListener implements Listener { - private final mcMMO plugin; + private final mcMMO pluginRef; - public PlayerListener(final mcMMO plugin) { - this.plugin = plugin; + public PlayerListener(final mcMMO pluginRef) { + this.pluginRef = pluginRef; } /** @@ -76,7 +72,7 @@ public class PlayerListener implements Listener { /* WORLD GUARD MAIN FLAG CHECK */ if (WorldGuardUtils.isWorldGuardLoaded()) { - if (!plugin.getWorldGuardManager().hasMainFlag(player)) + if (!pluginRef.getWorldGuardManager().hasMainFlag(player)) return; } @@ -89,7 +85,7 @@ public class PlayerListener implements Listener { return; } - if (mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) + if (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) UserManager.getPlayer(player).actualizeTeleportATS(); @@ -115,7 +111,7 @@ public class PlayerListener implements Listener { /* WORLD GUARD MAIN FLAG CHECK */ if (WorldGuardUtils.isWorldGuardLoaded()) { - if (!plugin.getWorldGuardManager().hasMainFlag(event.getEntity())) + if (!pluginRef.getWorldGuardManager().hasMainFlag(event.getEntity())) return; } @@ -160,7 +156,7 @@ public class PlayerListener implements Listener { /* WORLD GUARD MAIN FLAG CHECK */ if (WorldGuardUtils.isWorldGuardLoaded()) { - if (!plugin.getWorldGuardManager().hasMainFlag(killedPlayer)) + if (!pluginRef.getWorldGuardManager().hasMainFlag(killedPlayer)) return; } @@ -224,7 +220,7 @@ public class PlayerListener implements Listener { /* WORLD GUARD MAIN FLAG CHECK */ if (WorldGuardUtils.isWorldGuardLoaded()) { - if (!plugin.getWorldGuardManager().hasMainFlag(event.getPlayer())) + if (!pluginRef.getWorldGuardManager().hasMainFlag(event.getPlayer())) return; } @@ -256,7 +252,7 @@ public class PlayerListener implements Listener { /* WORLD GUARD MAIN FLAG CHECK */ if (WorldGuardUtils.isWorldGuardLoaded()) { - if (!plugin.getWorldGuardManager().hasMainFlag(player)) + if (!pluginRef.getWorldGuardManager().hasMainFlag(player)) return; } @@ -276,7 +272,7 @@ public class PlayerListener implements Listener { //TODO Update to new API once available! Waiting for case CAUGHT_TREASURE: Item fishingCatch = (Item) event.getCaught(); - if (mcMMO.getConfigManager().getConfigFishing().isOverrideVanillaTreasures()) { + if (pluginRef.getConfigManager().getConfigFishing().isOverrideVanillaTreasures()) { if (fishingCatch.getItemStack().getType() != Material.SALMON && fishingCatch.getItemStack().getType() != Material.COD && fishingCatch.getItemStack().getType() != Material.TROPICAL_FISH && @@ -331,7 +327,7 @@ public class PlayerListener implements Listener { /* WORLD GUARD MAIN FLAG CHECK */ if (WorldGuardUtils.isWorldGuardLoaded()) { - if (!plugin.getWorldGuardManager().hasMainFlag(player)) + if (!pluginRef.getWorldGuardManager().hasMainFlag(player)) return; } @@ -348,7 +344,7 @@ public class PlayerListener implements Listener { FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager(); //Track the hook - if (mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits()) { + if (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits()) { if (event.getHook().getMetadata(MetadataConstants.FISH_HOOK_REF_METAKEY).size() == 0) { fishingManager.setFishHookReference(event.getHook()); } @@ -381,9 +377,9 @@ public class PlayerListener implements Listener { } return; case CAUGHT_FISH: - if (mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits()) { + if (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits()) { if (fishingManager.isExploitingFishing(event.getHook().getLocation().toVector())) { - player.sendMessage(LocaleLoader.getString("Fishing.ScarcityTip", mcMMO.getConfigManager().getConfigExploitPrevention().getOverFishingAreaSize() * 2)); + player.sendMessage(pluginRef.getLocaleManager().getString("Fishing.ScarcityTip", pluginRef.getConfigManager().getConfigExploitPrevention().getOverFishingAreaSize() * 2)); event.setExpToDrop(0); Item caughtItem = (Item) caught; caughtItem.remove(); @@ -424,7 +420,7 @@ public class PlayerListener implements Listener { /* WORLD GUARD MAIN FLAG CHECK */ if (WorldGuardUtils.isWorldGuardLoaded()) { - if (!plugin.getWorldGuardManager().hasMainFlag(player)) + if (!pluginRef.getWorldGuardManager().hasMainFlag(player)) return; } @@ -443,7 +439,7 @@ public class PlayerListener implements Listener { //Remove tracking ItemStack dropStack = drop.getItemStack(); if(drop.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY)) { - drop.removeMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, mcMMO.p); + drop.removeMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, pluginRef); } if (drop.hasMetadata(MetadataConstants.DISARMED_ITEM_METAKEY)) { @@ -516,23 +512,23 @@ public class PlayerListener implements Listener { Player player = event.getPlayer(); //Delay loading for 3 seconds in case the player has a save task running, its hacky but it should do the trick - new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 60); + new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(pluginRef, 60); - if (mcMMO.getConfigManager().getConfigMOTD().isEnableMOTD()) { + if (pluginRef.getConfigManager().getConfigMOTD().isEnableMOTD()) { Motd.displayAll(player); } - if (plugin.isXPEventEnabled()) { - player.sendMessage(LocaleLoader.getString("XPRate.Event", mcMMO.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult())); + if (pluginRef.isXPEventEnabled()) { + player.sendMessage(pluginRef.getLocaleManager().getString("XPRate.Event", pluginRef.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult())); } //TODO: Remove this warning after 2.2 is done - if (mcMMO.p.getDescription().getVersion().contains("SNAPSHOT")) { + if (pluginRef.getDescription().getVersion().contains("SNAPSHOT")) { event.getPlayer().sendMessage(ChatColor.RED + "WARNING: " + ChatColor.WHITE + "This dev build version of mcMMO is in the MIDDLE of completely rewriting the configs, there may be game breaking bugs. It is not recommended to play on this version of mcMMO, please grab the latest stable release from https://www.mcmmo.org and use that instead!"); } - if (plugin.isXPEventEnabled() && mcMMO.getConfigManager().getConfigEvent().isShowXPRateInfoOnPlayerJoin()) { - player.sendMessage(LocaleLoader.getString("XPRate.Event", mcMMO.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult())); + if (pluginRef.isXPEventEnabled() && pluginRef.getConfigManager().getConfigEvent().isShowXPRateInfoOnPlayerJoin()) { + player.sendMessage(pluginRef.getLocaleManager().getString("XPRate.Event", pluginRef.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult())); } } @@ -576,7 +572,7 @@ public class PlayerListener implements Listener { /* WORLD GUARD MAIN FLAG CHECK */ if (WorldGuardUtils.isWorldGuardLoaded()) { - if (!plugin.getWorldGuardManager().hasMainFlag(player)) + if (!pluginRef.getWorldGuardManager().hasMainFlag(player)) return; } @@ -598,11 +594,11 @@ public class PlayerListener implements Listener { case RIGHT_CLICK_BLOCK: Material type = block.getType(); - if (!mcMMO.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { + if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { /* REPAIR CHECKS */ if (type == Repair.getInstance().getAnvilMaterial() && PrimarySkillType.REPAIR.getPermissions(player) - && mcMMO.getRepairableManager().isRepairable(heldItem) + && pluginRef.getRepairableManager().isRepairable(heldItem) && heldItem.getAmount() <= 1) { RepairManager repairManager = mcMMOPlayer.getRepairManager(); event.setCancelled(true); @@ -617,7 +613,7 @@ public class PlayerListener implements Listener { else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR) - && mcMMO.getSalvageableManager().isSalvageable(heldItem) + && pluginRef.getSalvageableManager().isSalvageable(heldItem) && heldItem.getAmount() <= 1) { SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager(); event.setCancelled(true); @@ -644,25 +640,25 @@ public class PlayerListener implements Listener { case LEFT_CLICK_BLOCK: type = block.getType(); - if (!mcMMO.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { + if (!pluginRef.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) { /* REPAIR CHECKS */ - if (type == Repair.getInstance().getAnvilMaterial() && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) { + if (type == Repair.getInstance().getAnvilMaterial() && PrimarySkillType.REPAIR.getPermissions(player) && pluginRef.getRepairableManager().isRepairable(heldItem)) { RepairManager repairManager = mcMMOPlayer.getRepairManager(); // Cancel repairing an enchanted item if (repairManager.checkConfirmation(false)) { repairManager.setLastAnvilUse(0); - player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name"))); + player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Cancelled", pluginRef.getLocaleManager().getString("Repair.Pretty.Name"))); } } /* SALVAGE CHECKS */ - else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) { + else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player) && pluginRef.getSalvageableManager().isSalvageable(heldItem)) { SalvageManager salvageManager = mcMMOPlayer.getSalvageManager(); // Cancel salvaging an enchanted item if (salvageManager.checkConfirmation(false)) { salvageManager.setLastAnvilUse(0); - player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name"))); + player.sendMessage(pluginRef.getLocaleManager().getString("Skills.Cancelled", pluginRef.getLocaleManager().getString("Salvage.Pretty.Name"))); } } } @@ -689,7 +685,7 @@ public class PlayerListener implements Listener { /* WORLD GUARD MAIN FLAG CHECK */ if (WorldGuardUtils.isWorldGuardLoaded()) { - if (!plugin.getWorldGuardManager().hasMainFlag(player)) + if (!pluginRef.getWorldGuardManager().hasMainFlag(player)) return; } @@ -706,7 +702,7 @@ public class PlayerListener implements Listener { ItemStack heldItem = player.getInventory().getItemInMainHand(); //Spam Fishing Detection - if (mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits()) { + if (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitFishing().isPreventFishingExploits()) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) { if (player.isInsideVehicle() && (player.getVehicle() instanceof Minecart || player.getVehicle() instanceof PoweredMinecart)) { player.getVehicle().eject(); @@ -729,7 +725,7 @@ public class PlayerListener implements Listener { /* ACTIVATION & ITEM CHECKS */ if (BlockUtils.canActivateTools(blockState)) { - if (mcMMO.getConfigManager().getConfigSuperAbilities().isSuperAbilitiesEnabled()) { + if (pluginRef.getConfigManager().getConfigSuperAbilities().isSuperAbilitiesEnabled()) { if (BlockUtils.canActivateHerbalism(blockState)) { mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM); } @@ -756,7 +752,7 @@ public class PlayerListener implements Listener { case WHEAT: case NETHER_WART_BLOCK: case POTATO: - mcMMO.getPlaceStore().setFalse(blockState); + pluginRef.getPlaceStore().setFalse(blockState); } } @@ -784,7 +780,7 @@ public class PlayerListener implements Listener { } /* ACTIVATION CHECKS */ - if (mcMMO.getConfigManager().getConfigSuperAbilities().isSuperAbilitiesEnabled()) { + if (pluginRef.getConfigManager().getConfigSuperAbilities().isSuperAbilitiesEnabled()) { mcMMOPlayer.processAbilityActivation(PrimarySkillType.AXES); mcMMOPlayer.processAbilityActivation(PrimarySkillType.EXCAVATION); mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM); @@ -847,8 +843,8 @@ public class PlayerListener implements Listener { McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(player); if (mcMMOPlayer == null) { - mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server."); - mcMMO.p.debug("Party & Admin chat will not work properly for this player."); + pluginRef.debug(player.getName() + "is chatting, but is currently not logged in to the server."); + pluginRef.debug("Party & Admin chat will not work properly for this player."); return; } @@ -859,18 +855,14 @@ public class PlayerListener implements Listener { if (party == null) { mcMMOPlayer.disableChat(ChatMode.PARTY); - player.sendMessage(LocaleLoader.getString("Commands.Party.None")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.None")); return; } - chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY); - ((PartyChatManager) chatManager).setParty(party); + pluginRef.getChatManager().processPartyChat(party, player, event.getMessage()); + event.setCancelled(true); } else if (mcMMOPlayer.isChatEnabled(ChatMode.ADMIN)) { - chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN); - } - - if (chatManager != null) { - chatManager.handleChat(player, event.getMessage(), event.isAsynchronous()); + pluginRef.getChatManager().processAdminChat(player, event.getMessage()); event.setCancelled(true); } } @@ -882,7 +874,7 @@ public class PlayerListener implements Listener { */ @EventHandler(priority = EventPriority.LOWEST) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { - if (!mcMMO.getConfigManager().getConfigLanguage().getTargetLanguage().equalsIgnoreCase("en_US")) { + if (!pluginRef.getConfigManager().getConfigLanguage().getTargetLanguage().equalsIgnoreCase("en_US")) { String message = event.getMessage(); String command = message.substring(1).split(" ")[0]; String lowerCaseCommand = command.toLowerCase(); diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index 5d31db229..0f608b886 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -11,7 +11,6 @@ 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.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -41,7 +40,7 @@ public class SelfListener implements Listener { //Reset the delay timer RankUtils.resetUnlockDelayTimer(); - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled()) + if (pluginRef.getScoreboardSettings().getScoreboardsEnabled()) ScoreboardManager.handleLevelUp(player, skill); /*if ((event.getSkillLevel() % Config.getInstance().getLevelUpEffectsTier()) == 0) { @@ -51,13 +50,13 @@ public class SelfListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerXp(McMMOPlayerXpGainEvent event) { - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled()) + if (pluginRef.getScoreboardSettings().getScoreboardsEnabled()) ScoreboardManager.handleXp(event.getPlayer(), event.getSkill()); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onAbility(McMMOPlayerAbilityActivateEvent event) { - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled()) + if (pluginRef.getScoreboardSettings().getScoreboardsEnabled()) ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill()); } @@ -84,7 +83,7 @@ public class SelfListener implements Listener { return; } - if (mcMMO.getConfigManager().getConfigLeveling().isEnableEarlyGameBoost()) { + if (pluginRef.getConfigManager().getConfigLeveling().isEnableEarlyGameBoost()) { int earlyGameBonusXP = 0; @@ -96,9 +95,9 @@ public class SelfListener implements Listener { } } - int threshold = mcMMO.getConfigManager().getConfigLeveling().getSkillThreshold(primarySkillType); + int threshold = pluginRef.getConfigManager().getConfigLeveling().getSkillThreshold(primarySkillType); - if (threshold <= 0 || !mcMMO.getConfigManager().getConfigLeveling().getConfigLevelingDiminishedReturns().isDiminishedReturnsEnabled()) { + if (threshold <= 0 || !pluginRef.getConfigManager().getConfigLeveling().getConfigLevelingDiminishedReturns().isDiminishedReturnsEnabled()) { // Diminished returns is turned off return; } @@ -114,9 +113,9 @@ public class SelfListener implements Listener { final double rawXp = event.getRawXpGained(); - double guaranteedMinimum = mcMMO.getConfigManager().getConfigLeveling().getGuaranteedMinimums() * rawXp; + double guaranteedMinimum = pluginRef.getConfigManager().getConfigLeveling().getGuaranteedMinimums() * rawXp; - double modifiedThreshold = (double) (threshold / primarySkillType.getXpModifier() * mcMMO.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()); + double modifiedThreshold = (double) (threshold / primarySkillType.getXpModifier() * pluginRef.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()); double difference = (mcMMOPlayer.getProfile().getRegisteredXpGain(primarySkillType) - modifiedThreshold) / modifiedThreshold; if (difference > 0) { diff --git a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java index 2ae1a0769..a9f3d569e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/WorldListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/WorldListener.java @@ -33,12 +33,12 @@ public class WorldListener implements Listener { if (WorldBlacklist.isWorldBlacklisted(event.getWorld())) return; - if (!mcMMO.getPlaceStore().isTrue(event.getLocation().getBlock())) { + if (!pluginRef.getPlaceStore().isTrue(event.getLocation().getBlock())) { return; } for (BlockState blockState : event.getBlocks()) { - mcMMO.getPlaceStore().setFalse(blockState); + pluginRef.getPlaceStore().setFalse(blockState); } } @@ -75,7 +75,7 @@ public class WorldListener implements Listener { if (WorldBlacklist.isWorldBlacklisted(event.getWorld())) return; - mcMMO.getPlaceStore().unloadWorld(event.getWorld()); + pluginRef.getPlaceStore().unloadWorld(event.getWorld()); } /** @@ -91,6 +91,6 @@ public class WorldListener implements Listener { Chunk chunk = event.getChunk(); - mcMMO.getPlaceStore().chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld()); + pluginRef.getPlaceStore().chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld()); } } diff --git a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java b/src/main/java/com/gmail/nossr50/locale/LocaleManager.java similarity index 75% rename from src/main/java/com/gmail/nossr50/locale/LocaleLoader.java rename to src/main/java/com/gmail/nossr50/locale/LocaleManager.java index 40b285fb2..4b84d495a 100644 --- a/src/main/java/com/gmail/nossr50/locale/LocaleLoader.java +++ b/src/main/java/com/gmail/nossr50/locale/LocaleManager.java @@ -12,40 +12,40 @@ import java.text.MessageFormat; import java.util.*; import java.util.logging.Level; -public final class LocaleLoader { - private static final String BUNDLE_ROOT = "com.gmail.nossr50.locale.locale"; - private static Map bundleCache = new HashMap<>(); - private static ResourceBundle bundle = null; - private static ResourceBundle filesystemBundle = null; - private static ResourceBundle enBundle = null; +public final class LocaleManager { + private final String BUNDLE_ROOT = "com.gmail.nossr50.locale.locale"; + private Map bundleCache = new HashMap<>(); + private ResourceBundle bundle; + private ResourceBundle filesystemBundle; + private ResourceBundle enBundle; + private mcMMO pluginRef; - private LocaleLoader() { + public LocaleManager(mcMMO pluginRef) { + this.pluginRef = pluginRef; + initialize(); } - public static String getString(String key) { + public String getString(String key) { return getString(key, (Object[]) null); } /** - * Gets the appropriate string from the Locale files. + * Gets the appropriate string from the LocaleManager files. * * @param key The key to look up the string with * @param messageArguments Any arguments to be added to the string * @return The properly formatted locale string */ - public static String getString(String key, Object... messageArguments) { - if (bundle == null) { - initialize(); - } + public String getString(String key, Object... messageArguments) { - String rawMessage = bundleCache.computeIfAbsent(key, LocaleLoader::getRawString); + String rawMessage = bundleCache.computeIfAbsent(key, this::getRawString); return formatString(rawMessage, messageArguments); } /** * Reloads locale */ - public static void reloadLocale() { + public void reloadLocale() { bundle = null; filesystemBundle = null; enBundle = null; @@ -53,7 +53,7 @@ public final class LocaleLoader { initialize(); } - private static String getRawString(String key) { + private String getRawString(String key) { if (filesystemBundle != null) { try { return filesystemBundle.getString(key); @@ -70,14 +70,14 @@ public final class LocaleLoader { return enBundle.getString(key); } catch (MissingResourceException ignored) { if (!key.contains("Guides")) { - mcMMO.p.getLogger().warning("Could not find locale string: " + key); + pluginRef.getLogger().warning("Could not find locale string: " + key); } return '!' + key + '!'; } } - public static String formatString(String string, Object... messageArguments) { + public String formatString(String string, Object... messageArguments) { if (messageArguments != null) { MessageFormat formatter = new MessageFormat(""); formatter.applyPattern(string.replace("'", "''")); @@ -89,40 +89,37 @@ public final class LocaleLoader { return string; } - public static Locale getCurrentLocale() { - if (bundle == null) { - initialize(); - } + public java.util.Locale getCurrentLocale() { return bundle.getLocale(); } - private static void initialize() { + private void initialize() { if (bundle == null) { - Locale.setDefault(new Locale("en", "US")); - Locale locale = null; - String[] myLocale = mcMMO.getConfigManager().getConfigLanguage().getTargetLanguage().split("[-_ ]"); + java.util.Locale.setDefault(new java.util.Locale("en", "US")); + java.util.Locale locale = null; + String[] myLocale = pluginRef.getConfigManager().getConfigLanguage().getTargetLanguage().split("[-_ ]"); if (myLocale.length == 1) { - locale = new Locale(myLocale[0]); + locale = new java.util.Locale(myLocale[0]); } else if (myLocale.length >= 2) { - locale = new Locale(myLocale[0], myLocale[1]); + locale = new java.util.Locale(myLocale[0], myLocale[1]); } if (locale == null) { - throw new IllegalStateException("Failed to parse locale string '" + mcMMO.getConfigManager().getConfigLanguage().getTargetLanguage() + "'"); + throw new IllegalStateException("Failed to parse locale string '" + pluginRef.getConfigManager().getConfigLanguage().getTargetLanguage() + "'"); } - Path localePath = Paths.get(mcMMO.getLocalesDirectory() + "locale_" + locale.toString() + ".properties"); + Path localePath = Paths.get(pluginRef.getLocalesDirectory() + "locale_" + locale.toString() + ".properties"); if (Files.exists(localePath) && Files.isRegularFile(localePath)) { try (Reader localeReader = Files.newBufferedReader(localePath)) { - mcMMO.p.getLogger().log(Level.INFO, "Loading locale from {0}", localePath); + pluginRef.getLogger().log(Level.INFO, "Loading locale from {0}", localePath); filesystemBundle = new PropertyResourceBundle(localeReader); } catch (IOException e) { - mcMMO.p.getLogger().log(Level.WARNING, "Failed to load locale from " + localePath, e); + pluginRef.getLogger().log(Level.WARNING, "Failed to load locale from " + localePath, e); } } bundle = ResourceBundle.getBundle(BUNDLE_ROOT, locale); - enBundle = ResourceBundle.getBundle(BUNDLE_ROOT, Locale.US); + enBundle = ResourceBundle.getBundle(BUNDLE_ROOT, java.util.Locale.US); } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 797a56d79..1e9bbd274 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -1,5 +1,6 @@ package com.gmail.nossr50; +import com.gmail.nossr50.chat.ChatManager; import com.gmail.nossr50.config.ConfigManager; import com.gmail.nossr50.config.hocon.database.ConfigSectionCleaning; import com.gmail.nossr50.config.hocon.database.ConfigSectionMySQL; @@ -14,6 +15,7 @@ import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.database.DatabaseManagerFactory; import com.gmail.nossr50.datatypes.skills.subskills.acrobatics.Roll; import com.gmail.nossr50.listeners.*; +import com.gmail.nossr50.locale.LocaleManager; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.runnables.SaveTimerTask; import com.gmail.nossr50.runnables.backups.CleanBackupsTask; @@ -53,8 +55,6 @@ import java.io.File; import java.io.IOException; public class mcMMO extends JavaPlugin { - // Jar Stuff - private File mcMMOFile; /* Managers */ private ChunkManager placeStore; private ConfigManager configManager; @@ -67,6 +67,9 @@ public class mcMMO extends JavaPlugin { private CommandRegistrationManager commandRegistrationManager; private NBTManager nbtManager; private WorldGuardManager worldGuardManager; + private PartyManager partyManager; + private LocaleManager localeManager; + private ChatManager chatManager; /* File Paths */ private String mainDirectory; @@ -88,11 +91,10 @@ public class mcMMO extends JavaPlugin { public void onEnable() { try { getLogger().setFilter(new LogFilter(this)); - MetadataConstants.metadataValue = new FixedMetadataValue(this, true); - PluginManager pluginManager = getServer().getPluginManager(); healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null; + localeManager = new LocaleManager(this); //upgradeManager = new UpgradeManager(); @@ -134,9 +136,7 @@ public class mcMMO extends JavaPlugin { registerEvents(); registerCoreSkills(); registerCustomRecipes(); - - if (getConfigManager().getConfigParty().isPartySystemEnabled()) - PartyManager.loadParties(); + initParties(); formulaManager = new FormulaManager(); @@ -188,6 +188,8 @@ public class mcMMO extends JavaPlugin { //Init Notification Manager notificationManager = new NotificationManager(); + + chatManager = new ChatManager(this); } @Override @@ -208,7 +210,7 @@ public class mcMMO extends JavaPlugin { try { UserManager.saveAll(); // Make sure to save player information if the server shuts down UserManager.clearAll(); - PartyManager.saveParties(); // Save our parties + getPartyManager().saveParties(); // Save our parties //TODO: Needed? if (getScoreboardSettings().getScoreboardsEnabled()) @@ -246,6 +248,13 @@ public class mcMMO extends JavaPlugin { debug("Was disabled."); // How informative! } + private void initParties() { + partyManager = new PartyManager(this); + + if (getConfigManager().getConfigParty().isPartySystemEnabled()) + getPartyManager().loadParties(); + } + public PlayerLevelUtils getPlayerLevelUtils() { return playerLevelUtils; } @@ -451,7 +460,6 @@ public class mcMMO extends JavaPlugin { * Setup the various storage file paths */ private void setupFilePaths() { - mcMMOFile = getFile(); mainDirectory = getDataFolder().getPath() + File.separator; localesDirectory = mainDirectory + "locales" + File.separator; flatFileDirectory = mainDirectory + "flatfile" + File.separator; @@ -600,4 +608,16 @@ public class mcMMO extends JavaPlugin { public WorldGuardManager getWorldGuardManager() { return worldGuardManager; } + + public PartyManager getPartyManager() { + return partyManager; + } + + public LocaleManager getLocaleManager() { + return localeManager; + } + + public ChatManager getChatManager() { + return chatManager; + } } diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 5ac45e2a6..70d377b08 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.events.party.McMMOPartyAllianceChangeEvent; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -26,11 +25,14 @@ import java.util.Map.Entry; import java.util.UUID; public final class PartyManager { - private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml"; - private static List parties = new ArrayList<>(); - private static File partyFile = new File(partiesFilePath); + private mcMMO pluginRef; + private List parties; + private File partyFile; - private PartyManager() { + public PartyManager(mcMMO pluginRef) { + this.pluginRef = pluginRef; + parties = new ArrayList<>(); + partyFile = new File(pluginRef.getFlatFileDirectory() + "parties.yml"); } /** @@ -39,11 +41,11 @@ public final class PartyManager { * @param partyFeature target party feature * @return the unlock level for the feature */ - public static int getPartyFeatureUnlockLevel(PartyFeature partyFeature) { - if (mcMMO.getDynamicSettingsManager().getPartyFeatureUnlocks().get(partyFeature) == null) + public int getPartyFeatureUnlockLevel(PartyFeature partyFeature) { + if (pluginRef.getDynamicSettingsManager().getPartyFeatureUnlocks().get(partyFeature) == null) return 0; else - return mcMMO.getDynamicSettingsManager().getPartyFeatureUnlocks().get(partyFeature); + return pluginRef.getDynamicSettingsManager().getPartyFeatureUnlocks().get(partyFeature); } /** @@ -53,12 +55,12 @@ public final class PartyManager { * @param partyName The name of the party to check * @return true if a party with that name exists, false otherwise */ - public static boolean checkPartyExistence(Player player, String partyName) { + public boolean checkPartyExistence(Player player, String partyName) { if (getParty(partyName) == null) { return false; } - player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", partyName)); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.AlreadyExists", partyName)); return true; } @@ -69,9 +71,9 @@ public final class PartyManager { * @param targetParty the target party * @return true if party is full and cannot be joined */ - public static boolean isPartyFull(Player player, Party targetParty) { + public boolean isPartyFull(Player player, Party targetParty) { return !Permissions.partySizeBypass(player) - && targetParty.getMembers().size() >= mcMMO.getConfigManager().getConfigParty().getPartySizeLimit(); + && targetParty.getMembers().size() >= pluginRef.getConfigManager().getConfigParty().getPartySizeLimit(); } /** @@ -81,7 +83,7 @@ public final class PartyManager { * @param newPartyName The name of the party being joined * @return true if the party was joined successfully, false otherwise */ - public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, String newPartyName) { + public boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, String newPartyName) { Player player = mcMMOPlayer.getPlayer(); if (mcMMOPlayer.inParty()) { @@ -104,9 +106,9 @@ public final class PartyManager { * @param secondPlayer The second player * @return true if they are in the same party, false otherwise */ - public static boolean inSameParty(Player firstPlayer, Player secondPlayer) { + public boolean inSameParty(Player firstPlayer, Player secondPlayer) { //If the party system is disabled, return false - if (!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled()) + if (!pluginRef.getConfigManager().getConfigParty().isPartySystemEnabled()) return false; //Profile not loaded @@ -129,9 +131,9 @@ public final class PartyManager { return firstParty.equals(secondParty); } - public static boolean areAllies(Player firstPlayer, Player secondPlayer) { + public boolean areAllies(Player firstPlayer, Player secondPlayer) { //If the party system is disabled, return false - if (!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled()) + if (!pluginRef.getConfigManager().getConfigParty().isPartySystemEnabled()) return false; //Profile not loaded @@ -160,13 +162,13 @@ public final class PartyManager { * @param mcMMOPlayer The player to check * @return the near party members */ - public static List getNearMembers(McMMOPlayer mcMMOPlayer) { + public List getNearMembers(McMMOPlayer mcMMOPlayer) { List nearMembers = new ArrayList<>(); Party party = mcMMOPlayer.getParty(); if (party != null) { Player player = mcMMOPlayer.getPlayer(); - double range = mcMMO.getPartyXPShareSettings().getPartyShareRange(); + double range = pluginRef.getPartyXPShareSettings().getPartyShareRange(); for (Player member : party.getOnlineMembers()) { if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) { @@ -178,13 +180,13 @@ public final class PartyManager { return nearMembers; } - public static List getNearVisibleMembers(McMMOPlayer mcMMOPlayer) { + public List getNearVisibleMembers(McMMOPlayer mcMMOPlayer) { List nearMembers = new ArrayList<>(); Party party = mcMMOPlayer.getParty(); if (party != null) { Player player = mcMMOPlayer.getPlayer(); - double range = mcMMO.getPartyXPShareSettings().getPartyShareRange(); + double range = pluginRef.getPartyXPShareSettings().getPartyShareRange(); for (Player member : party.getVisibleMembers(player)) { if (!player.equals(member) @@ -205,7 +207,7 @@ public final class PartyManager { * @param player The player to check * @return all the players in the player's party */ - public static LinkedHashMap getAllMembers(Player player) { + public LinkedHashMap getAllMembers(Player player) { Party party = getParty(player); return party == null ? new LinkedHashMap<>() : party.getMembers(); @@ -217,7 +219,7 @@ public final class PartyManager { * @param partyName The party to check * @return all online players in this party */ - public static List getOnlineMembers(String partyName) { + public List getOnlineMembers(String partyName) { return getOnlineMembers(getParty(partyName)); } @@ -227,11 +229,11 @@ public final class PartyManager { * @param player The player to check * @return all online players in this party */ - public static List getOnlineMembers(Player player) { + public List getOnlineMembers(Player player) { return getOnlineMembers(getParty(player)); } - private static List getOnlineMembers(Party party) { + private List getOnlineMembers(Party party) { return party == null ? new ArrayList<>() : party.getOnlineMembers(); } @@ -241,9 +243,9 @@ public final class PartyManager { * @param partyName The party name * @return the existing party, null otherwise */ - public static Party getParty(String partyName) { + public Party getParty(String partyName) { //If the party system is disabled, return null - if (!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled()) + if (!pluginRef.getConfigManager().getConfigParty().isPartySystemEnabled()) return null; for (Party party : parties) { @@ -262,9 +264,9 @@ public final class PartyManager { * @return the existing party, null otherwise */ @Deprecated - public static Party getPlayerParty(String playerName) { + public Party getPlayerParty(String playerName) { //If the party system is disabled, return null - if (!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled()) + if (!pluginRef.getConfigManager().getConfigParty().isPartySystemEnabled()) return null; for (Party party : parties) { @@ -282,9 +284,9 @@ public final class PartyManager { * @param uuid The members uuid * @return the existing party, null otherwise */ - public static Party getPlayerParty(String playerName, UUID uuid) { + public Party getPlayerParty(String playerName, UUID uuid) { //If the party system is disabled, return null - if (!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled()) + if (!pluginRef.getConfigManager().getConfigParty().isPartySystemEnabled()) return null; for (Party party : parties) { @@ -309,7 +311,7 @@ public final class PartyManager { * @param player The member * @return the existing party, null otherwise */ - public static Party getParty(Player player) { + public Party getParty(Player player) { //Profile not loaded if (UserManager.getPlayer(player) == null) { return null; @@ -325,7 +327,7 @@ public final class PartyManager { * * @return the list of parties. */ - public static List getParties() { + public List getParties() { return parties; } @@ -335,7 +337,7 @@ public final class PartyManager { * @param player The player to remove * @param party The party */ - public static void removeFromParty(OfflinePlayer player, Party party) { + public void removeFromParty(OfflinePlayer player, Party party) { LinkedHashMap members = party.getMembers(); String playerName = player.getName(); @@ -362,7 +364,7 @@ public final class PartyManager { * * @param mcMMOPlayer The player to remove */ - public static void removeFromParty(McMMOPlayer mcMMOPlayer) { + public void removeFromParty(McMMOPlayer mcMMOPlayer) { removeFromParty(mcMMOPlayer.getPlayer(), mcMMOPlayer.getParty()); processPartyLeaving(mcMMOPlayer); } @@ -372,7 +374,7 @@ public final class PartyManager { * * @param party The party to remove */ - public static void disbandParty(Party party) { + public void disbandParty(Party party) { //TODO: Potential issues with unloaded profile? for (Player member : party.getOnlineMembers()) { //Profile not loaded @@ -398,18 +400,18 @@ public final class PartyManager { * @param partyName The party to add the player to * @param password The password for this party, null if there was no password */ - public static void createParty(McMMOPlayer mcMMOPlayer, String partyName, String password) { + public void createParty(McMMOPlayer mcMMOPlayer, String partyName, String password) { Player player = mcMMOPlayer.getPlayer(); Party party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName.replace(".", ""), password); if (password != null) { - player.sendMessage(LocaleLoader.getString("Party.Password.Set", password)); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Password.Set", password)); } parties.add(party); - player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName())); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Create", party.getName())); addToParty(mcMMOPlayer, party); } @@ -421,22 +423,22 @@ public final class PartyManager { * @param password The password provided by the player * @return true if the player can join the party */ - public static boolean checkPartyPassword(Player player, Party party, String password) { + public boolean checkPartyPassword(Player player, Party party, String password) { if (party.isLocked()) { String partyPassword = party.getPassword(); if (partyPassword == null) { - player.sendMessage(LocaleLoader.getString("Party.Locked")); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Locked")); return false; } if (password == null) { - player.sendMessage(LocaleLoader.getString("Party.Password.None")); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Password.None")); return false; } if (!password.equals(partyPassword)) { - player.sendMessage(LocaleLoader.getString("Party.Password.Incorrect")); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Password.Incorrect")); return false; } } @@ -449,26 +451,26 @@ public final class PartyManager { * * @param mcMMOPlayer The player to add to the party */ - public static void joinInvitedParty(McMMOPlayer mcMMOPlayer) { + public void joinInvitedParty(McMMOPlayer mcMMOPlayer) { Party invite = mcMMOPlayer.getPartyInvite(); // Check if the party still exists, it might have been disbanded if (!parties.contains(invite)) { - mcMMO.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Party.Disband"); + pluginRef.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Party.Disband"); return; } /* * Don't let players join a full party */ - if (mcMMO.getConfigManager().getConfigParty().isPartySizeCapped() && invite.getMembers().size() >= mcMMO.getConfigManager().getConfigParty().getPartySizeLimit()) { - mcMMO.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), + if (pluginRef.getConfigManager().getConfigParty().isPartySizeCapped() && invite.getMembers().size() >= pluginRef.getConfigManager().getConfigParty().getPartySizeLimit()) { + pluginRef.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull.InviteAccept", - invite.getName(), String.valueOf(mcMMO.getConfigManager().getConfigParty().getPartySizeLimit())); + invite.getName(), String.valueOf(pluginRef.getConfigManager().getConfigParty().getPartySizeLimit())); return; } - mcMMO.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.Invite.Accepted", invite.getName()); + pluginRef.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.Invite.Accepted", invite.getName()); mcMMOPlayer.removePartyInvite(); addToParty(mcMMOPlayer, invite); } @@ -478,13 +480,13 @@ public final class PartyManager { * * @param mcMMOPlayer The player who accepts the alliance invite */ - public static void acceptAllianceInvite(McMMOPlayer mcMMOPlayer) { + public void acceptAllianceInvite(McMMOPlayer mcMMOPlayer) { Party invite = mcMMOPlayer.getPartyAllianceInvite(); Player player = mcMMOPlayer.getPlayer(); // Check if the party still exists, it might have been disbanded if (!parties.contains(invite)) { - player.sendMessage(LocaleLoader.getString("Party.Disband")); + player.sendMessage(pluginRef.getLocaleManager().getString("Party.Disband")); return; } @@ -492,43 +494,39 @@ public final class PartyManager { return; } - player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.Accepted", invite.getName())); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Party.Alliance.Invite.Accepted", invite.getName())); mcMMOPlayer.removePartyAllianceInvite(); createAlliance(mcMMOPlayer.getParty(), invite); } - public static void createAlliance(Party firstParty, Party secondParty) { + private void createAlliance(Party firstParty, Party secondParty) { firstParty.setAlly(secondParty); secondParty.setAlly(firstParty); for (Player member : firstParty.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Party.Alliance.Formed", secondParty.getName())); + member.sendMessage(pluginRef.getLocaleManager().getString("Party.Alliance.Formed", secondParty.getName())); } for (Player member : secondParty.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Party.Alliance.Formed", firstParty.getName())); + member.sendMessage(pluginRef.getLocaleManager().getString("Party.Alliance.Formed", firstParty.getName())); } } - public static void disbandAlliance(Player player, Party firstParty, Party secondParty) { + public void disbandAlliance(Player player, Party firstParty, Party secondParty) { if (!handlePartyChangeAllianceEvent(player, firstParty.getName(), secondParty.getName(), McMMOPartyAllianceChangeEvent.EventReason.DISBAND_ALLIANCE)) { return; } - PartyManager.disbandAlliance(firstParty, secondParty); - } - - private static void disbandAlliance(Party firstParty, Party secondParty) { firstParty.setAlly(null); secondParty.setAlly(null); for (Player member : firstParty.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Party.Alliance.Disband", secondParty.getName())); + member.sendMessage(pluginRef.getLocaleManager().getString("Party.Alliance.Disband", secondParty.getName())); } for (Player member : secondParty.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Party.Alliance.Disband", firstParty.getName())); + member.sendMessage(pluginRef.getLocaleManager().getString("Party.Alliance.Disband", firstParty.getName())); } } @@ -538,7 +536,7 @@ public final class PartyManager { * @param mcMMOPlayer The player to add to the party * @param party The party */ - public static void addToParty(McMMOPlayer mcMMOPlayer, Party party) { + public void addToParty(McMMOPlayer mcMMOPlayer, Party party) { Player player = mcMMOPlayer.getPlayer(); String playerName = player.getName(); @@ -554,7 +552,7 @@ public final class PartyManager { * @param partyName The party name * @return the leader of the party */ - public static String getPartyLeaderName(String partyName) { + public String getPartyLeaderName(String partyName) { Party party = getParty(partyName); return party == null ? null : party.getLeader().getPlayerName(); @@ -566,19 +564,19 @@ public final class PartyManager { * @param uuid The uuid of the player to set as leader * @param party The party */ - public static void setPartyLeader(UUID uuid, Party party) { - OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(uuid); + public void setPartyLeader(UUID uuid, Party party) { + OfflinePlayer player = pluginRef.getServer().getOfflinePlayer(uuid); UUID leaderUniqueId = party.getLeader().getUniqueId(); for (Player member : party.getOnlineMembers()) { UUID memberUniqueId = member.getUniqueId(); if (memberUniqueId.equals(player.getUniqueId())) { - member.sendMessage(LocaleLoader.getString("Party.Owner.Player")); + member.sendMessage(pluginRef.getLocaleManager().getString("Party.Owner.Player")); } else if (memberUniqueId.equals(leaderUniqueId)) { - member.sendMessage(LocaleLoader.getString("Party.Owner.NotLeader")); + member.sendMessage(pluginRef.getLocaleManager().getString("Party.Owner.NotLeader")); } else { - member.sendMessage(LocaleLoader.getString("Party.Owner.New", player.getName())); + member.sendMessage(pluginRef.getLocaleManager().getString("Party.Owner.New", player.getName())); } } @@ -590,7 +588,7 @@ public final class PartyManager { * * @return true if the player can invite */ - public static boolean canInvite(McMMOPlayer mcMMOPlayer) { + public boolean canInvite(McMMOPlayer mcMMOPlayer) { Party party = mcMMOPlayer.getParty(); return !party.isLocked() || party.getLeader().getUniqueId().equals(mcMMOPlayer.getPlayer().getUniqueId()); @@ -599,7 +597,7 @@ public final class PartyManager { /** * Load party file. */ - public static void loadParties() { + public void loadParties() { if (!partyFile.exists()) { return; } @@ -646,10 +644,10 @@ public final class PartyManager { parties.add(party); } - mcMMO.p.debug("Loaded (" + parties.size() + ") Parties..."); + pluginRef.debug("Loaded (" + parties.size() + ") Parties..."); for (Party party : hasAlly) { - party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally"))); + party.setAlly(getParty(partiesFile.getString(party.getName() + ".Ally"))); } } catch (Exception e) { @@ -661,17 +659,17 @@ public final class PartyManager { /** * Save party file. */ - public static void saveParties() { + public void saveParties() { if (partyFile.exists()) { if (!partyFile.delete()) { - mcMMO.p.getLogger().warning("Could not delete party file. Party saving failed!"); + pluginRef.getLogger().warning("Could not delete party file. Party saving failed!"); return; } } YamlConfiguration partiesFile = new YamlConfiguration(); - mcMMO.p.debug("Saving Parties... (" + parties.size() + ")"); + pluginRef.debug("Saving Parties... (" + parties.size() + ")"); for (Party party : parties) { String partyName = party.getName(); PartyLeader leader = party.getLeader(); @@ -771,7 +769,7 @@ public final class PartyManager { mcMMO.p.debug("Loaded (" + parties.size() + ") Parties..."); for (Party party : hasAlly) { - party.setAlly(PartyManager.getParty(partiesFile.getString(party.getName() + ".Ally"))); + party.setAlly(pluginRef.getPartyManager().getParty(partiesFile.getString(party.getName() + ".Ally"))); } //mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS_PARTY); @@ -786,9 +784,9 @@ public final class PartyManager { * @param reason The reason for changing parties * @return true if the change event was successful, false otherwise */ - public static boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) { + public boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) { McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, newPartyName, reason); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); return !event.isCancelled(); } @@ -802,9 +800,9 @@ public final class PartyManager { * @param reason The reason for changing allies * @return true if the change event was successful, false otherwise */ - public static boolean handlePartyChangeAllianceEvent(Player player, String oldAllyName, String newAllyName, McMMOPartyAllianceChangeEvent.EventReason reason) { + public boolean handlePartyChangeAllianceEvent(Player player, String oldAllyName, String newAllyName, McMMOPartyAllianceChangeEvent.EventReason reason) { McMMOPartyAllianceChangeEvent event = new McMMOPartyAllianceChangeEvent(player, oldAllyName, newAllyName, reason); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); return !event.isCancelled(); } @@ -814,7 +812,7 @@ public final class PartyManager { * * @param mcMMOPlayer The player to remove party data from. */ - public static void processPartyLeaving(McMMOPlayer mcMMOPlayer) { + public void processPartyLeaving(McMMOPlayer mcMMOPlayer) { mcMMOPlayer.removeParty(); mcMMOPlayer.disableChat(ChatMode.PARTY); mcMMOPlayer.setItemShareModifier(10); @@ -827,9 +825,9 @@ public final class PartyManager { * @param levelsGained The amount of levels gained * @param level The current party level */ - public static void informPartyMembersLevelUp(Party party, int levelsGained, int level) { + public void informPartyMembersLevelUp(Party party, int levelsGained, int level) { for (Player member : party.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level)); + member.sendMessage(pluginRef.getLocaleManager().getString("Party.LevelUp", levelsGained, level)); SoundManager.sendSound(member, member.getLocation(), SoundType.LEVEL_UP); } @@ -841,9 +839,9 @@ public final class PartyManager { * @param party The concerned party * @param playerName The name of the player that joined */ - private static void informPartyMembersJoin(Party party, String playerName) { + private void informPartyMembersJoin(Party party, String playerName) { for (Player member : party.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", playerName)); + member.sendMessage(pluginRef.getLocaleManager().getString("Party.InformedOnJoin", playerName)); } } @@ -853,9 +851,9 @@ public final class PartyManager { * @param party The concerned party * @param playerName The name of the player that left */ - private static void informPartyMembersQuit(Party party, String playerName) { + private void informPartyMembersQuit(Party party, String playerName) { for (Player member : party.getOnlineMembers()) { - member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", playerName)); + member.sendMessage(pluginRef.getLocaleManager().getString("Party.InformedOnQuit", playerName)); } } } diff --git a/src/main/java/com/gmail/nossr50/party/ShareHandler.java b/src/main/java/com/gmail/nossr50/party/ShareHandler.java index 672ceae58..bb51c20c8 100644 --- a/src/main/java/com/gmail/nossr50/party/ShareHandler.java +++ b/src/main/java/com/gmail/nossr50/party/ShareHandler.java @@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.ShareMode; 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; @@ -36,7 +35,7 @@ public final class ShareHandler { return false; } - List nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer); + List nearMembers = pluginRef.getPartyManager().getNearVisibleMembers(mcMMOPlayer); if (nearMembers.isEmpty()) { return false; @@ -45,9 +44,9 @@ public final class ShareHandler { nearMembers.add(mcMMOPlayer.getPlayer()); int partySize = nearMembers.size(); - double shareBonus = Math.min(mcMMO.getPartyXPShareSettings().getPartyShareXPBonusBase() - + (partySize * mcMMO.getPartyXPShareSettings().getPartyShareBonusIncrease()), - mcMMO.getPartyXPShareSettings().getPartyShareBonusCap()); + double shareBonus = Math.min(pluginRef.getPartyXPShareSettings().getPartyShareXPBonusBase() + + (partySize * pluginRef.getPartyXPShareSettings().getPartyShareBonusIncrease()), + pluginRef.getPartyXPShareSettings().getPartyShareBonusCap()); double splitXp = (double) (xp / partySize * shareBonus); for (Player member : nearMembers) { @@ -89,7 +88,7 @@ public final class ShareHandler { return false; } - List nearMembers = PartyManager.getNearMembers(mcMMOPlayer); + List nearMembers = pluginRef.getPartyManager().getNearMembers(mcMMOPlayer); if (nearMembers.isEmpty()) { return false; @@ -158,10 +157,10 @@ public final class ShareHandler { } public static int getItemWeight(Material material) { - if (mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(material) == null) + if (pluginRef.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(material) == null) return 5; else - return mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(material); + return pluginRef.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(material); } public static XPGainReason getSharedXpGainReason(XPGainReason xpGainReason) { diff --git a/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java b/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java index 47fcf867f..12958110c 100644 --- a/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/MobHealthDisplayUpdaterTask.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.runnables; import com.gmail.nossr50.core.MetadataConstants; -import com.gmail.nossr50.mcMMO; import org.bukkit.entity.LivingEntity; import org.bukkit.scheduler.BukkitRunnable; @@ -23,8 +22,8 @@ public class MobHealthDisplayUpdaterTask extends BukkitRunnable { if (target != null && target.isValid()) { target.setCustomNameVisible(oldNameVisible); target.setCustomName(oldName); - target.removeMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, mcMMO.p); - target.removeMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, mcMMO.p); + target.removeMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, pluginRef); + target.removeMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, pluginRef); } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java b/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java index 4529b696f..9b138b2df 100644 --- a/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/PistonTrackerTask.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.runnables; import com.gmail.nossr50.core.MetadataConstants; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.BlockUtils; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -27,19 +26,19 @@ public class PistonTrackerTask extends BukkitRunnable { return; } - if (mcMMO.getPlaceStore().isTrue(futureEmptyBlock)) { - mcMMO.getPlaceStore().setFalse(futureEmptyBlock); + if (pluginRef.getPlaceStore().isTrue(futureEmptyBlock)) { + pluginRef.getPlaceStore().setFalse(futureEmptyBlock); } for (Block b : blocks) { Block nextBlock = b.getRelative(direction); if (nextBlock.hasMetadata(MetadataConstants.PISTON_TRACKING_METAKEY)) { - mcMMO.getPlaceStore().setTrue(nextBlock); - nextBlock.removeMetadata(MetadataConstants.PISTON_TRACKING_METAKEY, mcMMO.p); - } else if (mcMMO.getPlaceStore().isTrue(nextBlock)) { + pluginRef.getPlaceStore().setTrue(nextBlock); + nextBlock.removeMetadata(MetadataConstants.PISTON_TRACKING_METAKEY, pluginRef); + } else if (pluginRef.getPlaceStore().isTrue(nextBlock)) { // Block doesn't have metadatakey but isTrue - set it to false - mcMMO.getPlaceStore().setFalse(nextBlock); + pluginRef.getPlaceStore().setFalse(nextBlock); } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java index 2e679b824..a6ea0c5bf 100644 --- a/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/SaveTimerTask.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.runnables; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.scheduler.BukkitRunnable; @@ -14,10 +12,10 @@ public class SaveTimerTask extends BukkitRunnable { int count = 1; for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) { - new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false).runTaskLaterAsynchronously(mcMMO.p, count); + new PlayerProfileSaveTask(mcMMOPlayer.getProfile(), false).runTaskLaterAsynchronously(pluginRef, count); count++; } - PartyManager.saveParties(); + pluginRef.getPartyManager().saveParties(); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java index 00062659b..3b6d2d26b 100644 --- a/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/StickyPistonTrackerTask.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.runnables; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.BlockUtils; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -19,7 +18,7 @@ public class StickyPistonTrackerTask extends BukkitRunnable { @Override public void run() { - if (!mcMMO.getPlaceStore().isTrue(movedBlock.getRelative(direction))) { + if (!pluginRef.getPlaceStore().isTrue(movedBlock.getRelative(direction))) { return; } @@ -29,7 +28,7 @@ public class StickyPistonTrackerTask extends BukkitRunnable { } // The sticky piston actually pulled the block so move the PlaceStore data - mcMMO.getPlaceStore().setFalse(movedBlock.getRelative(direction)); - mcMMO.getPlaceStore().setTrue(movedBlock); + pluginRef.getPlaceStore().setFalse(movedBlock.getRelative(direction)); + pluginRef.getPlaceStore().setTrue(movedBlock); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java index 09c215d41..426ec7b35 100644 --- a/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/backups/CleanBackupsTask.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.runnables.backups; -import com.gmail.nossr50.mcMMO; import org.bukkit.scheduler.BukkitRunnable; import java.io.File; @@ -13,7 +12,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; public class CleanBackupsTask extends BukkitRunnable { - private static final String BACKUP_DIRECTORY = mcMMO.getMainDirectory() + "backup" + File.separator; + private static final String BACKUP_DIRECTORY = pluginRef.getMainDirectory() + "backup" + File.separator; private static final File BACKUP_DIR = new File(BACKUP_DIRECTORY); @Override @@ -23,7 +22,7 @@ public class CleanBackupsTask extends BukkitRunnable { List toDelete = new ArrayList<>(); int amountTotal = 0; int amountDeleted = 0; - int oldFileAgeLimit = mcMMO.getConfigManager().getConfigAutomatedBackups().getBackupDayLimit(); + int oldFileAgeLimit = pluginRef.getConfigManager().getConfigAutomatedBackups().getBackupDayLimit(); if (BACKUP_DIR.listFiles() == null) { return; @@ -46,7 +45,7 @@ public class CleanBackupsTask extends BukkitRunnable { Date date = getDate(fileName.split("[.]")[0]); if (!fileName.contains(".zip") || date == null) { - mcMMO.p.debug("Could not determine date for file: " + fileName); + pluginRef.debug("Could not determine date for file: " + fileName); continue; } @@ -66,11 +65,11 @@ public class CleanBackupsTask extends BukkitRunnable { return; } - mcMMO.p.getLogger().info("Cleaned backup files. Deleted " + amountDeleted + " of " + amountTotal + " files."); + pluginRef.getLogger().info("Cleaned backup files. Deleted " + amountDeleted + " of " + amountTotal + " files."); for (File file : toDelete) { if (file.delete()) { - mcMMO.p.debug("Deleted: " + file.getName()); + pluginRef.debug("Deleted: " + file.getName()); } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java index 7311b50bf..4beb32424 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandAsyncTask.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.runnables.commands; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.mcMMO; import org.apache.commons.lang.Validate; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -30,9 +29,9 @@ public class McrankCommandAsyncTask extends BukkitRunnable { @Override public void run() { - Map skills = mcMMO.getDatabaseManager().readRank(playerName); + Map skills = pluginRef.getDatabaseManager().readRank(playerName); - new McrankCommandDisplayTask(skills, sender, playerName, useBoard, useChat).runTaskLater(mcMMO.p, 1); + new McrankCommandDisplayTask(skills, sender, playerName, useBoard, useChat).runTaskLater(pluginRef, 1); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java index 8e2e2ead3..0a55068c0 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java @@ -2,8 +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.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -30,22 +28,22 @@ public class McrankCommandDisplayTask extends BukkitRunnable { @Override public void run() { - if (useBoard && mcMMO.getScoreboardSettings().getScoreboardsEnabled()) { + if (useBoard && pluginRef.getScoreboardSettings().getScoreboardsEnabled()) { displayBoard(); } if (useChat) { displayChat(); } - ((Player) sender).removeMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, mcMMO.p); + ((Player) sender).removeMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, pluginRef); } private void displayChat() { // Player player = mcMMO.p.getServer().getPlayerExact(playerName); Integer rank; - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading")); - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName)); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcrank.Heading")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcrank.Player", playerName)); for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) { // if (!skill.getPermissions(player)) { @@ -53,11 +51,11 @@ public class McrankCommandDisplayTask extends BukkitRunnable { // } rank = skills.get(skill); - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", skill.getName(), (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank))); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcrank.Skill", skill.getName(), (rank == null ? pluginRef.getLocaleManager().getString("Commands.mcrank.Unranked") : rank))); } rank = skills.get(null); - sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank))); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcrank.Overall", (rank == null ? pluginRef.getLocaleManager().getString("Commands.mcrank.Unranked") : rank))); } public void displayBoard() { diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java index 387175cf7..8d448f876 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandAsyncTask.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.runnables.commands; import com.gmail.nossr50.datatypes.database.PlayerStat; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.mcMMO; import org.apache.commons.lang.Validate; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -33,8 +32,8 @@ public class MctopCommandAsyncTask extends BukkitRunnable { @Override public void run() { - final List userStats = mcMMO.getDatabaseManager().readLeaderboard(skill, page, 10); + final List userStats = pluginRef.getDatabaseManager().readLeaderboard(skill, page, 10); - new MctopCommandDisplayTask(userStats, page, skill, sender, useBoard, useChat).runTaskLater(mcMMO.p, 1); + new MctopCommandDisplayTask(userStats, page, skill, sender, useBoard, useChat).runTaskLater(pluginRef, 1); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java index 3a684b2c0..01a76888c 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java @@ -3,8 +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.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -34,7 +32,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable { @Override public void run() { - if (useBoard && mcMMO.getScoreboardSettings().getScoreboardsEnabled()) { + if (useBoard && pluginRef.getScoreboardSettings().getScoreboardsEnabled()) { displayBoard(); } @@ -43,25 +41,25 @@ public class MctopCommandDisplayTask extends BukkitRunnable { } if (sender instanceof Player) { - ((Player) sender).removeMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, mcMMO.p); + ((Player) sender).removeMetadata(MetadataConstants.DATABASE_PROCESSING_COMMAND_METAKEY, pluginRef); } if (sender instanceof Player) - sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mctop.Tip")); } private void displayChat() { if (skill == null) { if (sender instanceof Player) { - sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel.Leaderboard")); } else { - sender.sendMessage(ChatColor.stripColor(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"))); + sender.sendMessage(ChatColor.stripColor(pluginRef.getLocaleManager().getString("Commands.PowerLevel.Leaderboard"))); } } else { if (sender instanceof Player) { - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName())); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Skill.Leaderboard", skill.getName())); } else { - sender.sendMessage(ChatColor.stripColor(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName()))); + sender.sendMessage(ChatColor.stripColor(pluginRef.getLocaleManager().getString("Commands.Skill.Leaderboard", skill.getName()))); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java index 1f347bac4..1c25cf313 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/NotifySquelchReminderTask.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.runnables.commands; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -13,7 +12,7 @@ public class NotifySquelchReminderTask extends BukkitRunnable { for (Player player : Bukkit.getOnlinePlayers()) { if (UserManager.getPlayer(player) != null) { if (!UserManager.getPlayer(player).useChatNotifications()) { - player.sendMessage(LocaleLoader.getString("Reminder.Squelched")); + player.sendMessage(pluginRef.getLocaleManager().getString("Reminder.Squelched")); } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java index 0089ee677..9333fdeab 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/DatabaseConversionTask.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.runnables.database; import com.gmail.nossr50.database.DatabaseManager; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import org.bukkit.command.CommandSender; import org.bukkit.scheduler.BukkitRunnable; @@ -14,13 +12,13 @@ public class DatabaseConversionTask extends BukkitRunnable { public DatabaseConversionTask(DatabaseManager sourceDatabase, CommandSender sender, String oldType, String newType) { this.sourceDatabase = sourceDatabase; this.sender = sender; - message = LocaleLoader.getString("Commands.mcconvert.Database.Finish", oldType, newType); + message = pluginRef.getLocaleManager().getString("Commands.mcconvert.Database.Finish", oldType, newType); } @Override public void run() { - sourceDatabase.convertUsers(mcMMO.getDatabaseManager()); + sourceDatabase.convertUsers(pluginRef.getDatabaseManager()); - mcMMO.p.getServer().getScheduler().runTask(mcMMO.p, () -> sender.sendMessage(message)); + pluginRef.getServer().getScheduler().runTask(pluginRef, () -> sender.sendMessage(message)); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java index e17f1d715..64d04baef 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/FormulaConversionTask.java @@ -5,8 +5,6 @@ import com.gmail.nossr50.datatypes.experience.FormulaType; 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.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.CommandSender; @@ -25,16 +23,16 @@ public class FormulaConversionTask extends BukkitRunnable { public void run() { int convertedUsers = 0; long startMillis = System.currentTimeMillis(); - for (String playerName : mcMMO.getDatabaseManager().getStoredUsers()) { + for (String playerName : pluginRef.getDatabaseManager().getStoredUsers()) { McMMOPlayer mcMMOPlayer = UserManager.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. if (mcMMOPlayer == null) { - profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); + profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, false); if (!profile.isLoaded()) { - mcMMO.p.debug("Profile not loaded."); + pluginRef.debug("Profile not loaded."); continue; } @@ -49,36 +47,36 @@ public class FormulaConversionTask extends BukkitRunnable { Misc.printProgress(convertedUsers, DatabaseManager.progressInterval, startMillis); } - sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Finish", mcMMO.getConfigManager().getConfigLeveling().getConfigExperienceFormula().toString())); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.mcconvert.Experience.Finish", pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceFormula().toString())); } private void editValues(PlayerProfile profile) { - mcMMO.p.debug("========================================================================"); - mcMMO.p.debug("Conversion report for " + profile.getPlayerName() + ":"); + pluginRef.debug("========================================================================"); + pluginRef.debug("Conversion report for " + profile.getPlayerName() + ":"); for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { int oldLevel = profile.getSkillLevel(primarySkillType); int oldXPLevel = profile.getSkillXpLevel(primarySkillType); - int totalOldXP = mcMMO.getFormulaManager().calculateTotalExperience(oldLevel, oldXPLevel, previousFormula); + int totalOldXP = pluginRef.getFormulaManager().calculateTotalExperience(oldLevel, oldXPLevel, previousFormula); if (totalOldXP == 0) { continue; } - int[] newExperienceValues = mcMMO.getFormulaManager().calculateNewLevel(primarySkillType, (int) Math.floor(totalOldXP / 1.0)); + int[] newExperienceValues = pluginRef.getFormulaManager().calculateNewLevel(primarySkillType, (int) Math.floor(totalOldXP / 1.0)); int newLevel = newExperienceValues[0]; int newXPlevel = newExperienceValues[1]; - mcMMO.p.debug(" Skill: " + primarySkillType.toString()); + pluginRef.debug(" Skill: " + primarySkillType.toString()); - mcMMO.p.debug(" OLD:"); - mcMMO.p.debug(" Level: " + oldLevel); - mcMMO.p.debug(" XP " + oldXPLevel); - mcMMO.p.debug(" Total XP " + totalOldXP); + pluginRef.debug(" OLD:"); + pluginRef.debug(" Level: " + oldLevel); + pluginRef.debug(" XP " + oldXPLevel); + pluginRef.debug(" Total XP " + totalOldXP); - mcMMO.p.debug(" NEW:"); - mcMMO.p.debug(" Level " + newLevel); - mcMMO.p.debug(" XP " + newXPlevel); - mcMMO.p.debug("------------------------------------------------------------------------"); + pluginRef.debug(" NEW:"); + pluginRef.debug(" Level " + newLevel); + pluginRef.debug(" XP " + newXPlevel); + pluginRef.debug("------------------------------------------------------------------------"); profile.modifySkill(primarySkillType, newLevel); profile.setSkillXpLevel(primarySkillType, newXPlevel); diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java index 8bd2e1242..997463b28 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java @@ -87,12 +87,12 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis); if (fetchedUUIDs.size() >= BATCH_SIZE) { - mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs); + pluginRef.getDatabaseManager().saveUserUUIDs(fetchedUUIDs); fetchedUUIDs = new HashMap(); } } - if (fetchedUUIDs.size() == 0 || mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs)) { + if (fetchedUUIDs.size() == 0 || pluginRef.getDatabaseManager().saveUserUUIDs(fetchedUUIDs)) { //mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UUIDS); plugin.getLogger().info("UUID upgrade completed!"); } diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java index a841b3a8f..373fa8621 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UserPurgeTask.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.runnables.database; -import com.gmail.nossr50.mcMMO; import org.bukkit.scheduler.BukkitRunnable; import java.util.concurrent.locks.ReentrantLock; @@ -11,11 +10,11 @@ public class UserPurgeTask extends BukkitRunnable { @Override public void run() { lock.lock(); - if (mcMMO.getDatabaseCleaningSettings().isPurgePowerlessUsers()) - mcMMO.getDatabaseManager().purgePowerlessUsers(); + if (pluginRef.getDatabaseCleaningSettings().isPurgePowerlessUsers()) + pluginRef.getDatabaseManager().purgePowerlessUsers(); - if (mcMMO.getDatabaseCleaningSettings().isPurgeOldUsers()) { - mcMMO.getDatabaseManager().purgeOldUsers(); + if (pluginRef.getDatabaseCleaningSettings().isPurgeOldUsers()) { + pluginRef.getDatabaseManager().purgeOldUsers(); } lock.unlock(); } diff --git a/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java index 5b276e681..68bb2076e 100644 --- a/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java +++ b/src/main/java/com/gmail/nossr50/runnables/items/ChimaeraWingWarmup.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.runnables.items; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.ChimaeraWing; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; @@ -29,26 +27,26 @@ public class ChimaeraWingWarmup extends BukkitRunnable { Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation(); if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) { - player.sendMessage(LocaleLoader.getString("Teleport.Cancelled")); + player.sendMessage(pluginRef.getLocaleManager().getString("Teleport.Cancelled")); mcMMOPlayer.setTeleportCommenceLocation(null); return; } ItemStack inHand = player.getInventory().getItemInMainHand(); - if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < mcMMO.getConfigManager().getConfigItems().getChimaeraWingUseCost()) { - player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name"))); + if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < pluginRef.getConfigManager().getConfigItems().getChimaeraWingUseCost()) { + player.sendMessage(pluginRef.getLocaleManager().getString("Skills.NeedMore", pluginRef.getLocaleManager().getString("Item.ChimaeraWing.Name"))); return; } long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); - int hurtCooldown = mcMMO.getConfigManager().getConfigItems().getRecentlyHurtCooldown(); + int hurtCooldown = pluginRef.getConfigManager().getConfigItems().getRecentlyHurtCooldown(); if (hurtCooldown > 0) { int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player); if (timeRemaining > 0) { - player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining)); + player.sendMessage(pluginRef.getLocaleManager().getString("Item.Injured.Wait", timeRemaining)); return; } } diff --git a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java index c586b5780..2ebd8f69d 100644 --- a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java +++ b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java @@ -1,9 +1,6 @@ package com.gmail.nossr50.runnables.items; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.skills.SkillUtils; @@ -30,23 +27,23 @@ public class TeleportationWarmup extends BukkitRunnable { mcMMOPlayer.setTeleportCommenceLocation(null); - if (!PartyManager.inSameParty(teleportingPlayer, targetPlayer)) { - teleportingPlayer.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetPlayer.getName())); + if (!pluginRef.getPartyManager().inSameParty(teleportingPlayer, targetPlayer)) { + teleportingPlayer.sendMessage(pluginRef.getLocaleManager().getString("Party.NotInYourParty", targetPlayer.getName())); return; } if (newLocation.distanceSquared(previousLocation) > 1.0) { - teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Cancelled")); + teleportingPlayer.sendMessage(pluginRef.getLocaleManager().getString("Teleport.Cancelled")); return; } - int hurtCooldown = mcMMO.getConfigManager().getConfigParty().getPTP().getPtpRecentlyHurtCooldown(); + int hurtCooldown = pluginRef.getConfigManager().getConfigParty().getPTP().getPtpRecentlyHurtCooldown(); if (hurtCooldown > 0) { int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, teleportingPlayer); if (timeRemaining > 0) { - teleportingPlayer.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining)); + teleportingPlayer.sendMessage(pluginRef.getLocaleManager().getString("Item.Injured.Wait", timeRemaining)); return; } } diff --git a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java index 48db5eccd..4fe65d184 100644 --- a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.runnables.party; import com.gmail.nossr50.datatypes.party.Party; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import org.bukkit.OfflinePlayer; import org.bukkit.scheduler.BukkitRunnable; @@ -13,7 +11,7 @@ import java.util.Map.Entry; import java.util.UUID; public class PartyAutoKickTask extends BukkitRunnable { - private final static long KICK_TIME = 24L * 60L * 60L * 1000L * mcMMO.getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval(); + private final static long KICK_TIME = 24L * 60L * 60L * 1000L * pluginRef.getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval(); @Override public void run() { @@ -22,9 +20,9 @@ public class PartyAutoKickTask extends BukkitRunnable { long currentTime = System.currentTimeMillis(); - for (Party party : PartyManager.getParties()) { + for (Party party : pluginRef.getPartyManager().getParties()) { for (UUID memberUniqueId : party.getMembers().keySet()) { - OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId); + OfflinePlayer member = pluginRef.getServer().getOfflinePlayer(memberUniqueId); boolean isProcessed = processedPlayers.contains(memberUniqueId); if ((!member.isOnline() && (currentTime - member.getLastPlayed() > KICK_TIME)) || isProcessed) { @@ -38,7 +36,7 @@ public class PartyAutoKickTask extends BukkitRunnable { } for (Entry entry : toRemove.entrySet()) { - PartyManager.removeFromParty(entry.getKey(), entry.getValue()); + pluginRef.getPartyManager().removeFromParty(entry.getKey(), entry.getValue()); } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/party/PartyChatTask.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyChatTask.java index 94543d4ba..f545436af 100644 --- a/src/main/java/com/gmail/nossr50/runnables/party/PartyChatTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyChatTask.java @@ -1,16 +1,9 @@ package com.gmail.nossr50.runnables.party; import com.gmail.nossr50.datatypes.party.Party; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class PartyChatTask extends BukkitRunnable { private Plugin plugin; @@ -30,22 +23,6 @@ public class PartyChatTask extends BukkitRunnable { @Override public void run() { - if (mcMMO.getConfigManager().getConfigParty().isPartyLeaderColoredGold() - && senderName.equalsIgnoreCase(party.getLeader().getPlayerName())) { - message = message.replaceFirst(Pattern.quote(displayName), ChatColor.GOLD + Matcher.quoteReplacement(displayName) + ChatColor.RESET); - } - for (Player member : party.getOnlineMembers()) { - member.sendMessage(message); - } - - if (party.getAlly() != null) { - for (Player member : party.getAlly().getOnlineMembers()) { - String allyPrefix = LocaleLoader.formatString(mcMMO.getConfigManager().getConfigParty().getPartyChatPrefixAlly()); - member.sendMessage(allyPrefix + message); - } - } - - plugin.getServer().getConsoleSender().sendMessage(ChatColor.stripColor("[mcMMO] [P]<" + party.getName() + ">" + message)); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java index 2a036b5c1..8015323c0 100644 --- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java @@ -2,8 +2,6 @@ package com.gmail.nossr50.runnables.player; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.commands.McScoreboardKeepTask; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.player.UserManager; @@ -36,34 +34,34 @@ public class PlayerProfileLoadingTask extends BukkitRunnable { // Quit if they logged out if (!player.isOnline()) { - mcMMO.p.getLogger().info("Aborting profile loading recovery for " + player.getName() + " - player logged out"); + pluginRef.getLogger().info("Aborting profile loading recovery for " + player.getName() + " - player logged out"); return; } - PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true); + PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true); // If successful, schedule the apply if (profile.isLoaded()) { - new ApplySuccessfulProfile(new McMMOPlayer(player, profile)).runTask(mcMMO.p); + new ApplySuccessfulProfile(new McMMOPlayer(player, profile)).runTask(pluginRef); return; } // Print errors to console/logs if we're failing at least 2 times in a row to load the profile if (attempt >= 3) { //Log the error - mcMMO.p.getLogger().severe(LocaleLoader.getString("Profile.Loading.FailureNotice", + pluginRef.getLogger().severe(pluginRef.getLocaleManager().getString("Profile.Loading.FailureNotice", player.getName(), String.valueOf(attempt))); //Notify the admins - mcMMO.p.getServer().broadcast(LocaleLoader.getString("Profile.Loading.FailureNotice", player.getName()), Server.BROADCAST_CHANNEL_ADMINISTRATIVE); + pluginRef.getServer().broadcast(pluginRef.getLocaleManager().getString("Profile.Loading.FailureNotice", player.getName()), Server.BROADCAST_CHANNEL_ADMINISTRATIVE); //Notify the player - player.sendMessage(LocaleLoader.getString("Profile.Loading.FailurePlayer", String.valueOf(attempt)).split("\n")); + player.sendMessage(pluginRef.getLocaleManager().getString("Profile.Loading.FailurePlayer", String.valueOf(attempt)).split("\n")); } // Increment attempt counter and try attempt++; - new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, (100 + (attempt * 100))); + new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(pluginRef, (100 + (attempt * 100))); } private class ApplySuccessfulProfile extends BukkitRunnable { @@ -78,7 +76,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable { @Override public void run() { if (!player.isOnline()) { - mcMMO.p.getLogger().info("Aborting profile loading recovery for " + player.getName() + " - player logged out"); + pluginRef.getLogger().info("Aborting profile loading recovery for " + player.getName() + " - player logged out"); return; } @@ -86,17 +84,17 @@ public class PlayerProfileLoadingTask extends BukkitRunnable { UserManager.track(mcMMOPlayer); mcMMOPlayer.actualizeRespawnATS(); - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled()) { + if (pluginRef.getScoreboardSettings().getScoreboardsEnabled()) { ScoreboardManager.setupPlayer(player); - if (mcMMO.getScoreboardSettings().getShowStatsAfterLogin()) { + if (pluginRef.getScoreboardSettings().getShowStatsAfterLogin()) { ScoreboardManager.enablePlayerStatsScoreboard(player); - new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, Misc.TICK_CONVERSION_FACTOR); + new McScoreboardKeepTask(player).runTaskLater(pluginRef, Misc.TICK_CONVERSION_FACTOR); } } - if (mcMMO.getConfigManager().getConfigNotifications().isShowProfileLoadedMessage()) { - player.sendMessage(LocaleLoader.getString("Profile.Loading.Success")); + if (pluginRef.getConfigManager().getConfigNotifications().isShowProfileLoadedMessage()) { + player.sendMessage(pluginRef.getLocaleManager().getString("Profile.Loading.Success")); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java index a492ea8b3..a044df3ef 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityCooldownTask.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; -import com.gmail.nossr50.mcMMO; import org.bukkit.scheduler.BukkitRunnable; public class AbilityCooldownTask extends BukkitRunnable { @@ -23,7 +22,7 @@ public class AbilityCooldownTask extends BukkitRunnable { mcMMOPlayer.setAbilityInformed(ability, true); - mcMMO.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.ABILITY_REFRESHED, ability.getAbilityRefresh()); + pluginRef.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.ABILITY_REFRESHED, ability.getAbilityRefresh()); //mcMMOPlayer.getPlayer().sendMessage(ability.getAbilityRefresh()); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java index b50075859..4e53de966 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.skills.PerksUtils; @@ -51,12 +50,12 @@ public class AbilityDisableTask extends BukkitRunnable { if (mcMMOPlayer.useChatNotifications()) { //player.sendMessage(ability.getAbilityOff()); - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_OFF, ability.getAbilityOff()); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_OFF, ability.getAbilityOff()); } SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff()); - new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR); + new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(pluginRef, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR); } private void resendChunkRadiusAt(Player player) { diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index b6039bc85..daea51073 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.MobHealthbarUtils; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; @@ -80,7 +79,7 @@ public class BleedTimerTask extends BukkitRunnable { if (containerEntry.getValue().bleedTicks <= 0 || !target.isValid()) { if (target instanceof Player) { - mcMMO.getNotificationManager().sendPlayerInformation((Player) target, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Stopped"); + pluginRef.getNotificationManager().sendPlayerInformation((Player) target, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Stopped"); } bleedIterator.remove(); @@ -92,7 +91,7 @@ public class BleedTimerTask extends BukkitRunnable { double damage; if (target instanceof Player) { - damage = mcMMO.getConfigManager().getConfigSwords().getRuptureDamagePlayer(); + damage = pluginRef.getConfigManager().getConfigSwords().getRuptureDamagePlayer(); //Above Bleed Rank 3 deals 50% more damage if (containerEntry.getValue().toolTier >= 4 && containerEntry.getValue().bleedRank >= 3) @@ -111,7 +110,7 @@ public class BleedTimerTask extends BukkitRunnable { } } else { - damage = mcMMO.getConfigManager().getConfigSwords().getRuptureDamageMobs(); + damage = pluginRef.getConfigManager().getConfigSwords().getRuptureDamageMobs(); // debugMessage+="BaseDMG=["+damage+"], "; @@ -123,7 +122,7 @@ public class BleedTimerTask extends BukkitRunnable { // debugMessage+="Rank4Bonus=["+String.valueOf(containerEntry.getValue().bleedRank >= 3)+"], "; - MobHealthbarUtils.handleMobHealthbars(target, damage, mcMMO.p); //Update health bars + MobHealthbarUtils.handleMobHealthbars(target, damage, pluginRef); //Update health bars } // debugMessage+="FullArmor=["+String.valueOf(armorCount > 3)+"], "; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java index c23a9961c..6aa47b6ea 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/SkillUnlockNotificationTask.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.mcMMO; import org.bukkit.scheduler.BukkitRunnable; @@ -38,6 +37,6 @@ public class SkillUnlockNotificationTask extends BukkitRunnable { @Override public void run() { //mcMMOPlayer.getPlayer().sendTitle(subSkillType.getLocaleName(), "Rank "+rank, 7, 20, 7); - mcMMO.getNotificationManager().sendPlayerUnlockNotification(mcMMOPlayer, subSkillType); + pluginRef.getNotificationManager().sendPlayerUnlockNotification(mcMMOPlayer, subSkillType); } } diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java index 22d9ab22a..bbd505e81 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/ToolLowerTask.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.ToolType; -import com.gmail.nossr50.mcMMO; import org.bukkit.scheduler.BukkitRunnable; public class ToolLowerTask extends BukkitRunnable { @@ -23,8 +22,8 @@ public class ToolLowerTask extends BukkitRunnable { mcMMOPlayer.setToolPreparationMode(tool, false); - if (mcMMO.getConfigManager().getConfigNotifications().isSuperAbilityToolMessage()) { - mcMMO.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.TOOL, tool.getLowerTool()); + if (pluginRef.getConfigManager().getConfigNotifications().isSuperAbilityToolMessage()) { + pluginRef.getNotificationManager().sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.TOOL, tool.getLowerTool()); } } } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java index c70f5a842..899167a35 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java @@ -1,15 +1,13 @@ package com.gmail.nossr50.skills.acrobatics; -import com.gmail.nossr50.mcMMO; - public final class Acrobatics { public static double dodgeDamageModifier; public static int dodgeXpModifier; // public static boolean dodgeLightningDisabled; private Acrobatics() { - dodgeDamageModifier = mcMMO.getConfigManager().getConfigAcrobatics().getDamageReductionDivisor(); - dodgeXpModifier = mcMMO.getConfigManager().getConfigExperience().getDodgeXP(); + dodgeDamageModifier = pluginRef.getConfigManager().getConfigAcrobatics().getDamageReductionDivisor(); + dodgeXpModifier = pluginRef.getConfigManager().getConfigExperience().getDodgeXP(); // dodgeLightningDisabled = MainConfig.getInstance().getDodgeLightningDisabled(); } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java index 245d032b1..1dabffa79 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -28,11 +27,11 @@ public class AcrobaticsManager extends SkillManager { public AcrobaticsManager(McMMOPlayer mcMMOPlayer) { super(mcMMOPlayer, PrimarySkillType.ACROBATICS); - rollXPInterval = (1000 * mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().getRollXPGainCooldownSeconds()); + rollXPInterval = (1000 * pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().getRollXPGainCooldownSeconds()); //Save some memory if exploit prevention is off - if (mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) - fallLocationMap = new LimitedSizeList(mcMMO.getConfigManager().getConfigExploitPrevention().getAcrobaticLocationLimit()); + if (pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) + fallLocationMap = new LimitedSizeList(pluginRef.getConfigManager().getConfigExploitPrevention().getAcrobaticLocationLimit()); } public boolean hasFallenInLocationBefore(Location location) { @@ -44,7 +43,7 @@ public class AcrobaticsManager extends SkillManager { } public boolean canGainRollXP() { - if (!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) + if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) return true; if (System.currentTimeMillis() >= rollXPCooldown) { @@ -87,11 +86,11 @@ public class AcrobaticsManager extends SkillManager { ParticleEffectUtils.playDodgeEffect(player); if (mcMMOPlayer.useChatNotifications()) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Combat.Proc"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Combat.Proc"); } //Check respawn to prevent abuse - if (!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) + if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) applyXpGain((float) (damage * Acrobatics.dodgeXpModifier), XPGainReason.PVP); else if (SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) && mcMMOPlayer.getTeleportATS() < System.currentTimeMillis()) { diff --git a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java index 8bb5cd76c..b8853a497 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.archery; import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.datatypes.meta.TrackedArrowMeta; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.skills.RankUtils; import org.bukkit.Material; @@ -27,9 +26,9 @@ public class Archery { public static void incrementArrowCount(LivingEntity livingEntity) { if(livingEntity.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY)) { int arrowCount = livingEntity.getMetadata(MetadataConstants.ARROW_TRACKER_METAKEY).get(0).asInt(); - livingEntity.getMetadata(MetadataConstants.ARROW_TRACKER_METAKEY).set(0, new FixedMetadataValue(mcMMO.p, arrowCount + 1)); + livingEntity.getMetadata(MetadataConstants.ARROW_TRACKER_METAKEY).set(0, new FixedMetadataValue(pluginRef, arrowCount + 1)); } else { - livingEntity.setMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, new TrackedArrowMeta(mcMMO.p, 1)); + livingEntity.setMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, new TrackedArrowMeta(pluginRef, 1)); } } @@ -40,18 +39,18 @@ public class Archery { } public static double getDamageBonusPercent(Player player) { - return ((RankUtils.getRank(player, SubSkillType.ARCHERY_SKILL_SHOT)) * mcMMO.getConfigManager().getConfigArchery().getSkillShotDamageMultiplier()) / 100.0D; + return ((RankUtils.getRank(player, SubSkillType.ARCHERY_SKILL_SHOT)) * pluginRef.getConfigManager().getConfigArchery().getSkillShotDamageMultiplier()) / 100.0D; } public static double getSkillShotDamageCap() { - return mcMMO.getConfigManager().getConfigArchery().getSkillShotDamageCeiling(); + return pluginRef.getConfigManager().getConfigArchery().getSkillShotDamageCeiling(); } public static double getDazeBonusDamage() { - return mcMMO.getConfigManager().getConfigArchery().getDaze().getDazeBonusDamage(); + return pluginRef.getConfigManager().getConfigArchery().getDaze().getDazeBonusDamage(); } public static double getDistanceXpMultiplier() { - return mcMMO.getConfigManager().getConfigExperience().getExperienceArchery().getDistanceMultiplier(); + return pluginRef.getConfigManager().getConfigExperience().getExperienceArchery().getDistanceMultiplier(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index f60d0b85a..611c44284 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -75,7 +74,7 @@ public class ArcheryManager extends SkillManager { public void processArrowRetrievalActivation(LivingEntity target, Projectile projectile) { if(projectile.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY)) { Archery.incrementArrowCount(target); - projectile.removeMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, mcMMO.p); //Only 1 entity per projectile + projectile.removeMetadata(MetadataConstants.ARROW_TRACKER_METAKEY, pluginRef); //Only 1 entity per projectile } } @@ -96,12 +95,12 @@ public class ArcheryManager extends SkillManager { defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10)); - if (mcMMO.getNotificationManager().doesPlayerUseNotifications(defender)) { - mcMMO.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Combat.TouchedFuzzy"); + if (pluginRef.getNotificationManager().doesPlayerUseNotifications(defender)) { + pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Combat.TouchedFuzzy"); } if (mcMMOPlayer.useChatNotifications()) { - mcMMO.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.TargetDazed"); + pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.TargetDazed"); } return Archery.getDazeBonusDamage(); diff --git a/src/main/java/com/gmail/nossr50/skills/axes/Axes.java b/src/main/java/com/gmail/nossr50/skills/axes/Axes.java index 2db64adda..861ec389b 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/Axes.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/Axes.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.skills.axes; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.skills.RankUtils; import org.bukkit.entity.LivingEntity; @@ -27,6 +26,6 @@ public class Axes { * @return The axe mastery bonus damage which will be added to their attack */ public static double getAxeMasteryBonusDamage(Player player) { - return RankUtils.getRank(player, SubSkillType.AXES_AXE_MASTERY) * mcMMO.getConfigManager().getConfigAxes().getAxeMasteryMultiplier(); + return RankUtils.getRank(player, SubSkillType.AXES_AXE_MASTERY) * pluginRef.getConfigManager().getConfigAxes().getAxeMasteryMultiplier(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java index 92f5d5c59..9bed07d93 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.ToolType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Permissions; @@ -88,19 +87,19 @@ public class AxesManager extends SkillManager { Player player = getPlayer(); if (mcMMOPlayer.useChatNotifications()) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.CriticalHit"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.CriticalHit"); } if (target instanceof Player) { Player defender = (Player) target; - if (mcMMO.getNotificationManager().doesPlayerUseNotifications(defender)) { - mcMMO.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.CritStruck"); + if (pluginRef.getNotificationManager().doesPlayerUseNotifications(defender)) { + pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.CritStruck"); } - damage = (damage * mcMMO.getConfigManager().getConfigAxes().getConfigAxesCriticalStrikes().getDamageProperty().getPVPModifier()) - damage; + damage = (damage * pluginRef.getConfigManager().getConfigAxes().getConfigAxesCriticalStrikes().getDamageProperty().getPVPModifier()) - damage; } else { - damage = (damage * mcMMO.getConfigManager().getConfigAxes().getConfigAxesCriticalStrikes().getDamageProperty().getPVEModifier()) - damage; + damage = (damage * pluginRef.getConfigManager().getConfigAxes().getConfigAxesCriticalStrikes().getDamageProperty().getPVEModifier()) - damage; } return damage; @@ -124,7 +123,7 @@ public class AxesManager extends SkillManager { } public double getImpactDurabilityDamage() { - return mcMMO.getConfigManager().getConfigAxes().getConfigAxesImpact().getImpactDurabilityDamageModifier() * RankUtils.getRank(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT); + return pluginRef.getConfigManager().getConfigAxes().getConfigAxesImpact().getImpactDurabilityDamageModifier() * RankUtils.getRank(getPlayer(), SubSkillType.AXES_ARMOR_IMPACT); } /** @@ -141,21 +140,21 @@ public class AxesManager extends SkillManager { Player player = getPlayer(); ParticleEffectUtils.playGreaterImpactEffect(target); - target.setVelocity(player.getLocation().getDirection().normalize().multiply(mcMMO.getConfigManager().getConfigAxes().getGreaterImpactKnockBackModifier())); + target.setVelocity(player.getLocation().getDirection().normalize().multiply(pluginRef.getConfigManager().getConfigAxes().getGreaterImpactKnockBackModifier())); if (mcMMOPlayer.useChatNotifications()) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.GI.Proc"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.GI.Proc"); } if (target instanceof Player) { Player defender = (Player) target; - if (mcMMO.getNotificationManager().doesPlayerUseNotifications(defender)) { - mcMMO.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.GI.Struck"); + if (pluginRef.getNotificationManager().doesPlayerUseNotifications(defender)) { + pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.GI.Struck"); } } - return mcMMO.getConfigManager().getConfigAxes().getConfigAxesGreaterImpact().getBonusDamage(); + return pluginRef.getConfigManager().getConfigAxes().getConfigAxesGreaterImpact().getBonusDamage(); } /** @@ -165,6 +164,6 @@ public class AxesManager extends SkillManager { * @param damage The amount of damage initially dealt by the event */ public void skullSplitterCheck(LivingEntity target, double damage, Map modifiers) { - CombatUtils.applyAbilityAoE(getPlayer(), target, damage / mcMMO.getConfigManager().getConfigAxes().getConfigAxesSkullSplitter().getSkullSplitterDamageDivisor(), modifiers, skill); + CombatUtils.applyAbilityAoE(getPlayer(), target, damage / pluginRef.getConfigManager().getConfigAxes().getConfigAxesSkullSplitter().getSkullSplitterDamageDivisor(), modifiers, skill); } } diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java index 5068553e2..f8eccdf60 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/Excavation.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.excavation; import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig; import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; import org.bukkit.block.BlockState; @@ -24,7 +23,7 @@ public class Excavation { } protected static int getBlockXP(BlockState blockState) { - int xp = mcMMO.getDynamicSettingsManager().getExperienceManager().getExcavationXp(blockState.getType()); + int xp = pluginRef.getDynamicSettingsManager().getExperienceManager().getExcavationXp(blockState.getType()); return xp; } diff --git a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java index a05c4c130..5c60a1785 100644 --- a/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java +++ b/src/main/java/com/gmail/nossr50/skills/excavation/ExcavationManager.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -100,6 +99,6 @@ public class ExcavationManager extends SkillManager { excavationBlockCheck(blockState); excavationBlockCheck(blockState); - SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage()); + SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), pluginRef.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage()); } } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index c72327632..5ece33972 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.fishing; import com.gmail.nossr50.config.treasure.FishingTreasureConfig; import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.adapter.BiomeAdapter; import org.bukkit.Material; @@ -27,9 +26,9 @@ public final class Fishing { private Set iceFishingBiomes = BiomeAdapter.ICE_BIOMES; public Fishing() { - overfishLimit = mcMMO.getConfigManager().getConfigExploitPrevention().getOverfishingLimit() + 1; - fishingRodCastCdMilliseconds = mcMMO.getConfigManager().getConfigExploitPrevention().getFishingRodSpamMilliseconds(); - boundingBoxSize = mcMMO.getConfigManager().getConfigExploitPrevention().getOverFishingAreaSize(); + overfishLimit = pluginRef.getConfigManager().getConfigExploitPrevention().getOverfishingLimit() + 1; + fishingRodCastCdMilliseconds = pluginRef.getConfigManager().getConfigExploitPrevention().getFishingRodSpamMilliseconds(); + boundingBoxSize = pluginRef.getConfigManager().getConfigExploitPrevention().getOverFishingAreaSize(); initFishingXPRewardMap(); } @@ -45,13 +44,13 @@ public final class Fishing { */ private void initFishingXPRewardMap() { fishingXpRewardMap = new HashMap<>(); - HashMap nameRegisterMap = mcMMO.getConfigManager().getConfigExperience().getFishingXPMap(); + HashMap nameRegisterMap = pluginRef.getConfigManager().getConfigExperience().getFishingXPMap(); for (String qualifiedName : nameRegisterMap.keySet()) { Material material = Material.matchMaterial(qualifiedName); if (material == null) { - mcMMO.p.getLogger().info("Unable to match qualified name to item for fishing xp map: " + qualifiedName); + pluginRef.getLogger().info("Unable to match qualified name to item for fishing xp map: " + qualifiedName); continue; } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index b28c80752..68c191ab2 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -14,8 +14,6 @@ import com.gmail.nossr50.datatypes.treasure.Rarity; import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.random.RandomChanceSkillStatic; @@ -82,7 +80,7 @@ public class FishingManager extends SkillManager { getPlayer().updateInventory(); if (lastWarnedExhaust + (1000) < currentTime) { - getPlayer().sendMessage(LocaleLoader.getString("Fishing.Exhausting")); + getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Fishing.Exhausting")); lastWarnedExhaust = currentTime; SoundManager.sendSound(getPlayer(), getPlayer().getLocation(), SoundType.TIRED); } @@ -106,7 +104,7 @@ public class FishingManager extends SkillManager { boolean hasFished = (currentTime < fishHookSpawnCD); if (hasFished && (lastWarned + (1000) < currentTime)) { - getPlayer().sendMessage(LocaleLoader.getString("Fishing.Scared")); + getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Fishing.Scared")); lastWarned = System.currentTimeMillis(); } @@ -133,7 +131,7 @@ public class FishingManager extends SkillManager { fishCaughtCounter = 1; if (fishCaughtCounter + 1 == overfishLimit) { - getPlayer().sendMessage(LocaleLoader.getString("Fishing.LowResourcesTip", mcMMO.getConfigManager().getConfigExploitPrevention().getOverFishingAreaSize() * 2)); + getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Fishing.LowResourcesTip", pluginRef.getConfigManager().getConfigExploitPrevention().getOverFishingAreaSize() * 2)); } //If the new bounding box does not intersect with the old one, then update our bounding box reference @@ -148,7 +146,7 @@ public class FishingManager extends SkillManager { if (overFishCount == 2) { for (Player player : Bukkit.getOnlinePlayers()) { if (player.isOp() || Permissions.adminChat(player)) { - player.sendMessage(LocaleLoader.getString("Fishing.OverFishingDetected", getPlayer().getDisplayName())); + player.sendMessage(pluginRef.getLocaleManager().getString("Fishing.OverFishingDetected", getPlayer().getDisplayName())); } } } @@ -202,7 +200,7 @@ public class FishingManager extends SkillManager { } public int getInnerPeaceMultiplier() { - return mcMMO.getConfigManager().getConfigFishing().getVanillaXPMultInnerPeace(RankUtils.getRank(getPlayer(), SubSkillType.FISHING_INNER_PEACE)); + return pluginRef.getConfigManager().getConfigFishing().getVanillaXPMultInnerPeace(RankUtils.getRank(getPlayer(), SubSkillType.FISHING_INNER_PEACE)); } /** @@ -277,7 +275,7 @@ public class FishingManager extends SkillManager { Player player = getPlayer(); FishingTreasure treasure = null; - if (mcMMO.getConfigManager().getConfigFishing().isAllowCustomDrops() + if (pluginRef.getConfigManager().getConfigFishing().isAllowCustomDrops() && Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_TREASURE_HUNTER)) { treasure = getFishingTreasure(); } @@ -311,10 +309,10 @@ public class FishingManager extends SkillManager { } if (enchanted) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Fishing.Ability.TH.MagicFound"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Fishing.Ability.TH.MagicFound"); } - if (mcMMO.getConfigManager().getConfigFishing().isAlwaysCatchFish()) { + if (pluginRef.getConfigManager().getConfigFishing().isAlwaysCatchFish()) { /*Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());*/ Misc.dropItem(fishingCatch.getLocation(), fishingCatch.getItemStack()).setVelocity(fishingCatch.getVelocity()); } @@ -424,7 +422,7 @@ public class FishingManager extends SkillManager { Misc.dropItem(target.getLocation(), drop); CombatUtils.dealDamage(target, Math.min(Math.max(target.getMaxHealth() / 4, 1), 10), EntityDamageEvent.DamageCause.CUSTOM, getPlayer()); // Make it so you can shake a mob no more than 4 times. - applyXpGain(mcMMO.getConfigManager().getConfigExperience().getShakeXP(), XPGainReason.PVE); + applyXpGain(pluginRef.getConfigManager().getConfigExperience().getShakeXP(), XPGainReason.PVE); } } @@ -445,7 +443,7 @@ public class FishingManager extends SkillManager { } // Rather than subtracting luck (and causing a minimum 3% chance for every drop), scale by luck. - diceRoll *= (1.0 - luck * mcMMO.getConfigManager().getConfigFishing().getLureLuckModifier() / 100); + diceRoll *= (1.0 - luck * pluginRef.getConfigManager().getConfigFishing().getLureLuckModifier() / 100); FishingTreasure treasure = null; diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index b9777c56f..4161a9ead 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.skills.herbalism; import com.gmail.nossr50.core.MetadataConstants; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.skills.SkillUtils; import org.bukkit.Material; @@ -60,8 +59,8 @@ public class Herbalism { int dropAmount = 0; - if (mcMMO.getPlaceStore().isTrue(target)) - mcMMO.getPlaceStore().setFalse(target); + if (pluginRef.getPlaceStore().isTrue(target)) + pluginRef.getPlaceStore().setFalse(target); else { dropAmount++; @@ -97,13 +96,13 @@ public class Herbalism { } } else { //Check the block itself first - if (!mcMMO.getPlaceStore().isTrue(block)) { + if (!pluginRef.getPlaceStore().isTrue(block)) { dropAmount++; if (herbalismManager.checkDoubleDrop(blockState)) bonusDropAmount += bonusAdd; } else { - mcMMO.getPlaceStore().setFalse(blockState); + pluginRef.getPlaceStore().setFalse(blockState); } // Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally @@ -114,8 +113,8 @@ public class Herbalism { break; } - if (mcMMO.getPlaceStore().isTrue(relativeBlock)) { - mcMMO.getPlaceStore().setFalse(relativeBlock); + if (pluginRef.getPlaceStore().isTrue(relativeBlock)) { + pluginRef.getPlaceStore().setFalse(relativeBlock); } else { dropAmount++; @@ -162,10 +161,10 @@ public class Herbalism { } private static int addKelpDrops(int dropAmount, Block relativeBlock) { - if (isKelp(relativeBlock) && !mcMMO.getPlaceStore().isTrue(relativeBlock)) { + if (isKelp(relativeBlock) && !pluginRef.getPlaceStore().isTrue(relativeBlock)) { dropAmount++; } else { - mcMMO.getPlaceStore().setFalse(relativeBlock); + pluginRef.getPlaceStore().setFalse(relativeBlock); } return dropAmount; diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index a259a01b6..0efc3b0ba 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.datatypes.treasure.HylianTreasure; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.*; @@ -37,7 +36,7 @@ public class HerbalismManager extends SkillManager { } public boolean canBlockCheck() { - return !(mcMMO.getConfigManager().getConfigExploitPrevention().isPreventVehicleAutoFarming() && getPlayer().isInsideVehicle()); + return !(pluginRef.getConfigManager().getConfigExploitPrevention().isPreventVehicleAutoFarming() && getPlayer().isInsideVehicle()); } public boolean canGreenThumbBlock(BlockState blockState) { @@ -107,7 +106,7 @@ public class HerbalismManager extends SkillManager { ItemStack seed = new ItemStack(Material.WHEAT_SEEDS); if (!playerInventory.containsAtLeast(seed, 1)) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Herbalism.Ability.GTe.NeedMore"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Herbalism.Ability.GTe.NeedMore"); return false; } @@ -126,7 +125,7 @@ public class HerbalismManager extends SkillManager { boolean oneBlockPlant = isOneBlockPlant(material); // Prevents placing and immediately breaking blocks for exp - if (oneBlockPlant && mcMMO.getPlaceStore().isTrue(blockState)) { + if (oneBlockPlant && pluginRef.getPlaceStore().isTrue(blockState)) { return; } @@ -147,7 +146,7 @@ public class HerbalismManager extends SkillManager { // } // } // else { - xp = mcMMO.getDynamicSettingsManager().getExperienceManager().getHerbalismXp(blockState.getType()); + xp = pluginRef.getDynamicSettingsManager().getExperienceManager().getHerbalismXp(blockState.getType()); if (!oneBlockPlant) { //Kelp is actually two blocks mixed together @@ -173,7 +172,7 @@ public class HerbalismManager extends SkillManager { } public boolean isOneBlockPlant(Material material) { - return !mcMMO.getMaterialMapStore().isMultiBlock(material); + return !pluginRef.getMaterialMapStore().isMultiBlock(material); } /** @@ -194,7 +193,7 @@ public class HerbalismManager extends SkillManager { */ public boolean processGreenThumbBlocks(BlockState blockState) { if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.HERBALISM_GREEN_THUMB, getPlayer())) { - mcMMO.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE_FAILED, "Herbalism.Ability.GTh.Fail"); + pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE_FAILED, "Herbalism.Ability.GTh.Fail"); return false; } @@ -233,7 +232,7 @@ public class HerbalismManager extends SkillManager { } blockState.setType(Material.AIR); Misc.dropItem(location, treasure.getDrop()); - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Herbalism.HylianLuck"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Herbalism.HylianLuck"); return true; } } @@ -251,12 +250,12 @@ public class HerbalismManager extends SkillManager { PlayerInventory playerInventory = player.getInventory(); if (!playerInventory.contains(Material.BROWN_MUSHROOM, 1)) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)); return false; } if (!playerInventory.contains(Material.RED_MUSHROOM, 1)) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)); return false; } @@ -265,7 +264,7 @@ public class HerbalismManager extends SkillManager { player.updateInventory(); if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.HERBALISM_SHROOM_THUMB, player)) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Herbalism.Ability.ShroomThumb.Fail"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Herbalism.Ability.ShroomThumb.Fail"); return false; } @@ -334,13 +333,13 @@ public class HerbalismManager extends SkillManager { player.updateInventory(); // Needed until replacement available } - new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0); + new HerbalismBlockUpdaterTask(blockState).runTaskLater(pluginRef, 0); } private boolean handleBlockState(BlockState blockState, boolean greenTerra) { int greenThumbStage = getGreenThumbStage(); - blockState.setMetadata(MetadataConstants.GREEN_THUMB_METAKEY, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR))); + blockState.setMetadata(MetadataConstants.GREEN_THUMB_METAKEY, new FixedMetadataValue(pluginRef, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR))); Ageable crops = (Ageable) blockState.getBlockData(); switch (blockState.getType()) { diff --git a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java index b4bf56553..481ed5660 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java @@ -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.mcMMO; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.RankUtils; import org.bukkit.entity.Player; @@ -15,12 +14,12 @@ public class BlastMining { public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100; public static double getBlastRadiusModifier(int rank) { - return mcMMO.getConfigManager().getConfigMining().getBlastMining().getRadius(rank); + return pluginRef.getConfigManager().getConfigMining().getBlastMining().getRadius(rank); } public static double getBlastDamageDecrease(int rank) { - return mcMMO.getConfigManager().getConfigMining().getBlastMining().getDamageDecrease(rank); + return pluginRef.getConfigManager().getConfigMining().getBlastMining().getDamageDecrease(rank); } @@ -50,7 +49,7 @@ public class BlastMining { } // We can make this assumption because we (should) be the only ones using this exact metadata - Player player = mcMMO.p.getServer().getPlayerExact(tnt.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString()); + Player player = pluginRef.getServer().getPlayerExact(tnt.getMetadata(MetadataConstants.TNT_TRACKING_METAKEY).get(0).asString()); if (!player.equals(defender)) { return false; diff --git a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java index b6c15b1da..a3e67ebb5 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/Mining.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.mining; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import org.bukkit.Material; @@ -16,7 +15,7 @@ public class Mining { public Mining() { //Init detonators - this.detonators = ItemUtils.matchMaterials(mcMMO.getConfigManager().getConfigMining().getDetonators()); + this.detonators = ItemUtils.matchMaterials(pluginRef.getConfigManager().getConfigMining().getDetonators()); } public static Mining getInstance() { @@ -32,7 +31,7 @@ public class Mining { * @param blockState The {@link BlockState} to check ability activation for */ public static int getBlockXp(BlockState blockState) { - int xp = mcMMO.getDynamicSettingsManager().getExperienceManager().getMiningXp(blockState.getType()); + int xp = pluginRef.getDynamicSettingsManager().getExperienceManager().getMiningXp(blockState.getType()); return xp; } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 284e7838f..504d97144 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.AbilityCooldownTask; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.BlockUtils; @@ -34,15 +33,15 @@ public class MiningManager extends SkillManager { } public static double getOreBonus(int rank) { - return mcMMO.getConfigManager().getConfigMining().getBlastMining().getOreBonus(rank); + return pluginRef.getConfigManager().getConfigMining().getBlastMining().getOreBonus(rank); } public static double getDebrisReduction(int rank) { - return mcMMO.getConfigManager().getConfigMining().getBlastMining().getDebrisReduction(rank); + return pluginRef.getConfigManager().getConfigMining().getBlastMining().getDebrisReduction(rank); } public static int getDropMultiplier(int rank) { - return mcMMO.getConfigManager().getConfigMining().getBlastMining().getDropMultiplier(rank); + return pluginRef.getConfigManager().getConfigMining().getBlastMining().getDropMultiplier(rank); } public boolean canUseDemolitionsExpertise() { @@ -87,15 +86,15 @@ public class MiningManager extends SkillManager { applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE); if (mcMMOPlayer.getAbilityMode(skill.getSuperAbility())) { - SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage()); + SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), pluginRef.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage()); } - if (!canDoubleDrop() || !mcMMO.getDynamicSettingsManager().getBonusDropManager().isBonusDropWhitelisted(blockState.getType())) + if (!canDoubleDrop() || !pluginRef.getDynamicSettingsManager().getBonusDropManager().isBonusDropWhitelisted(blockState.getType())) return; boolean silkTouch = player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH); - if (silkTouch && !mcMMO.getConfigManager().getConfigMining().getMiningSubskills().getDoubleDrops().isAllowSilkTouchDoubleDrops()) + if (silkTouch && !pluginRef.getConfigManager().getConfigMining().getMiningSubskills().getDoubleDrops().isAllowSilkTouchDoubleDrops()) return; //TODO: Make this readable @@ -119,8 +118,8 @@ public class MiningManager extends SkillManager { TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class); //SkillUtils.sendSkillMessage(player, SuperAbilityType.BLAST_MINING.getAbilityPlayer(player)); - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUPER_ABILITY, "Mining.Blast.Boom"); - //player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom")); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUPER_ABILITY, "Mining.Blast.Boom"); + //player.sendMessage(pluginRef.getLocaleManager().getString("Mining.Blast.Boom")); tnt.setMetadata(MetadataConstants.TNT_TRACKING_METAKEY, mcMMOPlayer.getPlayerMetadata()); tnt.setFuseTicks(0); @@ -128,7 +127,7 @@ public class MiningManager extends SkillManager { mcMMOPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis()); mcMMOPlayer.setAbilityInformed(SuperAbilityType.BLAST_MINING, false); - new AbilityCooldownTask(mcMMOPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(mcMMO.p, SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR); + new AbilityCooldownTask(mcMMOPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(pluginRef, SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR); } /** @@ -160,13 +159,13 @@ public class MiningManager extends SkillManager { for (BlockState blockState : ores) { if (Misc.getRandom().nextFloat() < (yield + oreBonus)) { - if (!mcMMO.getPlaceStore().isTrue(blockState)) { + if (!pluginRef.getPlaceStore().isTrue(blockState)) { xp += Mining.getBlockXp(blockState); } Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType())); // Initial block that would have been dropped - if (!mcMMO.getPlaceStore().isTrue(blockState)) { + if (!pluginRef.getPlaceStore().isTrue(blockState)) { for (int i = 1; i < dropMultiplier; i++) { Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items } @@ -257,8 +256,8 @@ public class MiningManager extends SkillManager { int timeRemaining = mcMMOPlayer.calculateTimeRemaining(SuperAbilityType.BLAST_MINING); if (timeRemaining > 0) { - //getPlayer().sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining)); - mcMMO.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); + //getPlayer().sendMessage(pluginRef.getLocaleManager().getString("Skills.TooTired", timeRemaining)); + pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.ABILITY_COOLDOWN, "Skills.TooTired", String.valueOf(timeRemaining)); return false; } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java index 97a8c2713..61ffc549f 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.repair; -import com.gmail.nossr50.mcMMO; import org.bukkit.Material; public class Repair { @@ -8,7 +7,7 @@ public class Repair { private Material anvilMaterial; public Repair() { - anvilMaterial = mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().getRepairAnvilMaterial(); + anvilMaterial = pluginRef.getConfigManager().getConfigRepair().getRepairGeneral().getRepairAnvilMaterial(); } public static Repair getInstance() { diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java index 8588f66ac..41374a180 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -4,8 +4,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -41,11 +39,11 @@ public class RepairManager extends SkillManager { return; } - if (mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilMessages()) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Repair.Listener.Anvil"); + if (pluginRef.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilMessages()) { + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Repair.Listener.Anvil"); } - if (mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilPlacedSounds()) { + if (pluginRef.getConfigManager().getConfigRepair().getRepairGeneral().isAnvilPlacedSounds()) { SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL); } @@ -121,7 +119,7 @@ public class RepairManager extends SkillManager { // // /* Abort the repair if no compatible basic repairing item found */ // if (repairMaterial == null && foundNonBasicMaterial == true) { -// player.sendMessage(LocaleLoader.getString("Repair.NoBasicRepairMatsFound")); +// player.sendMessage(pluginRef.getLocaleManager().getString("Repair.NoBasicRepairMatsFound")); // return; // } // @@ -186,7 +184,7 @@ public class RepairManager extends SkillManager { Player player = getPlayer(); long lastUse = getLastAnvilUse(); - if (!SkillUtils.cooldownExpired(lastUse, 3) || !mcMMO.getConfigManager().getConfigRepair().getRepairGeneral().isEnchantedItemsRequireConfirm()) { + if (!SkillUtils.cooldownExpired(lastUse, 3) || !pluginRef.getConfigManager().getConfigRepair().getRepairGeneral().isEnchantedItemsRequireConfirm()) { return true; } @@ -195,7 +193,7 @@ public class RepairManager extends SkillManager { } actualizeLastAnvilUse(); - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Skills.ConfirmOrCancel", LocaleLoader.getString("Repair.Pretty.Name")); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Skills.ConfirmOrCancel", pluginRef.getLocaleManager().getString("Repair.Pretty.Name")); return false; } @@ -215,7 +213,7 @@ public class RepairManager extends SkillManager { * @return The chance of keeping the enchantment */ public double getKeepEnchantChance() { - return mcMMO.getConfigManager().getConfigRepair().getArcaneForging().getKeepEnchantChanceMap().get(getArcaneForgingRank()); + return pluginRef.getConfigManager().getConfigRepair().getArcaneForging().getKeepEnchantChanceMap().get(getArcaneForgingRank()); } /** @@ -224,7 +222,7 @@ public class RepairManager extends SkillManager { * @return The chance of the enchantment being downgraded */ public double getDowngradeEnchantChance() { - return mcMMO.getConfigManager().getConfigRepair().getArcaneForging().getDowngradeChanceMap().get(getArcaneForgingRank()); + return pluginRef.getConfigManager().getConfigRepair().getArcaneForging().getDowngradeChanceMap().get(getArcaneForgingRank()); } /** @@ -240,8 +238,8 @@ public class RepairManager extends SkillManager { if (Permissions.isSubSkillEnabled(player, SubSkillType.REPAIR_REPAIR_MASTERY) && RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.REPAIR_REPAIR_MASTERY)) { - double maxBonusCalc = mcMMO.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonus(SubSkillType.REPAIR_REPAIR_MASTERY) / 100.0D; - double skillLevelBonusCalc = (maxBonusCalc / mcMMO.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY)) * (getSkillLevel() / 100.0D); + double maxBonusCalc = pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonus(SubSkillType.REPAIR_REPAIR_MASTERY) / 100.0D; + double skillLevelBonusCalc = (maxBonusCalc / pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY)) * (getSkillLevel() / 100.0D); double bonus = repairAmount * Math.min(skillLevelBonusCalc, maxBonusCalc); repairAmount += bonus; @@ -268,7 +266,7 @@ public class RepairManager extends SkillManager { return false; if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.REPAIR_SUPER_REPAIR, getPlayer())) { - mcMMO.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Repair.Skills.FeltEasy"); + pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Repair.Skills.FeltEasy"); return true; } @@ -290,7 +288,7 @@ public class RepairManager extends SkillManager { } if (Permissions.arcaneBypass(player)) { - mcMMO.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Repair.Arcane.Perfect"); + pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Repair.Arcane.Perfect"); return; } @@ -299,7 +297,7 @@ public class RepairManager extends SkillManager { item.removeEnchantment(enchant); } - mcMMO.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE_FAILED, "Repair.Arcane.Lost"); + pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE_FAILED, "Repair.Arcane.Lost"); return; } @@ -308,7 +306,7 @@ public class RepairManager extends SkillManager { for (Entry enchant : enchants.entrySet()) { int enchantLevel = enchant.getValue(); - if(!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitRepair().isAllowUnsafeEnchants()) { + if(!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitRepair().isAllowUnsafeEnchants()) { if(enchantLevel > enchant.getKey().getMaxLevel()) { enchantLevel = enchant.getKey().getMaxLevel(); @@ -320,7 +318,7 @@ public class RepairManager extends SkillManager { if (RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getKeepEnchantChance(), getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING))) { - if (mcMMO.getConfigManager().getConfigRepair().getArcaneForging().isDowngradesEnabled() && enchantLevel > 1 + if (pluginRef.getConfigManager().getConfigRepair().getArcaneForging().isDowngradesEnabled() && enchantLevel > 1 && (!RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(100 - getDowngradeEnchantChance(), getPlayer(), SubSkillType.REPAIR_ARCANE_FORGING)))) { item.addUnsafeEnchantment(enchantment, enchantLevel - 1); downgraded = true; @@ -333,13 +331,13 @@ public class RepairManager extends SkillManager { Map newEnchants = item.getEnchantments(); if (newEnchants.isEmpty()) { - mcMMO.getNotificationManager().sendPlayerInformationChatOnly(getPlayer(), "Repair.Arcane.Fail"); + pluginRef.getNotificationManager().sendPlayerInformationChatOnly(getPlayer(), "Repair.Arcane.Fail"); } else if (downgraded || newEnchants.size() < enchants.size()) { - mcMMO.getNotificationManager().sendPlayerInformationChatOnly(getPlayer(), "Repair.Arcane.Downgrade"); + pluginRef.getNotificationManager().sendPlayerInformationChatOnly(getPlayer(), "Repair.Arcane.Downgrade"); } else { - mcMMO.getNotificationManager().sendPlayerInformationChatOnly(getPlayer(), "Repair.Arcane.Perfect"); + pluginRef.getNotificationManager().sendPlayerInformationChatOnly(getPlayer(), "Repair.Arcane.Perfect"); } } diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java b/src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java index 5d87156b1..da0ae4e5e 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/Salvage.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.salvage; -import com.gmail.nossr50.mcMMO; import org.bukkit.Material; public class Salvage { @@ -10,9 +9,9 @@ public class Salvage { public static boolean arcaneSalvageEnchantLoss; public Salvage() { - anvilMaterial = mcMMO.getConfigManager().getConfigSalvage().getGeneral().getSalvageAnvilMaterial(); - arcaneSalvageDowngrades = mcMMO.getConfigManager().getConfigSalvage().getConfigArcaneSalvage().isDowngradesEnabled(); - arcaneSalvageEnchantLoss = mcMMO.getConfigManager().getConfigSalvage().getConfigArcaneSalvage().isMayLoseEnchants(); + anvilMaterial = pluginRef.getConfigManager().getConfigSalvage().getGeneral().getSalvageAnvilMaterial(); + arcaneSalvageDowngrades = pluginRef.getConfigManager().getConfigSalvage().getConfigArcaneSalvage().isDowngradesEnabled(); + arcaneSalvageEnchantLoss = pluginRef.getConfigManager().getConfigSalvage().getConfigArcaneSalvage().isMayLoseEnchants(); } protected static int calculateSalvageableAmount(short currentDurability, short maxDurability, int baseAmount) { diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java index 4fc1df35e..b0a856df2 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -4,8 +4,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; import com.gmail.nossr50.util.EventUtils; @@ -46,11 +44,11 @@ public class SalvageManager extends SkillManager { return; } - if (mcMMO.getConfigManager().getConfigSalvage().getGeneral().isAnvilMessages()) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Salvage.Listener.Anvil"); + if (pluginRef.getConfigManager().getConfigSalvage().getGeneral().isAnvilMessages()) { + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Salvage.Listener.Anvil"); } - if (mcMMO.getConfigManager().getConfigSalvage().getGeneral().isAnvilPlacedSounds()) { + if (pluginRef.getConfigManager().getConfigSalvage().getGeneral().isAnvilPlacedSounds()) { SoundManager.sendSound(player, player.getLocation(), SoundType.ANVIL); } @@ -60,21 +58,21 @@ public class SalvageManager extends SkillManager { public void handleSalvage(Location location, ItemStack item) { Player player = getPlayer(); - Salvageable salvageable = mcMMO.getSalvageableManager().getSalvageable(item.getType()); + Salvageable salvageable = pluginRef.getSalvageableManager().getSalvageable(item.getType()); if (item.getItemMeta().isUnbreakable()) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Unbreakable"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Unbreakable"); return; } // Permissions checks on material and item types if (!Permissions.salvageItemType(player, salvageable.getSalvageItemType())) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission"); return; } if (!Permissions.salvageMaterialType(player, salvageable.getSalvageItemMaterialCategory())) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission"); return; } @@ -83,14 +81,14 @@ public class SalvageManager extends SkillManager { // Level check if (!RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Salvage.Skills.Adept.Level", String.valueOf(RankUtils.getUnlockLevel(SubSkillType.SALVAGE_ARCANE_SALVAGE)), StringUtils.getPrettyItemString(item.getType())); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Salvage.Skills.Adept.Level", String.valueOf(RankUtils.getUnlockLevel(SubSkillType.SALVAGE_ARCANE_SALVAGE)), StringUtils.getPrettyItemString(item.getType())); return; } int potentialSalvageYield = Salvage.calculateSalvageableAmount(item.getDurability(), salvageable.getMaximumDurability(), salvageable.getMaximumQuantity()); if (potentialSalvageYield <= 0) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.TooDamaged"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.TooDamaged"); return; } @@ -122,11 +120,11 @@ public class SalvageManager extends SkillManager { } if(lotteryResults == potentialSalvageYield && potentialSalvageYield != 1 && RankUtils.isPlayerMaxRankInSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) { - mcMMO.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Perfect", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType())); + pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Perfect", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType())); } else if(salvageable.getMaximumQuantity() == 1 || getSalvageLimit() >= salvageable.getMaximumQuantity()) { - mcMMO.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Normal", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType())); + pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Normal", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType())); } else { - mcMMO.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Untrained", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType())); + pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Untrained", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType())); } ItemStack salvageResults = new ItemStack(salvageable.getSalvagedItemMaterial(), lotteryResults); @@ -156,11 +154,11 @@ public class SalvageManager extends SkillManager { Misc.spawnItemTowardsLocation(anvilLoc.clone(), playerLoc.clone(), salvageResults, vectorSpeed); // BWONG BWONG BWONG - CLUNK! - if (mcMMO.getConfigManager().getConfigSalvage().getGeneral().isAnvilUseSounds()) { + if (pluginRef.getConfigManager().getConfigSalvage().getGeneral().isAnvilUseSounds()) { SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK); } - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Salvage.Skills.Success"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Salvage.Skills.Success"); } /*public double getMaxSalvagePercentage() { @@ -208,18 +206,18 @@ public class SalvageManager extends SkillManager { if (Permissions.hasSalvageEnchantBypassPerk(getPlayer())) return 100.0D; - return mcMMO.getConfigManager().getConfigSalvage().getConfigArcaneSalvage().getExtractFullEnchantChance().get(getArcaneSalvageRank()); + return pluginRef.getConfigManager().getConfigSalvage().getConfigArcaneSalvage().getExtractFullEnchantChance().get(getArcaneSalvageRank()); } public double getExtractPartialEnchantChance() { - return mcMMO.getConfigManager().getConfigSalvage().getConfigArcaneSalvage().getExtractPartialEnchantChance().get(getArcaneSalvageRank()); + return pluginRef.getConfigManager().getConfigSalvage().getConfigArcaneSalvage().getExtractPartialEnchantChance().get(getArcaneSalvageRank()); } private ItemStack arcaneSalvageCheck(Map enchants) { Player player = getPlayer(); if (!RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE) || !Permissions.arcaneSalvage(player)) { - mcMMO.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.ArcaneFailed"); + pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.ArcaneFailed"); return null; } @@ -233,7 +231,7 @@ public class SalvageManager extends SkillManager { int enchantLevel = enchant.getValue(); - if(!mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitSkills().getConfigSectionExploitSalvage().isAllowUnsafeEnchants()) { + if(!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitSkills().getConfigSectionExploitSalvage().isAllowUnsafeEnchants()) { if(enchantLevel > enchant.getKey().getMaxLevel()) { enchantLevel = enchant.getKey().getMaxLevel(); } @@ -257,11 +255,11 @@ public class SalvageManager extends SkillManager { if(failedAllEnchants(arcaneFailureCount, enchants.entrySet().size())) { - mcMMO.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.ArcaneFailed"); + pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.ArcaneFailed"); return null; } else if(downgraded) { - mcMMO.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.ArcanePartial"); + pluginRef.getNotificationManager().sendPlayerInformationChatOnly(player, "Salvage.Skills.ArcanePartial"); } book.setItemMeta(enchantMeta); @@ -282,7 +280,7 @@ public class SalvageManager extends SkillManager { Player player = getPlayer(); long lastUse = getLastAnvilUse(); - if (!SkillUtils.cooldownExpired(lastUse, 3) || !mcMMO.getConfigManager().getConfigSalvage().getGeneral().isEnchantedItemsRequireConfirm()) { + if (!SkillUtils.cooldownExpired(lastUse, 3) || !pluginRef.getConfigManager().getConfigSalvage().getGeneral().isEnchantedItemsRequireConfirm()) { return true; } @@ -292,7 +290,7 @@ public class SalvageManager extends SkillManager { actualizeLastAnvilUse(); - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Skills.ConfirmOrCancel", LocaleLoader.getString("Salvage.Pretty.Name")); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Skills.ConfirmOrCancel", pluginRef.getLocaleManager().getString("Salvage.Pretty.Name")); return false; } diff --git a/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java b/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java index 7e634e68b..79a6446de 100644 --- a/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java +++ b/src/main/java/com/gmail/nossr50/skills/smelting/Smelting.java @@ -1,10 +1,9 @@ package com.gmail.nossr50.skills.smelting; -import com.gmail.nossr50.mcMMO; import org.bukkit.inventory.ItemStack; public class Smelting { protected static int getResourceXp(ItemStack smelting) { - return mcMMO.getDynamicSettingsManager().getExperienceManager().getFurnaceItemXP(smelting.getType()); + return pluginRef.getDynamicSettingsManager().getExperienceManager().getFurnaceItemXP(smelting.getType()); } } diff --git a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java index 04d3345aa..51cecac61 100644 --- a/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java +++ b/src/main/java/com/gmail/nossr50/skills/swords/SwordsManager.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.ToolType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.ItemUtils; @@ -69,16 +68,16 @@ public class SwordsManager extends SkillManager { if (defender.isBlocking()) return; - if (mcMMO.getNotificationManager().doesPlayerUseNotifications(defender)) { + if (pluginRef.getNotificationManager().doesPlayerUseNotifications(defender)) { if (!BleedTimerTask.isBleeding(defender)) - mcMMO.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Started"); + pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Started"); } } BleedTimerTask.add(target, getPlayer(), getRuptureBleedTicks(), RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE), getToolTier(getPlayer().getInventory().getItemInMainHand())); if (mcMMOPlayer.useChatNotifications()) { - mcMMO.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding"); + pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding"); } } } @@ -106,7 +105,7 @@ public class SwordsManager extends SkillManager { } public int getRuptureBleedTicks() { - int bleedTicks = mcMMO.getConfigManager().getConfigSwords().getRuptureBaseTicks() * RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE); + int bleedTicks = pluginRef.getConfigManager().getConfigSwords().getRuptureBaseTicks() * RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE); /*if (bleedTicks > AdvancedConfig.getInstance().getRuptureMaxTicks()) bleedTicks = AdvancedConfig.getInstance().getRuptureMaxTicks();*/ @@ -122,12 +121,12 @@ public class SwordsManager extends SkillManager { */ public void counterAttackChecks(LivingEntity attacker, double damage) { if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SWORDS_COUNTER_ATTACK, getPlayer())) { - CombatUtils.dealDamage(attacker, damage / mcMMO.getConfigManager().getConfigSwords().getCounterAttackDamageModifier(), getPlayer()); + CombatUtils.dealDamage(attacker, damage / pluginRef.getConfigManager().getConfigSwords().getCounterAttackDamageModifier(), getPlayer()); - mcMMO.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Countered"); + pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Countered"); if (attacker instanceof Player) { - mcMMO.getNotificationManager().sendPlayerInformation((Player) attacker, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Counter.Hit"); + pluginRef.getNotificationManager().sendPlayerInformation((Player) attacker, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Counter.Hit"); } } } @@ -139,6 +138,6 @@ public class SwordsManager extends SkillManager { * @param damage The amount of damage initially dealt by the event */ public void serratedStrikes(LivingEntity target, double damage, Map modifiers) { - CombatUtils.applyAbilityAoE(getPlayer(), target, damage / mcMMO.getConfigManager().getConfigSwords().getSerratedStrikesDamageModifier(), modifiers, skill); + CombatUtils.applyAbilityAoE(getPlayer(), target, damage / pluginRef.getConfigManager().getConfigSwords().getSerratedStrikesDamageModifier(), modifiers, skill); } } diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index 4a351f641..e2923eb59 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -9,8 +9,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.events.fake.FakeEntityTameEvent; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.BleedTimerTask; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.Misc; @@ -105,7 +103,7 @@ public class TamingManager extends SkillManager { * @param entity The LivingEntity to award XP for */ public void awardTamingXP(LivingEntity entity) { - applyXpGain(mcMMO.getDynamicSettingsManager().getExperienceManager().getTamingXp(entity.getType()), XPGainReason.PVE); + applyXpGain(pluginRef.getDynamicSettingsManager().getExperienceManager().getTamingXp(entity.getType()), XPGainReason.PVE); } /** @@ -143,10 +141,10 @@ public class TamingManager extends SkillManager { BleedTimerTask.add(target, getPlayer(), Taming.getInstance().getGoreBleedTicks(), 1, 2); if (target instanceof Player) { - mcMMO.getNotificationManager().sendPlayerInformation((Player) target, NotificationType.SUBSKILL_MESSAGE, "Combat.StruckByGore"); + pluginRef.getNotificationManager().sendPlayerInformation((Player) target, NotificationType.SUBSKILL_MESSAGE, "Combat.StruckByGore"); } - mcMMO.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.Gore"); + pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.Gore"); damage = (damage * Taming.getInstance().getGoreModifier()) - damage; return damage; @@ -207,13 +205,13 @@ public class TamingManager extends SkillManager { Player player = getPlayer(); Tameable beast = (Tameable) target; - String message = LocaleLoader.getString("Combat.BeastLore") + " "; + String message = pluginRef.getLocaleManager().getString("Combat.BeastLore") + " "; if (beast.isTamed() && beast.getOwner() != null) { - message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", beast.getOwner().getName()) + " "); + message = message.concat(pluginRef.getLocaleManager().getString("Combat.BeastLoreOwner", beast.getOwner().getName()) + " "); } - message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", target.getHealth(), target.getMaxHealth())); + message = message.concat(pluginRef.getLocaleManager().getString("Combat.BeastLoreHealth", target.getHealth(), target.getMaxHealth())); player.sendMessage(message); } @@ -225,7 +223,7 @@ public class TamingManager extends SkillManager { Player owner = getPlayer(); wolf.teleport(owner); - mcMMO.getNotificationManager().sendPlayerInformation(owner, NotificationType.SUBSKILL_MESSAGE, "Taming.Listener.Wolf"); + pluginRef.getNotificationManager().sendPlayerInformation(owner, NotificationType.SUBSKILL_MESSAGE, "Taming.Listener.Wolf"); } public void pummel(LivingEntity target, Wolf wolf) { @@ -241,8 +239,8 @@ public class TamingManager extends SkillManager { if (target instanceof Player) { Player defender = (Player) target; - if (mcMMO.getNotificationManager().doesPlayerUseNotifications(defender)) { - mcMMO.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Taming.SubSkill.Pummel.TargetMessage"); + if (pluginRef.getNotificationManager().doesPlayerUseNotifications(defender)) { + pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Taming.SubSkill.Pummel.TargetMessage"); } } } @@ -287,7 +285,7 @@ public class TamingManager extends SkillManager { if (heldItemAmount < summonAmount) { int moreAmount = summonAmount - heldItemAmount; - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.NotEnough", String.valueOf(moreAmount), StringUtils.getPrettyItemString(heldItem.getType())); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.NotEnough", String.valueOf(moreAmount), StringUtils.getPrettyItemString(heldItem.getType())); return; } @@ -307,7 +305,7 @@ public class TamingManager extends SkillManager { LivingEntity callOfWildEntity = (LivingEntity) player.getWorld().spawnEntity(location, type); FakeEntityTameEvent event = new FakeEntityTameEvent(callOfWildEntity, player); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { continue; @@ -345,7 +343,7 @@ public class TamingManager extends SkillManager { } if (Permissions.renamePets(player)) { - callOfWildEntity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(type))); + callOfWildEntity.setCustomName(pluginRef.getLocaleManager().getString("Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(type))); } ParticleEffectUtils.playCallOfTheWildEffect(callOfWildEntity); @@ -357,10 +355,10 @@ public class TamingManager extends SkillManager { String lifeSpan = ""; if (tamingCOTWLength > 0) { - lifeSpan = LocaleLoader.getString("Taming.Summon.Lifespan", tamingCOTWLength); + lifeSpan = pluginRef.getLocaleManager().getString("Taming.Summon.Lifespan", tamingCOTWLength); } - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Taming.Summon.Complete", lifeSpan); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Taming.Summon.Complete", lifeSpan); player.playSound(location, Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR, 1F, 0.5F); } @@ -374,7 +372,7 @@ public class TamingManager extends SkillManager { for (Entity entity : player.getNearbyEntities(range, range, range)) { if (entity.getType() == type) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, Taming.getInstance().getCallOfTheWildFailureMessage(type)); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, Taming.getInstance().getCallOfTheWildFailureMessage(type)); return false; } } @@ -395,7 +393,7 @@ public class TamingManager extends SkillManager { int summonAmount = trackedEntities == null ? 0 : trackedEntities.size(); if (summonAmount >= maxAmountSummons) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Taming.Summon.Fail.TooMany", String.valueOf(maxAmountSummons)); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Taming.Summon.Fail.TooMany", String.valueOf(maxAmountSummons)); return false; } diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java index ed76a4bdb..ec4898865 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TrackedTamingEntity.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.skills.taming; import com.gmail.nossr50.config.MainConfig; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; @@ -26,7 +25,7 @@ public class TrackedTamingEntity extends BukkitRunnable { if (tamingCOTWLength > 0) { this.length = tamingCOTWLength * Misc.TICK_CONVERSION_FACTOR; - this.runTaskLater(mcMMO.p, length); + this.runTaskLater(pluginRef, length); } } diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index cc043e098..89df1fe7a 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.ToolType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.ItemUtils; @@ -105,12 +104,12 @@ public class UnarmedManager extends SkillManager { Item item = Misc.dropItem(defender.getLocation(), defender.getInventory().getItemInMainHand()); - if (item != null && mcMMO.getConfigManager().getConfigUnarmed().doesDisarmPreventTheft()) { + if (item != null && pluginRef.getConfigManager().getConfigUnarmed().doesDisarmPreventTheft()) { item.setMetadata(MetadataConstants.DISARMED_ITEM_METAKEY, UserManager.getPlayer(defender).getPlayerMetadata()); } defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR)); - mcMMO.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Skills.Disarmed"); + pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Skills.Disarmed"); } } @@ -119,7 +118,7 @@ public class UnarmedManager extends SkillManager { */ public boolean deflectCheck() { if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_ARROW_DEFLECT, getPlayer())) { - mcMMO.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.ArrowDeflect"); + pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.ArrowDeflect"); return true; } @@ -171,8 +170,8 @@ public class UnarmedManager extends SkillManager { private boolean hasIronGrip(Player defender) { if (!Misc.isNPCEntityExcludingVillagers(defender) && Permissions.isSubSkillEnabled(defender, SubSkillType.UNARMED_IRON_GRIP) && RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_IRON_GRIP, getPlayer())) { - mcMMO.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Defender"); - mcMMO.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Attacker"); + pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Defender"); + pluginRef.getNotificationManager().sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Attacker"); return true; } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index d46e8a474..653e47464 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.woodcutting; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.skills.SkillUtils; @@ -38,7 +37,7 @@ public final class Woodcutting { * @return Amount of experience */ protected static int getExperienceFromLog(BlockState blockState) { - return mcMMO.getDynamicSettingsManager().getExperienceManager().getWoodcuttingXp(blockState.getType()); + return pluginRef.getDynamicSettingsManager().getExperienceManager().getWoodcuttingXp(blockState.getType()); } /** @@ -52,17 +51,17 @@ public final class Woodcutting { * @return Amount of experience */ protected static int processTreeFellerXPGains(BlockState blockState, int woodCount) { - int rawXP = mcMMO.getDynamicSettingsManager().getExperienceManager().getWoodcuttingXp(blockState.getType()); + int rawXP = pluginRef.getDynamicSettingsManager().getExperienceManager().getWoodcuttingXp(blockState.getType()); if(rawXP <= 0) return 0; - if(mcMMO.getConfigManager().getConfigExperience().getExperienceWoodcutting().isReduceTreeFellerXP()) { + if(pluginRef.getConfigManager().getConfigExperience().getExperienceWoodcutting().isReduceTreeFellerXP()) { int reducedXP = 1 + (woodCount * 5); rawXP = Math.max(1, rawXP - reducedXP); return rawXP; } else { - return mcMMO.getDynamicSettingsManager().getExperienceManager().getWoodcuttingXp(blockState.getType()); + return pluginRef.getDynamicSettingsManager().getExperienceManager().getWoodcuttingXp(blockState.getType()); } } @@ -76,7 +75,7 @@ public final class Woodcutting { Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops()); } else {*/ - if (mcMMO.getDynamicSettingsManager().getBonusDropManager().isBonusDropWhitelisted(blockState.getType())) { + if (pluginRef.getDynamicSettingsManager().getBonusDropManager().isBonusDropWhitelisted(blockState.getType())) { Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops()); } //} @@ -166,12 +165,12 @@ public final class Woodcutting { for (BlockState blockState : treeFellerBlocks) { if (BlockUtils.isLog(blockState)) { - durabilityLoss += mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage(); + durabilityLoss += pluginRef.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage(); } } SkillUtils.handleDurabilityChange(inHand, durabilityLoss); - return (inHand.getDurability() < (mcMMO.getRepairableManager().isRepairable(type) ? mcMMO.getRepairableManager().getRepairable(type).getMaximumDurability() : type.getMaxDurability())); + return (inHand.getDurability() < (pluginRef.getRepairableManager().isRepairable(type) ? pluginRef.getRepairableManager().getRepairable(type).getMaximumDurability() : type.getMaxDurability())); } /** @@ -187,12 +186,12 @@ public final class Woodcutting { * in treeFellerBlocks. */ private static boolean handleBlock(BlockState blockState, List futureCenterBlocks, Set treeFellerBlocks) { - if (treeFellerBlocks.contains(blockState) || mcMMO.getPlaceStore().isTrue(blockState)) { + if (treeFellerBlocks.contains(blockState) || pluginRef.getPlaceStore().isTrue(blockState)) { return false; } // Without this check Tree Feller propagates through leaves until the threshold is hit - if (treeFellerBlocks.size() > mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getTreeFeller().getTreeFellerLimit()) { + if (treeFellerBlocks.size() > pluginRef.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getTreeFeller().getTreeFellerLimit()) { treeFellerReachedThreshold = true; } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index 78eedbda6..1c22d53cd 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.random.RandomChanceUtil; @@ -84,13 +83,13 @@ public class WoodcuttingManager extends SkillManager { if (Woodcutting.treeFellerReachedThreshold) { Woodcutting.treeFellerReachedThreshold = false; - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Woodcutting.Skills.TreeFeller.Threshold"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Woodcutting.Skills.TreeFeller.Threshold"); return; } // If the tool can't sustain the durability loss if (!Woodcutting.handleDurabilityLoss(treeFellerBlocks, player.getInventory().getItemInMainHand())) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Woodcutting.Skills.TreeFeller.Splinter"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Woodcutting.Skills.TreeFeller.Splinter"); double health = player.getHealth(); diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index 5f4738c60..c5e4da8ab 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.util; import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.datatypes.meta.BonusDropMeta; import com.gmail.nossr50.datatypes.skills.SubSkillType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.util.random.RandomChanceSkill; @@ -30,9 +29,9 @@ public final class BlockUtils { */ public static void markDropsAsBonus(BlockState blockState, boolean triple) { if (triple) - blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(2, mcMMO.p)); + blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(2, pluginRef)); else - blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(1, mcMMO.p)); + blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(1, pluginRef)); } /** @@ -42,7 +41,7 @@ public final class BlockUtils { * @param amount amount of extra items to drop */ public static void markDropsAsBonus(BlockState blockState, int amount) { - blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(amount, mcMMO.p)); + blockState.setMetadata(MetadataConstants.BONUS_DROPS_METAKEY, new BonusDropMeta(amount, pluginRef)); } /** @@ -52,7 +51,7 @@ public final class BlockUtils { * @return true if the player succeeded in the check */ public static boolean checkDoubleDrops(Player player, BlockState blockState, SubSkillType subSkillType) { - if (mcMMO.getDynamicSettingsManager().isBonusDropsEnabled(blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) { + if (pluginRef.getDynamicSettingsManager().isBonusDropsEnabled(blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) { return RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType, true)); } @@ -97,7 +96,7 @@ public final class BlockUtils { * otherwise */ public static boolean canActivateAbilities(BlockState blockState) { - return !mcMMO.getMaterialMapStore().isAbilityActivationBlackListed(blockState.getType()); + return !pluginRef.getMaterialMapStore().isAbilityActivationBlackListed(blockState.getType()); } /** @@ -109,7 +108,7 @@ public final class BlockUtils { * otherwise */ public static boolean canActivateTools(BlockState blockState) { - return !mcMMO.getMaterialMapStore().isToolActivationBlackListed(blockState.getType()); + return !pluginRef.getMaterialMapStore().isToolActivationBlackListed(blockState.getType()); } /** @@ -129,7 +128,7 @@ public final class BlockUtils { * @return true if the block can be made mossy, false otherwise */ public static boolean canMakeMossy(BlockState blockState) { - return mcMMO.getMaterialMapStore().isMossyWhiteListed(blockState.getType()); + return pluginRef.getMaterialMapStore().isMossyWhiteListed(blockState.getType()); } /** @@ -139,7 +138,7 @@ public final class BlockUtils { * @return true if the block should affected by Green Terra, false otherwise */ public static boolean affectedByGreenTerra(BlockState blockState) { - return mcMMO.getDynamicSettingsManager().getExperienceManager().hasHerbalismXp(blockState.getType()); + return pluginRef.getDynamicSettingsManager().getExperienceManager().hasHerbalismXp(blockState.getType()); } /** @@ -149,7 +148,7 @@ public final class BlockUtils { * @return true if the block should affected by Green Terra, false otherwise */ public static boolean affectedByGreenTerra(Material material) { - return mcMMO.getDynamicSettingsManager().getExperienceManager().hasHerbalismXp(material); + return pluginRef.getDynamicSettingsManager().getExperienceManager().hasHerbalismXp(material); } /** @@ -160,7 +159,7 @@ public final class BlockUtils { * otherwise */ public static Boolean affectedBySuperBreaker(BlockState blockState) { - if (mcMMO.getDynamicSettingsManager().getExperienceManager().hasMiningXp(blockState.getType())) + if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasMiningXp(blockState.getType())) return true; return isMineable(blockState); @@ -174,7 +173,7 @@ public final class BlockUtils { * otherwise */ public static Boolean affectedBySuperBreaker(Material material) { - if (mcMMO.getDynamicSettingsManager().getExperienceManager().hasMiningXp(material)) + if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasMiningXp(material)) return true; return isMineable(material); @@ -225,7 +224,7 @@ public final class BlockUtils { * otherwise */ public static boolean affectedByGigaDrillBreaker(Material material) { - if (mcMMO.getDynamicSettingsManager().getExperienceManager().hasExcavationXp(material)) + if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasExcavationXp(material)) return true; return isDiggable(material); @@ -239,7 +238,7 @@ public final class BlockUtils { * otherwise */ public static boolean affectedByGigaDrillBreaker(BlockState blockState) { - if (mcMMO.getDynamicSettingsManager().getExperienceManager().hasExcavationXp(blockState.getType())) + if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasExcavationXp(blockState.getType())) return true; return isDiggable(blockState); @@ -291,7 +290,7 @@ public final class BlockUtils { * @return true if the block is a log, false otherwise */ public static boolean isLog(BlockState blockState) { - if (mcMMO.getDynamicSettingsManager().getExperienceManager().hasWoodcuttingXp(blockState.getType())) + if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasWoodcuttingXp(blockState.getType())) return true; return isLoggingRelated(blockState); @@ -305,7 +304,7 @@ public final class BlockUtils { * @return true if the block is a log, false otherwise */ public static boolean isLog(Material material) { - if (mcMMO.getDynamicSettingsManager().getExperienceManager().hasWoodcuttingXp(material)) + if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasWoodcuttingXp(material)) return true; return isLoggingRelated(material); @@ -367,7 +366,7 @@ public final class BlockUtils { * @return true if the block is a leaf, false otherwise */ public static boolean isLeaves(BlockState blockState) { - return mcMMO.getMaterialMapStore().isLeavesWhiteListed(blockState.getType()); + return pluginRef.getMaterialMapStore().isLeavesWhiteListed(blockState.getType()); } /** @@ -396,7 +395,7 @@ public final class BlockUtils { * otherwise */ public static boolean canActivateHerbalism(BlockState blockState) { - return mcMMO.getMaterialMapStore().isHerbalismAbilityWhiteListed(blockState.getType()); + return pluginRef.getMaterialMapStore().isHerbalismAbilityWhiteListed(blockState.getType()); } /** @@ -407,7 +406,7 @@ public final class BlockUtils { * otherwise */ public static boolean affectedByBlockCracker(BlockState blockState) { - return mcMMO.getMaterialMapStore().isBlockCrackerWhiteListed(blockState.getType()); + return pluginRef.getMaterialMapStore().isBlockCrackerWhiteListed(blockState.getType()); } /** @@ -417,7 +416,7 @@ public final class BlockUtils { * @return true if the block can be made into Mycelium, false otherwise */ public static boolean canMakeShroomy(BlockState blockState) { - return mcMMO.getMaterialMapStore().isShroomyWhiteListed(blockState.getType()); + return pluginRef.getMaterialMapStore().isShroomyWhiteListed(blockState.getType()); } /** diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index 5e5d1518d..805666f67 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -2,8 +2,6 @@ package com.gmail.nossr50.util; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.CombatUtils; @@ -36,7 +34,7 @@ public final class ChimaeraWing { * @param player Player whose item usage to check */ public static void activationCheck(Player player) { - if (!mcMMO.getConfigManager().getConfigItems().isChimaeraWingEnabled()) { + if (!pluginRef.getConfigManager().getConfigItems().isChimaeraWingEnabled()) { return; } @@ -47,7 +45,7 @@ public final class ChimaeraWing { } if (!Permissions.chimaeraWing(player)) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission"); return; } @@ -63,42 +61,42 @@ public final class ChimaeraWing { int amount = inHand.getAmount(); - if (amount < mcMMO.getConfigManager().getConfigItems().getChimaeraWingUseCost()) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.NotEnough", - String.valueOf(mcMMO.getConfigManager().getConfigItems().getChimaeraWingUseCost() - amount), "Item.ChimaeraWing.Name"); + if (amount < pluginRef.getConfigManager().getConfigItems().getChimaeraWingUseCost()) { + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.NotEnough", + String.valueOf(pluginRef.getConfigManager().getConfigItems().getChimaeraWingUseCost() - amount), "Item.ChimaeraWing.Name"); return; } long lastTeleport = mcMMOPlayer.getChimeraWingLastUse(); - int cooldown = mcMMO.getConfigManager().getConfigItems().getCooldown(); + int cooldown = pluginRef.getConfigManager().getConfigItems().getCooldown(); if (cooldown > 0) { int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, cooldown, player); if (timeRemaining > 0) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Item.Generic.Wait", String.valueOf(timeRemaining)); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Item.Generic.Wait", String.valueOf(timeRemaining)); return; } } long recentlyHurt = mcMMOPlayer.getRecentlyHurt(); - int hurtCooldown = mcMMO.getConfigManager().getConfigItems().getRecentlyHurtCooldown(); + int hurtCooldown = pluginRef.getConfigManager().getConfigItems().getRecentlyHurtCooldown(); if (hurtCooldown > 0) { int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player); if (timeRemaining > 0) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Item.Injured.Wait", String.valueOf(timeRemaining)); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Item.Injured.Wait", String.valueOf(timeRemaining)); return; } } location = player.getLocation(); - if (mcMMO.getConfigManager().getConfigItems().isPreventUndergroundUse()) { + if (pluginRef.getConfigManager().getConfigItems().isPreventUndergroundUse()) { if (location.getY() < player.getWorld().getHighestBlockYAt(location)) { - player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(amount - mcMMO.getConfigManager().getConfigItems().getChimaeraWingUseCost()))); - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.Fail"); + player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(amount - pluginRef.getConfigManager().getConfigItems().getChimaeraWingUseCost()))); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.Fail"); player.updateInventory(); player.setVelocity(new Vector(0, 0.5D, 0)); CombatUtils.dealDamage(player, Misc.getRandom().nextInt((int) (player.getHealth() - 10))); @@ -109,11 +107,11 @@ public final class ChimaeraWing { mcMMOPlayer.actualizeTeleportCommenceLocation(player); - long warmup = mcMMO.getConfigManager().getConfigItems().getChimaeraWingWarmup(); + long warmup = pluginRef.getConfigManager().getConfigItems().getChimaeraWingWarmup(); if (warmup > 0) { - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Teleport.Commencing", String.valueOf(warmup)); - new ChimaeraWingWarmup(mcMMOPlayer).runTaskLater(mcMMO.p, 20 * warmup); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Teleport.Commencing", String.valueOf(warmup)); + new ChimaeraWingWarmup(mcMMOPlayer).runTaskLater(pluginRef, 20 * warmup); } else { chimaeraExecuteTeleport(); } @@ -122,7 +120,7 @@ public final class ChimaeraWing { public static void chimaeraExecuteTeleport() { Player player = mcMMOPlayer.getPlayer(); - if (mcMMO.getConfigManager().getConfigItems().doesChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) { + if (pluginRef.getConfigManager().getConfigItems().doesChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) { player.teleport(player.getBedSpawnLocation()); } else { Location spawnLocation = player.getWorld().getSpawnLocation(); @@ -133,20 +131,20 @@ public final class ChimaeraWing { } } - player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(player.getInventory().getItemInMainHand().getAmount() - mcMMO.getConfigManager().getConfigItems().getChimaeraWingUseCost()))); + player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(player.getInventory().getItemInMainHand().getAmount() - pluginRef.getConfigManager().getConfigItems().getChimaeraWingUseCost()))); player.updateInventory(); mcMMOPlayer.actualizeChimeraWingLastUse(); mcMMOPlayer.setTeleportCommenceLocation(null); - if (mcMMO.getConfigManager().getConfigItems().isChimaeraWingSoundEnabled()) { + if (pluginRef.getConfigManager().getConfigItems().isChimaeraWingSoundEnabled()) { SoundManager.sendSound(player, location, SoundType.CHIMAERA_WING); } - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Item.ChimaeraWing.Pass"); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Item.ChimaeraWing.Pass"); } public static ItemStack getChimaeraWing(int amount) { - Material ingredient = Material.matchMaterial(mcMMO.getConfigManager().getConfigItems().getChimaeraWingRecipeMats()); + Material ingredient = Material.matchMaterial(pluginRef.getConfigManager().getConfigItems().getChimaeraWingRecipeMats()); if(ingredient == null) ingredient = Material.FEATHER; @@ -154,11 +152,11 @@ public final class ChimaeraWing { ItemStack itemStack = new ItemStack(ingredient, amount); ItemMeta itemMeta = itemStack.getItemMeta(); - itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name")); + itemMeta.setDisplayName(ChatColor.GOLD + pluginRef.getLocaleManager().getString("Item.ChimaeraWing.Name")); List itemLore = new ArrayList<>(); itemLore.add("mcMMO Item"); - itemLore.add(LocaleLoader.getString("Item.ChimaeraWing.Lore")); + itemLore.add(pluginRef.getLocaleManager().getString("Item.ChimaeraWing.Lore")); itemMeta.setLore(itemLore); itemStack.setItemMeta(itemMeta); @@ -166,14 +164,14 @@ public final class ChimaeraWing { } public static ShapelessRecipe getChimaeraWingRecipe() { - Material ingredient = Material.matchMaterial(mcMMO.getConfigManager().getConfigItems().getChimaeraWingRecipeMats()); + Material ingredient = Material.matchMaterial(pluginRef.getConfigManager().getConfigItems().getChimaeraWingRecipeMats()); if(ingredient == null) ingredient = Material.FEATHER; - int amount = mcMMO.getConfigManager().getConfigItems().getChimaeraWingUseCost(); + int amount = pluginRef.getConfigManager().getConfigItems().getChimaeraWingUseCost(); - ShapelessRecipe chimaeraWing = new ShapelessRecipe(new NamespacedKey(mcMMO.p, "Chimaera"), getChimaeraWing(1)); + ShapelessRecipe chimaeraWing = new ShapelessRecipe(new NamespacedKey(pluginRef, "Chimaera"), getChimaeraWing(1)); chimaeraWing.addIngredient(amount, ingredient); return chimaeraWing; } diff --git a/src/main/java/com/gmail/nossr50/util/CompatibilityCheck.java b/src/main/java/com/gmail/nossr50/util/CompatibilityCheck.java index fd06c2728..cbb180cc9 100644 --- a/src/main/java/com/gmail/nossr50/util/CompatibilityCheck.java +++ b/src/main/java/com/gmail/nossr50/util/CompatibilityCheck.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.util; -import com.gmail.nossr50.mcMMO; - import java.lang.reflect.Method; public class CompatibilityCheck { @@ -15,7 +13,7 @@ public class CompatibilityCheck { Class checkForClassBaseComponent = Class.forName("net.md_5.bungee.api.chat.BaseComponent"); } catch (ClassNotFoundException | NoSuchMethodException e) { serverAPIOutdated = true; - mcMMO.p.getLogger().severe("You are running an older version of " + software + " that is not compatible with mcMMO, update your server software!"); + pluginRef.getLogger().severe("You are running an older version of " + software + " that is not compatible with mcMMO, update your server software!"); } } } diff --git a/src/main/java/com/gmail/nossr50/util/EventUtils.java b/src/main/java/com/gmail/nossr50/util/EventUtils.java index 111a50489..fb01b2f51 100644 --- a/src/main/java/com/gmail/nossr50/util/EventUtils.java +++ b/src/main/java/com/gmail/nossr50/util/EventUtils.java @@ -30,8 +30,6 @@ import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent; 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.locale.LocaleLoader; -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; @@ -167,7 +165,7 @@ public class EventUtils { public static McMMOPlayerAbilityActivateEvent callPlayerAbilityActivateEvent(Player player, PrimarySkillType skill) { McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, skill); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); return event; } @@ -182,7 +180,7 @@ public class EventUtils { @Deprecated public static SubSkillEvent callSubSkillEvent(Player player, SubSkillType subSkillType) { SubSkillEvent event = new SubSkillEvent(player, subSkillType); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); return event; } @@ -196,20 +194,20 @@ public class EventUtils { */ public static SubSkillEvent callSubSkillEvent(Player player, AbstractSubSkill abstractSubSkill) { SubSkillEvent event = new SubSkillEvent(player, abstractSubSkill); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); return event; } public static void callFakeArmSwingEvent(Player player) { FakePlayerAnimationEvent event = new FakePlayerAnimationEvent(player); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); } public static boolean tryLevelChangeEvent(Player player, PrimarySkillType skill, int levelsChanged, float xpRemoved, boolean isLevelUp, XPGainReason xpGainReason) { McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged, xpGainReason) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged, xpGainReason); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); boolean isCancelled = event.isCancelled(); @@ -225,7 +223,7 @@ public class EventUtils { public static boolean tryLevelEditEvent(Player player, PrimarySkillType skill, int levelsChanged, float xpRemoved, boolean isLevelUp, XPGainReason xpGainReason, int oldLevel) { McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged - oldLevel, xpGainReason) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged, xpGainReason); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); boolean isCancelled = event.isCancelled(); @@ -248,7 +246,7 @@ public class EventUtils { * @return true if the event wasn't cancelled, false otherwise */ public static boolean simulateBlockBreak(Block block, Player player, boolean shouldArmSwing) { - PluginManager pluginManager = mcMMO.p.getServer().getPluginManager(); + PluginManager pluginManager = pluginRef.getServer().getPluginManager(); // Support for NoCheat if (shouldArmSwing) { @@ -271,7 +269,7 @@ public class EventUtils { return; McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName()); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; @@ -279,15 +277,15 @@ public class EventUtils { teleportingPlayer.teleport(targetPlayer); - teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName())); - targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName())); + teleportingPlayer.sendMessage(pluginRef.getLocaleManager().getString("Party.Teleport.Player", targetPlayer.getName())); + targetPlayer.sendMessage(pluginRef.getLocaleManager().getString("Party.Teleport.Target", teleportingPlayer.getName())); mcMMOPlayer.getPartyTeleportRecord().actualizeLastUse(); } public static boolean handlePartyXpGainEvent(Party party, double xpGained) { McMMOPartyXpGainEvent event = new McMMOPartyXpGainEvent(party, xpGained); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); boolean isCancelled = event.isCancelled(); @@ -300,7 +298,7 @@ public class EventUtils { public static boolean handlePartyLevelChangeEvent(Party party, int levelsChanged, double xpRemoved) { McMMOPartyLevelUpEvent event = new McMMOPartyLevelUpEvent(party, levelsChanged); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); boolean isCancelled = event.isCancelled(); @@ -315,7 +313,7 @@ public class EventUtils { public static boolean handleXpGainEvent(Player player, PrimarySkillType skill, double xpGained, XPGainReason xpGainReason) { McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skill, xpGained, xpGainReason); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); boolean isCancelled = event.isCancelled(); @@ -332,7 +330,7 @@ public class EventUtils { return true; McMMOPlayerStatLossEvent event = new McMMOPlayerStatLossEvent(player, levelChanged, experienceChanged); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); boolean isCancelled = event.isCancelled(); @@ -364,8 +362,8 @@ public class EventUtils { public static boolean handleVampirismEvent(Player killer, Player victim, HashMap levelChanged, HashMap experienceChanged) { McMMOPlayerVampirismEvent eventKiller = new McMMOPlayerVampirismEvent(killer, false, levelChanged, experienceChanged); McMMOPlayerVampirismEvent eventVictim = new McMMOPlayerVampirismEvent(victim, true, levelChanged, experienceChanged); - mcMMO.p.getServer().getPluginManager().callEvent(eventKiller); - mcMMO.p.getServer().getPluginManager().callEvent(eventVictim); + pluginRef.getServer().getPluginManager().callEvent(eventKiller); + pluginRef.getServer().getPluginManager().callEvent(eventVictim); boolean isCancelled = eventKiller.isCancelled() || eventVictim.isCancelled(); @@ -413,47 +411,47 @@ public class EventUtils { public static void callAbilityDeactivateEvent(Player player, SuperAbilityType ability) { McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, PrimarySkillType.byAbility(ability)); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); } public static McMMOPlayerFishingTreasureEvent callFishingTreasureEvent(Player player, ItemStack treasureDrop, int treasureXp, Map enchants) { McMMOPlayerFishingTreasureEvent event = enchants.isEmpty() ? new McMMOPlayerFishingTreasureEvent(player, treasureDrop, treasureXp) : new McMMOPlayerMagicHunterEvent(player, treasureDrop, treasureXp, enchants); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); return event; } public static void callFakeFishEvent(Player player, FishHook hook) { FakePlayerFishEvent event = new FakePlayerFishEvent(player, null, hook, PlayerFishEvent.State.FISHING); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); } public static McMMOPlayerRepairCheckEvent callRepairCheckEvent(Player player, short durability, ItemStack repairMaterial, ItemStack repairedObject) { McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, durability, repairMaterial, repairedObject); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); return event; } public static McMMOPlayerPreDeathPenaltyEvent callPreDeathPenaltyEvent(Player player) { McMMOPlayerPreDeathPenaltyEvent event = new McMMOPlayerPreDeathPenaltyEvent(player); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); return event; } public static McMMOPlayerDisarmEvent callDisarmEvent(Player defender) { McMMOPlayerDisarmEvent event = new McMMOPlayerDisarmEvent(defender); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); return event; } public static McMMOPlayerSalvageCheckEvent callSalvageCheckEvent(Player player, ItemStack salvageMaterial, ItemStack salvageResults, ItemStack enchantedBook) { McMMOPlayerSalvageCheckEvent event = new McMMOPlayerSalvageCheckEvent(player, salvageMaterial, salvageResults, enchantedBook); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); return event; } @@ -467,7 +465,7 @@ public class EventUtils { */ public static McMMOPlayerNotificationEvent createAndCallNotificationEvent(Player player, NotificationType notificationType, TextComponent textComponent) { //Init event - McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(notificationType, player, mcMMO.getNotificationManager().getPlayerNotificationSettings(notificationType), textComponent); + McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(notificationType, player, pluginRef.getNotificationManager().getPlayerNotificationSettings(notificationType), textComponent); //Call event Bukkit.getServer().getPluginManager().callEvent(customEvent); @@ -483,7 +481,7 @@ public class EventUtils { */ public static McMMOPlayerNotificationEvent createAndCallNotificationEvent(Player player, NotificationType notificationType, String message) { //Init event - McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(notificationType, player, mcMMO.getNotificationManager().getPlayerNotificationSettings(notificationType), message); + McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(notificationType, player, pluginRef.getNotificationManager().getPlayerNotificationSettings(notificationType), message); //Call event Bukkit.getServer().getPluginManager().callEvent(customEvent); diff --git a/src/main/java/com/gmail/nossr50/util/HardcoreManager.java b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java index 2c3f09e5e..c15729600 100644 --- a/src/main/java/com/gmail/nossr50/util/HardcoreManager.java +++ b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java @@ -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.mcMMO; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; @@ -23,8 +22,8 @@ public final class HardcoreManager { } } - double statLossPercentage = mcMMO.getConfigManager().getConfigHardcore().getDeathPenalty().getPenaltyPercentage(); - int levelThreshold = mcMMO.getConfigManager().getConfigHardcore().getDeathPenalty().getLevelThreshold(); + double statLossPercentage = pluginRef.getConfigManager().getConfigHardcore().getDeathPenalty().getPenaltyPercentage(); + int levelThreshold = pluginRef.getConfigManager().getConfigHardcore().getDeathPenalty().getLevelThreshold(); if (UserManager.getPlayer(player) == null) return; @@ -64,7 +63,7 @@ public final class HardcoreManager { return; } - mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.HARDCORE_MODE, "Hardcore.DeathStatLoss.PlayerDeath", String.valueOf(totalLevelsLost)); + pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.HARDCORE_MODE, "Hardcore.DeathStatLoss.PlayerDeath", String.valueOf(totalLevelsLost)); } public static void invokeVampirism(Player killer, Player victim) { @@ -75,8 +74,8 @@ public final class HardcoreManager { } } - double vampirismStatLeechPercentage = mcMMO.getConfigManager().getConfigHardcore().getVampirism().getPenaltyPercentage(); - int levelThreshold = mcMMO.getConfigManager().getConfigHardcore().getVampirism().getLevelThreshold(); + double vampirismStatLeechPercentage = pluginRef.getConfigManager().getConfigHardcore().getVampirism().getPenaltyPercentage(); + int levelThreshold = pluginRef.getConfigManager().getConfigHardcore().getVampirism().getLevelThreshold(); if (UserManager.getPlayer(killer) == null || UserManager.getPlayer(victim) == null) return; @@ -120,11 +119,11 @@ public final class HardcoreManager { } if (totalLevelsStolen > 0) { - mcMMO.getNotificationManager().sendPlayerInformation(killer, NotificationType.HARDCORE_MODE, "Hardcore.Vampirism.Killer.Success", String.valueOf(totalLevelsStolen), victim.getName()); - mcMMO.getNotificationManager().sendPlayerInformation(victim, NotificationType.HARDCORE_MODE, "Hardcore.Vampirism.Victim.Success", killer.getName(), String.valueOf(totalLevelsStolen)); + pluginRef.getNotificationManager().sendPlayerInformation(killer, NotificationType.HARDCORE_MODE, "Hardcore.Vampirism.Killer.Success", String.valueOf(totalLevelsStolen), victim.getName()); + pluginRef.getNotificationManager().sendPlayerInformation(victim, NotificationType.HARDCORE_MODE, "Hardcore.Vampirism.Victim.Success", killer.getName(), String.valueOf(totalLevelsStolen)); } else { - mcMMO.getNotificationManager().sendPlayerInformation(killer, NotificationType.HARDCORE_MODE, "Hardcore.Vampirism.Killer.Failure", victim.getName()); - mcMMO.getNotificationManager().sendPlayerInformation(victim, NotificationType.HARDCORE_MODE, "Hardcore.Vampirism.Victim.Failure", killer.getName()); + pluginRef.getNotificationManager().sendPlayerInformation(killer, NotificationType.HARDCORE_MODE, "Hardcore.Vampirism.Killer.Failure", victim.getName()); + pluginRef.getNotificationManager().sendPlayerInformation(victim, NotificationType.HARDCORE_MODE, "Hardcore.Vampirism.Victim.Failure", killer.getName()); } } diff --git a/src/main/java/com/gmail/nossr50/util/ItemUtils.java b/src/main/java/com/gmail/nossr50/util/ItemUtils.java index 03023c199..f06d95175 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemUtils.java +++ b/src/main/java/com/gmail/nossr50/util/ItemUtils.java @@ -2,8 +2,6 @@ package com.gmail.nossr50.util; import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory; import com.gmail.nossr50.datatypes.skills.ItemType; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.inventory.FurnaceRecipe; @@ -234,7 +232,7 @@ public final class ItemUtils { * @return true if the item counts as unarmed, false otherwise */ public static boolean isUnarmed(ItemStack item) { - if (mcMMO.getConfigManager().getConfigUnarmed().doItemsCountAsUnarmed()) { + if (pluginRef.getConfigManager().getConfigUnarmed().doItemsCountAsUnarmed()) { return !isMinecraftTool(item); } @@ -629,7 +627,7 @@ public final class ItemUtils { return false; } - for (Recipe recipe : mcMMO.p.getServer().getRecipesFor(item)) { + for (Recipe recipe : pluginRef.getServer().getRecipesFor(item)) { if (recipe instanceof FurnaceRecipe && ((FurnaceRecipe) recipe).getInput().getType().isBlock() && MaterialUtils.isOre(((FurnaceRecipe) recipe).getInput().getType())) { @@ -829,7 +827,7 @@ public final class ItemUtils { * @return true if the item is a miscellaneous drop, false otherwise */ public static boolean isMiscDrop(ItemStack item) { - return mcMMO.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(item.getType()) != null; + return pluginRef.getConfigManager().getConfigParty().getPartyItemShare().getItemShareMap().get(item.getType()) != null; } public static boolean isMcMMOItem(ItemStack item) { @@ -847,6 +845,6 @@ public final class ItemUtils { } ItemMeta itemMeta = item.getItemMeta(); - return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name")); + return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + pluginRef.getLocaleManager().getString("Item.ChimaeraWing.Name")); } } diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index d3faf7735..5dda43bd9 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.util; import com.gmail.nossr50.events.items.McMMOItemSpawnEvent; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableSet; @@ -107,7 +106,7 @@ public final class Misc { // We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event. McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return null; @@ -152,7 +151,7 @@ public final class Misc { // We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event. McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(spawnLocation, clonedItem); - mcMMO.p.getServer().getPluginManager().callEvent(event); + pluginRef.getServer().getPluginManager().callEvent(event); //Something cancelled the event so back out if (event.isCancelled() || event.getItemStack() == null) { @@ -174,17 +173,17 @@ public final class Misc { } public static void profileCleanup(String playerName) { - Player player = mcMMO.p.getServer().getPlayerExact(playerName); + Player player = pluginRef.getServer().getPlayerExact(playerName); if (player != null) { UserManager.remove(player); - new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading } } public static void printProgress(int convertedUsers, int progressInterval, long startMillis) { if ((convertedUsers % progressInterval) == 0) { - mcMMO.p.getLogger().info(String.format("Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / (double) ((System.currentTimeMillis() - startMillis) / TIME_CONVERSION_FACTOR))); + pluginRef.getLogger().info(String.format("Conversion progress: %d users at %.2f users/second", convertedUsers, convertedUsers / (double) ((System.currentTimeMillis() - startMillis) / TIME_CONVERSION_FACTOR))); } } diff --git a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java index 4a5c16e4c..f0b012a30 100644 --- a/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java +++ b/src/main/java/com/gmail/nossr50/util/MobHealthbarUtils.java @@ -37,7 +37,7 @@ public final class MobHealthbarUtils { * @param damage damage done by the attack triggering this */ public static void handleMobHealthbars(LivingEntity target, double damage, mcMMO plugin) { - if (mcMMO.isHealthBarPluginEnabled() || !mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().isEnableHealthBars()) { + if (pluginRef.isHealthBarPluginEnabled() || !pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().isEnableHealthBars()) { return; } @@ -59,25 +59,25 @@ public final class MobHealthbarUtils { } boolean oldNameVisible = target.isCustomNameVisible(); - String newName = createHealthDisplay(mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType(), target, damage); + String newName = createHealthDisplay(pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType(), target, damage); target.setCustomName(newName); target.setCustomNameVisible(true); - int displayTime = Math.max(mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayTimeSeconds(), 1); + int displayTime = Math.max(pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayTimeSeconds(), 1); if (displayTime != -1) { boolean updateName = !ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName)); if (updateName) { - target.setMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, new FixedMetadataValue(mcMMO.p, oldName)); - target.setMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(mcMMO.p, oldNameVisible)); + target.setMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, new FixedMetadataValue(pluginRef, oldName)); + target.setMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(pluginRef, oldNameVisible)); } else if (!target.hasMetadata(MetadataConstants.CUSTOM_NAME_METAKEY)) { - target.setMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, new FixedMetadataValue(mcMMO.p, "")); - target.setMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(mcMMO.p, false)); + target.setMetadata(MetadataConstants.CUSTOM_NAME_METAKEY, new FixedMetadataValue(pluginRef, "")); + target.setMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(pluginRef, false)); } - new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds + new MobHealthDisplayUpdaterTask(target).runTaskLater(pluginRef, displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds } } diff --git a/src/main/java/com/gmail/nossr50/util/Motd.java b/src/main/java/com/gmail/nossr50/util/Motd.java index 9dbdda98e..303907c53 100644 --- a/src/main/java/com/gmail/nossr50/util/Motd.java +++ b/src/main/java/com/gmail/nossr50/util/Motd.java @@ -1,8 +1,6 @@ package com.gmail.nossr50.util; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.SkillUtils; import org.bukkit.entity.Player; @@ -11,8 +9,8 @@ import org.bukkit.plugin.PluginDescriptionFile; import java.text.DecimalFormat; public final class Motd { - public static final String PERK_PREFIX = LocaleLoader.getString("MOTD.PerksPrefix") + " "; - private static final PluginDescriptionFile pluginDescription = mcMMO.p.getDescription(); + public static final String PERK_PREFIX = pluginRef.getLocaleManager().getString("MOTD.PerksPrefix") + " "; + private static final PluginDescriptionFile pluginDescription = pluginRef.getDescription(); private Motd() { } @@ -35,7 +33,7 @@ public final class Motd { */ public static void displayVersion(Player player, String version) { if (Permissions.showversion(player)) { - player.sendMessage(LocaleLoader.getString("MOTD.Version.Overhaul", version)); + player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Version.Overhaul", version)); } } @@ -57,25 +55,25 @@ public final class Motd { String seperator = ""; if (deathStatLossEnabled) { - statLossInfo = LocaleLoader.getString("Hardcore.DeathStatLoss.Name"); + statLossInfo = pluginRef.getLocaleManager().getString("Hardcore.DeathStatLoss.Name"); } if (vampirismEnabled) { - vampirismInfo = LocaleLoader.getString("Hardcore.Vampirism.Name"); + vampirismInfo = pluginRef.getLocaleManager().getString("Hardcore.Vampirism.Name"); } if (deathStatLossEnabled && vampirismEnabled) { seperator = " & "; } - player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Enabled", statLossInfo + seperator + vampirismInfo)); + player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Hardcore.Enabled", statLossInfo + seperator + vampirismInfo)); if (deathStatLossEnabled) { - player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.DeathStatLoss.Stats", mcMMO.getConfigManager().getConfigHardcore().getDeathPenalty().getPenaltyPercentage())); + player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Hardcore.DeathStatLoss.Stats", pluginRef.getConfigManager().getConfigHardcore().getDeathPenalty().getPenaltyPercentage())); } if (vampirismEnabled) { - player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Vampirism.Stats", mcMMO.getConfigManager().getConfigHardcore().getVampirism().getPenaltyPercentage())); + player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Hardcore.Vampirism.Stats", pluginRef.getConfigManager().getConfigHardcore().getVampirism().getPenaltyPercentage())); } } @@ -87,7 +85,7 @@ public final class Motd { public static void displayXpPerks(Player player) { for (PrimarySkillType skill : PrimarySkillType.values()) { // if (PerksUtils.handleXpPerks(player, 1, skill) > 1) { -// player.sendMessage(PERK_PREFIX + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.XP.Name"), LocaleLoader.getString("Perks.XP.Desc"))); +// player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.XP.Name"), pluginRef.getLocaleManager().getString("Perks.XP.Desc"))); // return; // } } @@ -103,7 +101,7 @@ public final class Motd { if (cooldownReduction > 0.0) { DecimalFormat percent = new DecimalFormat("##0.00%"); - player.sendMessage(PERK_PREFIX + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.Cooldowns.Name"), LocaleLoader.getString("Perks.Cooldowns.Desc", percent.format(cooldownReduction)))); + player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.Cooldowns.Name"), pluginRef.getLocaleManager().getString("Perks.Cooldowns.Desc", percent.format(cooldownReduction)))); } } @@ -116,7 +114,7 @@ public final class Motd { int perkAmount = SkillUtils.getEnduranceLength(player); if (perkAmount > 0) { - player.sendMessage(PERK_PREFIX + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.ActivationTime.Name"), LocaleLoader.getString("Perks.ActivationTime.Desc", perkAmount))); + player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.ActivationTime.Name"), pluginRef.getLocaleManager().getString("Perks.ActivationTime.Desc", perkAmount))); } } @@ -128,7 +126,7 @@ public final class Motd { public static void displayLuckyPerks(Player player) { for (PrimarySkillType skill : PrimarySkillType.values()) { if (Permissions.lucky(player, skill)) { - player.sendMessage(PERK_PREFIX + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.Lucky.Name"), LocaleLoader.getString("Perks.Lucky.Desc.Login"))); + player.sendMessage(PERK_PREFIX + pluginRef.getLocaleManager().getString("Effects.Template", pluginRef.getLocaleManager().getString("Perks.Lucky.Name"), pluginRef.getLocaleManager().getString("Perks.Lucky.Desc.Login"))); return; } } @@ -141,6 +139,6 @@ public final class Motd { * @param website Plugin website */ public static void displayWebsite(Player player, String website) { - player.sendMessage(LocaleLoader.getString("MOTD.Website", website)); + player.sendMessage(pluginRef.getLocaleManager().getString("MOTD.Website", website)); } } diff --git a/src/main/java/com/gmail/nossr50/util/Permissions.java b/src/main/java/com/gmail/nossr50/util/Permissions.java index e32e20ee9..b1352765c 100644 --- a/src/main/java/com/gmail/nossr50/util/Permissions.java +++ b/src/main/java/com/gmail/nossr50/util/Permissions.java @@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.skills.ItemType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; -import com.gmail.nossr50.mcMMO; import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.World; @@ -511,7 +510,7 @@ public final class Permissions { } public static void generateWorldTeleportPermissions() { - Server server = mcMMO.p.getServer(); + Server server = pluginRef.getServer(); PluginManager pluginManager = server.getPluginManager(); for (World world : server.getWorlds()) { @@ -524,10 +523,10 @@ public final class Permissions { * This method registers Permissions with the server software as needed */ public static void addCustomXPPerks() { - mcMMO.p.getLogger().info("Registering custom XP perks with server software..."); - PluginManager pluginManager = mcMMO.p.getServer().getPluginManager(); + pluginRef.getLogger().info("Registering custom XP perks with server software..."); + PluginManager pluginManager = pluginRef.getServer().getPluginManager(); - for (CustomXPPerk customXPPerk : mcMMO.getConfigManager().getConfigExperience().getCustomXPBoosts()) { + for (CustomXPPerk customXPPerk : pluginRef.getConfigManager().getConfigExperience().getCustomXPBoosts()) { Permission permission = new Permission(customXPPerk.getPerkPermissionAddress()); permission.setDefault(PermissionDefault.FALSE); diff --git a/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java b/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java index 68331e0e3..ea3f57bf4 100644 --- a/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java +++ b/src/main/java/com/gmail/nossr50/util/TextComponentFactory.java @@ -6,8 +6,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.listeners.InteractionManager; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.skills.RankUtils; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatMessageType; @@ -23,7 +21,7 @@ import java.util.List; public class TextComponentFactory { /** - * Makes a text component using strings from a locale and supports passing an undefined number of variables to the LocaleLoader + * Makes a text component using strings from a locale and supports passing an undefined number of variables to the LocaleManager * * @param localeKey target locale string address * @param values vars to be passed to the locale loader @@ -31,18 +29,18 @@ public class TextComponentFactory { */ public static TextComponent getNotificationMultipleValues(String localeKey, String... values) { - String preColoredString = LocaleLoader.getString(localeKey, (Object[]) values); + String preColoredString = pluginRef.getLocaleManager().getString(localeKey, (Object[]) values); TextComponent msg = new TextComponent(preColoredString); return new TextComponent(msg); } public static TextComponent getNotificationTextComponentFromLocale(String localeKey) { - return getNotificationTextComponent(LocaleLoader.getString(localeKey)); + return getNotificationTextComponent(pluginRef.getLocaleManager().getString(localeKey)); } public static TextComponent getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel) { - TextComponent textComponent = new TextComponent(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name." + StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel)); + TextComponent textComponent = new TextComponent(pluginRef.getLocaleManager().getString("Overhaul.Levelup", pluginRef.getLocaleManager().getString("Overhaul.Name." + StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel)); return textComponent; } @@ -52,12 +50,12 @@ public class TextComponentFactory { } public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted) { - if (!mcMMO.getConfigManager().getConfigAds().isShowWebsiteLinks()) + if (!pluginRef.getConfigManager().getConfigAds().isShowWebsiteLinks()) return; Player.Spigot spigotPlayer = player.spigot(); - TextComponent wikiLinkComponent = new TextComponent(LocaleLoader.getString("Overhaul.mcMMO.MmoInfo.Wiki")); + TextComponent wikiLinkComponent = new TextComponent(pluginRef.getLocaleManager().getString("Overhaul.mcMMO.MmoInfo.Wiki")); wikiLinkComponent.setUnderlined(true); String wikiUrl = "https://mcmmo.org/wiki/" + subskillformatted; @@ -74,14 +72,14 @@ public class TextComponentFactory { public static void sendPlayerUrlHeader(Player player) { Player.Spigot spigotPlayer = player.spigot(); - TextComponent prefix = new TextComponent(LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Prefix") + " "); + TextComponent prefix = new TextComponent(pluginRef.getLocaleManager().getString("Overhaul.mcMMO.Url.Wrap.Prefix") + " "); /*prefix.setColor(ChatColor.DARK_AQUA);*/ - TextComponent suffix = new TextComponent(" " + LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Suffix")); + TextComponent suffix = new TextComponent(" " + pluginRef.getLocaleManager().getString("Overhaul.mcMMO.Url.Wrap.Suffix")); /*suffix.setColor(ChatColor.DARK_AQUA);*/ TextComponent emptySpace = new TextComponent(" "); - if (mcMMO.getConfigManager().getConfigAds().isShowPatreonInfo()) { + if (pluginRef.getConfigManager().getConfigAds().isShowPatreonInfo()) { BaseComponent[] baseComponents = {new TextComponent(prefix), getWebLinkTextComponent(McMMOWebLinks.WEBSITE), emptySpace, @@ -133,7 +131,7 @@ public class TextComponentFactory { //Style the skills into @links final String originalTxt = textComponent.getText(); - TextComponent stylizedText = new TextComponent(LocaleLoader.getString("JSON.Hover.AtSymbolSkills")); + TextComponent stylizedText = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.AtSymbolSkills")); addChild(stylizedText, originalTxt); if (textComponent.getHoverEvent() != null) @@ -162,32 +160,32 @@ public class TextComponentFactory { switch (webLinks) { case WEBSITE: - webTextComponent = new TextComponent(LocaleLoader.getString("JSON.Hover.AtSymbolURL")); + webTextComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.AtSymbolURL")); addChild(webTextComponent, "Web"); webTextComponent.setClickEvent(getUrlClickEvent(McMMOUrl.urlWebsite)); break; case SPIGOT: - webTextComponent = new TextComponent(LocaleLoader.getString("JSON.Hover.AtSymbolURL")); + webTextComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.AtSymbolURL")); addChild(webTextComponent, "Spigot"); webTextComponent.setClickEvent(getUrlClickEvent(McMMOUrl.urlSpigot)); break; case DISCORD: - webTextComponent = new TextComponent(LocaleLoader.getString("JSON.Hover.AtSymbolURL")); + webTextComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.AtSymbolURL")); addChild(webTextComponent, "Discord"); webTextComponent.setClickEvent(getUrlClickEvent(McMMOUrl.urlDiscord)); break; case PATREON: - webTextComponent = new TextComponent(LocaleLoader.getString("JSON.Hover.AtSymbolURL")); + webTextComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.AtSymbolURL")); addChild(webTextComponent, "Patreon"); webTextComponent.setClickEvent(getUrlClickEvent(McMMOUrl.urlPatreon)); break; case WIKI: - webTextComponent = new TextComponent(LocaleLoader.getString("JSON.Hover.AtSymbolURL")); + webTextComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.AtSymbolURL")); addChild(webTextComponent, "Wiki"); webTextComponent.setClickEvent(getUrlClickEvent(McMMOUrl.urlWiki)); break; case HELP_TRANSLATE: - webTextComponent = new TextComponent(LocaleLoader.getString("JSON.Hover.AtSymbolURL")); + webTextComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.AtSymbolURL")); addChild(webTextComponent, "Lang"); webTextComponent.setClickEvent(getUrlClickEvent(McMMOUrl.urlTranslate)); break; @@ -308,14 +306,14 @@ public class TextComponentFactory { TextComponent textComponent; if (skillUnlocked) { if (RankUtils.getHighestRank(subSkillType) == RankUtils.getRank(player, subSkillType) && subSkillType.getNumRanks() > 1) - textComponent = new TextComponent(LocaleLoader.getString("JSON.Hover.MaxRankSkillName", skillName)); + textComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.MaxRankSkillName", skillName)); else - textComponent = new TextComponent(LocaleLoader.getString("JSON.Hover.SkillName", skillName)); + textComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.SkillName", skillName)); textComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/mmoinfo " + subSkillType.getNiceNameNoSpaces(subSkillType))); } else { - textComponent = new TextComponent(LocaleLoader.getString("JSON.Hover.Mystery", + textComponent = new TextComponent(pluginRef.getLocaleManager().getString("JSON.Hover.Mystery", String.valueOf(RankUtils.getUnlockLevel(subSkillType)))); textComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/mmoinfo ???")); @@ -376,7 +374,7 @@ public class TextComponentFactory { addRanked(ccRank, ccCurRank, ccPossessive, ccNumRanks, componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(player, abstractSubSkill), nextRank); - componentBuilder.append(LocaleLoader.getString("JSON.DescriptionHeader")); + componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.DescriptionHeader")); componentBuilder.append("\n").append(abstractSubSkill.getDescription()).append("\n"); //Empty line @@ -394,11 +392,11 @@ public class TextComponentFactory { ComponentBuilder componentBuilder; if (skillUnlocked) { if (RankUtils.getHighestRank(subSkillType) == RankUtils.getRank(player, subSkillType) && subSkillType.getNumRanks() > 1) - componentBuilder = getNewComponentBuilder(LocaleLoader.getString("JSON.Hover.MaxRankSkillName", skillName)); + componentBuilder = getNewComponentBuilder(pluginRef.getLocaleManager().getString("JSON.Hover.MaxRankSkillName", skillName)); else - componentBuilder = getNewComponentBuilder(LocaleLoader.getString("JSON.Hover.SkillName", skillName)); + componentBuilder = getNewComponentBuilder(pluginRef.getLocaleManager().getString("JSON.Hover.SkillName", skillName)); } else - componentBuilder = getNewComponentBuilder(LocaleLoader.getString("JSON.Hover.Mystery", + componentBuilder = getNewComponentBuilder(pluginRef.getLocaleManager().getString("JSON.Hover.Mystery", String.valueOf(RankUtils.getUnlockLevel(subSkillType)))); return componentBuilder; } @@ -412,15 +410,15 @@ public class TextComponentFactory { private static void addRanked(ChatColor ccRank, ChatColor ccCurRank, ChatColor ccPossessive, ChatColor ccNumRanks, ComponentBuilder componentBuilder, int numRanks, int rank, int nextRank) { if (numRanks > 0) { //Rank: x - componentBuilder.append(LocaleLoader.getString("JSON.Hover.Rank", String.valueOf(rank))).append("\n") + componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.Hover.Rank", String.valueOf(rank))).append("\n") .bold(false).italic(false).strikethrough(false).underlined(false); //Next Rank: x if (nextRank > rank) - componentBuilder.append(LocaleLoader.getString("JSON.Hover.NextRank", String.valueOf(nextRank))).append("\n") + componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.Hover.NextRank", String.valueOf(nextRank))).append("\n") .bold(false).italic(false).strikethrough(false).underlined(false); - /*componentBuilder.append(" " + LocaleLoader.getString("JSON.RankPossesive") + " ").color(ccPossessive); + /*componentBuilder.append(" " + pluginRef.getLocaleManager().getString("JSON.RankPossesive") + " ").color(ccPossessive); componentBuilder.append(String.valueOf(numRanks)).color(ccNumRanks);*/ } } @@ -438,9 +436,9 @@ public class TextComponentFactory { } private static void addLocked(ChatColor ccLocked, ChatColor ccLevelRequirement, ComponentBuilder componentBuilder) { - componentBuilder.append(LocaleLoader.getString("JSON.Locked")).color(ccLocked).bold(true); + componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.Locked")).color(ccLocked).bold(true); componentBuilder.append("\n").append("\n").bold(false); - componentBuilder.append(LocaleLoader.getString("JSON.LevelRequirement") + ": ").color(ccLevelRequirement); + componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.LevelRequirement") + ": ").color(ccLevelRequirement); } @Deprecated @@ -484,7 +482,7 @@ public class TextComponentFactory { } componentBuilder.append("\n").bold(false); - componentBuilder.append(LocaleLoader.getString("JSON.DescriptionHeader")); + componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.DescriptionHeader")); componentBuilder.color(ccDescriptionHeader); componentBuilder.append("\n"); componentBuilder.append(subSkillType.getLocaleDescription()); @@ -496,13 +494,13 @@ public class TextComponentFactory { private static void addSubSkillTypeToHoverEventJSON(AbstractSubSkill abstractSubSkill, ComponentBuilder componentBuilder) { if (abstractSubSkill.isSuperAbility()) { - componentBuilder.append(LocaleLoader.getString("JSON.Type.SuperAbility")).color(ChatColor.LIGHT_PURPLE); + componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.Type.SuperAbility")).color(ChatColor.LIGHT_PURPLE); componentBuilder.bold(true); } else if (abstractSubSkill.isActiveUse()) { - componentBuilder.append(LocaleLoader.getString("JSON.Type.Active")).color(ChatColor.DARK_RED); + componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.Type.Active")).color(ChatColor.DARK_RED); componentBuilder.bold(true); } else { - componentBuilder.append(LocaleLoader.getString("JSON.Type.Passive")).color(ChatColor.GREEN); + componentBuilder.append(pluginRef.getLocaleManager().getString("JSON.Type.Passive")).color(ChatColor.GREEN); componentBuilder.bold(true); } @@ -530,7 +528,7 @@ public class TextComponentFactory { public static TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType) { TextComponent unlockMessage = new TextComponent(""); - unlockMessage.setText(LocaleLoader.getString("JSON.SkillUnlockMessage", subSkillType.getLocaleName(), RankUtils.getRank(player, subSkillType))); + unlockMessage.setText(pluginRef.getLocaleManager().getString("JSON.SkillUnlockMessage", subSkillType.getLocaleName(), RankUtils.getRank(player, subSkillType))); unlockMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, getSubSkillHoverComponent(player, subSkillType))); unlockMessage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + subSkillType.getParentSkill().toString().toLowerCase())); return unlockMessage; diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java index 43f500b81..093da6243 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.blockmeta; -import com.gmail.nossr50.mcMMO; import org.bukkit.World; import org.bukkit.block.Block; @@ -160,7 +159,7 @@ public class HashChunkletManager implements ChunkletManager { @Override public void saveAll() { - for (World world : mcMMO.p.getServer().getWorlds()) { + for (World world : pluginRef.getServer().getWorlds()) { saveWorld(world); } } @@ -168,7 +167,7 @@ public class HashChunkletManager implements ChunkletManager { @Override public void unloadAll() { saveAll(); - for (World world : mcMMO.p.getServer().getWorlds()) { + for (World world : pluginRef.getServer().getWorlds()) { unloadWorld(world); } } @@ -269,7 +268,7 @@ public class HashChunkletManager implements ChunkletManager { for (String key : store.keySet()) { if (store.get(key).isEmpty()) { String[] info = key.split(","); - File dataDir = new File(mcMMO.p.getServer().getWorld(info[0]).getWorldFolder(), "mcmmo_data"); + File dataDir = new File(pluginRef.getServer().getWorld(info[0]).getWorldFolder(), "mcmmo_data"); File cxDir = new File(dataDir, "" + info[1]); if (!cxDir.exists()) { diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java index d8cee27e3..f414c75a3 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.blockmeta.chunkmeta; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory; import org.bukkit.World; import org.bukkit.block.Block; @@ -250,7 +249,7 @@ public class HashChunkManager implements ChunkManager { public synchronized void saveAll() { closeAll(); - for (World world : mcMMO.p.getServer().getWorlds()) { + for (World world : pluginRef.getServer().getWorlds()) { saveWorld(world); } } @@ -259,7 +258,7 @@ public class HashChunkManager implements ChunkManager { public synchronized void unloadAll() { closeAll(); - for (World world : mcMMO.p.getServer().getWorlds()) { + for (World world : pluginRef.getServer().getWorlds()) { unloadWorld(world); } } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java index ad2cd1c4e..7e10ec247 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionMain.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.util.blockmeta.conversion; import com.gmail.nossr50.core.ChunkConversionOptions; -import com.gmail.nossr50.mcMMO; import org.bukkit.scheduler.BukkitScheduler; import java.io.File; @@ -17,7 +16,7 @@ public class BlockStoreConversionMain implements Runnable { public BlockStoreConversionMain(org.bukkit.World world) { this.taskID = -1; this.world = world; - this.scheduler = mcMMO.p.getServer().getScheduler(); + this.scheduler = pluginRef.getServer().getScheduler(); this.dataDir = new File(this.world.getWorldFolder(), "mcmmo_data"); this.converters = new BlockStoreConversionXDirectory[ChunkConversionOptions.getConversionRate()]; } @@ -27,7 +26,7 @@ public class BlockStoreConversionMain implements Runnable { return; } - this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); + this.taskID = this.scheduler.runTaskLater(pluginRef, this, 1).getTaskId(); } @Override @@ -79,7 +78,7 @@ public class BlockStoreConversionMain implements Runnable { return; } - mcMMO.p.getLogger().info("Finished converting the storage for " + world.getName() + "."); + pluginRef.getLogger().info("Finished converting the storage for " + world.getName() + "."); this.dataDir = null; this.xDirs = null; diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java index 3e0077f9d..011ad7ea3 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionXDirectory.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.util.blockmeta.conversion; import com.gmail.nossr50.core.ChunkConversionOptions; -import com.gmail.nossr50.mcMMO; import org.bukkit.scheduler.BukkitScheduler; import java.io.File; @@ -20,7 +19,7 @@ public class BlockStoreConversionXDirectory implements Runnable { public void start(org.bukkit.World world, File dataDir) { this.world = world; - this.scheduler = mcMMO.p.getServer().getScheduler(); + this.scheduler = pluginRef.getServer().getScheduler(); this.converters = new BlockStoreConversionZDirectory[ChunkConversionOptions.getConversionRate()]; this.dataDir = dataDir; @@ -28,7 +27,7 @@ public class BlockStoreConversionXDirectory implements Runnable { return; } - this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); + this.taskID = this.scheduler.runTaskLater(pluginRef, this, 1).getTaskId(); } @Override diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java index ccc144ef6..9d1421150 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/conversion/BlockStoreConversionZDirectory.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.blockmeta.conversion; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.blockmeta.ChunkletStore; import com.gmail.nossr50.util.blockmeta.HashChunkletManager; import com.gmail.nossr50.util.blockmeta.PrimitiveChunkletStore; @@ -30,9 +29,9 @@ public class BlockStoreConversionZDirectory implements Runnable { public void start(org.bukkit.World world, File xDir, File dataDir) { this.world = world; - this.scheduler = mcMMO.p.getServer().getScheduler(); + this.scheduler = pluginRef.getServer().getScheduler(); this.manager = new HashChunkletManager(); - this.newManager = (HashChunkManager) mcMMO.getPlaceStore(); + this.newManager = (HashChunkManager) pluginRef.getPlaceStore(); this.dataDir = dataDir; this.xDir = xDir; @@ -40,7 +39,7 @@ public class BlockStoreConversionZDirectory implements Runnable { return; } - this.taskID = this.scheduler.runTaskLater(mcMMO.p, this, 1).getTaskId(); + this.taskID = this.scheduler.runTaskLater(pluginRef, this, 1).getTaskId(); } @Override diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java index 4d6725256..0673783dd 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java @@ -18,7 +18,6 @@ import com.gmail.nossr50.commands.player.*; import com.gmail.nossr50.commands.server.ReloadCommand; import com.gmail.nossr50.commands.skills.*; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; import org.bukkit.command.PluginCommand; @@ -28,7 +27,7 @@ import java.util.List; public final class CommandRegistrationManager { private mcMMO pluginRef; - private String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission"); + private String permissionsMessage = pluginRef.getLocaleManager().getString("mcMMO.NoPermission"); public CommandRegistrationManager(mcMMO pluginRef) { this.pluginRef = pluginRef; @@ -41,12 +40,12 @@ public final class CommandRegistrationManager { PluginCommand command; - command = mcMMO.p.getCommand(commandName); - command.setDescription(LocaleLoader.getString("Commands.Description.Skill", StringUtils.getCapitalized(localizedName))); + command = pluginRef.getCommand(commandName); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.Skill", StringUtils.getCapitalized(localizedName))); command.setPermission("mcmmo.commands." + commandName); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", localizedName)); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.2", localizedName, "?", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", localizedName)); + command.setUsage(command.getUsage() + "\n" + pluginRef.getLocaleManager().getString("Commands.Usage.2", localizedName, "?", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Page") + "]")); switch (skill) { case ACROBATICS: @@ -116,83 +115,83 @@ public final class CommandRegistrationManager { } private void registerAddlevelsCommand() { - PluginCommand command = mcMMO.p.getCommand("addlevels"); - command.setDescription(LocaleLoader.getString("Commands.Description.addlevels")); + PluginCommand command = pluginRef.getCommand("addlevels"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.addlevels")); command.setPermission("mcmmo.commands.addlevels;mcmmo.commands.addlevels.others"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addlevels", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.3", "addlevels", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "]", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Skill") + ">", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Level") + ">")); command.setExecutor(new AddlevelsCommand()); } private void registerAddxpCommand() { - PluginCommand command = mcMMO.p.getCommand("addxp"); - command.setDescription(LocaleLoader.getString("Commands.Description.addxp")); + PluginCommand command = pluginRef.getCommand("addxp"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.addxp")); command.setPermission("mcmmo.commands.addxp;mcmmo.commands.addxp.others"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.3", "addxp", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "]", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Skill") + ">", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.XP") + ">")); command.setExecutor(new AddxpCommand()); } private void registerMcgodCommand() { - PluginCommand command = mcMMO.p.getCommand("mcgod"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcgod")); + PluginCommand command = pluginRef.getCommand("mcgod"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcgod")); command.setPermission("mcmmo.commands.mcgod;mcmmo.commands.mcgod.others"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcgod", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "mcgod", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "]")); command.setExecutor(new McgodCommand()); } private void registerMmoInfoCommand() { - PluginCommand command = mcMMO.p.getCommand("mmoinfo"); - command.setDescription(LocaleLoader.getString("Commands.Description.mmoinfo")); + PluginCommand command = pluginRef.getCommand("mmoinfo"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mmoinfo")); command.setPermission("mcmmo.commands.mmoinfo"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mmoinfo", "[" + LocaleLoader.getString("Commands.Usage.SubSkill") + "]")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "mmoinfo", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.SubSkill") + "]")); command.setExecutor(new MmoInfoCommand()); } private void registerMcChatSpyCommand() { - PluginCommand command = mcMMO.p.getCommand("mcchatspy"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcchatspy")); + PluginCommand command = pluginRef.getCommand("mcchatspy"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcchatspy")); command.setPermission("mcmmo.commands.mcchatspy;mcmmo.commands.mcchatspy.others"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcchatspy", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "mcchatspy", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "]")); command.setExecutor(new McChatSpy()); } private void registerMcrefreshCommand() { - PluginCommand command = mcMMO.p.getCommand("mcrefresh"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh")); + PluginCommand command = pluginRef.getCommand("mcrefresh"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcrefresh")); command.setPermission("mcmmo.commands.mcrefresh;mcmmo.commands.mcrefresh.others"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrefresh", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "mcrefresh", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "]")); command.setExecutor(new McrefreshCommand()); } private void registerMmoeditCommand() { - PluginCommand command = mcMMO.p.getCommand("mmoedit"); - command.setDescription(LocaleLoader.getString("Commands.Description.mmoedit")); + PluginCommand command = pluginRef.getCommand("mmoedit"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mmoedit")); command.setPermission("mcmmo.commands.mmoedit;mcmmo.commands.mmoedit.others"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.3", "mmoedit", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.Level") + ">")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.3", "mmoedit", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "]", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Skill") + ">", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Level") + ">")); command.setExecutor(new MmoeditCommand()); } private void registerMcmmoReloadCommand() { - PluginCommand command = mcMMO.p.getCommand("mcmmoreload"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcmmoreload")); + PluginCommand command = pluginRef.getCommand("mcmmoreload"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcmmoreload")); command.setPermission("mcmmo.commands.reload"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmoreload")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "mcmmoreload")); command.setExecutor(new ReloadCommand(pluginRef)); } private void registerSkillresetCommand() { - PluginCommand command = mcMMO.p.getCommand("skillreset"); - command.setDescription(LocaleLoader.getString("Commands.Description.skillreset")); + PluginCommand command = pluginRef.getCommand("skillreset"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.skillreset")); command.setPermission("mcmmo.commands.skillreset;mcmmo.commands.skillreset.others"); // Only need the main ones, not the individual skill ones command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.2", "skillreset", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "skillreset", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "]", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Skill") + ">")); command.setExecutor(new SkillresetCommand()); } @@ -200,142 +199,142 @@ public final class CommandRegistrationManager { List aliasList = new ArrayList<>(); aliasList.add("mcxprate"); - PluginCommand command = mcMMO.p.getCommand("xprate"); - command.setDescription(LocaleLoader.getString("Commands.Description.xprate")); + PluginCommand command = pluginRef.getCommand("xprate"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.xprate")); command.setPermission("mcmmo.commands.xprate;mcmmo.commands.xprate.reset;mcmmo.commands.xprate.set"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.2", "xprate", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">", "")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "xprate", "reset")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "xprate", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Rate") + ">", "")); + command.setUsage(command.getUsage() + "\n" + pluginRef.getLocaleManager().getString("Commands.Usage.1", "xprate", "reset")); command.setAliases(aliasList); command.setExecutor(new XprateCommand()); } private void registerInspectCommand() { - PluginCommand command = mcMMO.p.getCommand("inspect"); - command.setDescription(LocaleLoader.getString("Commands.Description.inspect")); + PluginCommand command = pluginRef.getCommand("inspect"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.inspect")); command.setPermission("mcmmo.commands.inspect;mcmmo.commands.inspect.far;mcmmo.commands.inspect.offline"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "inspect", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "inspect", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">")); command.setExecutor(new InspectCommand()); } private void registerMccooldownCommand() { - PluginCommand command = mcMMO.p.getCommand("mccooldown"); - command.setDescription(LocaleLoader.getString("Commands.Description.mccooldown")); + PluginCommand command = pluginRef.getCommand("mccooldown"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mccooldown")); command.setPermission("mcmmo.commands.mccooldown"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mccooldowns")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "mccooldowns")); command.setExecutor(new MccooldownCommand()); } private void registerMcabilityCommand() { - PluginCommand command = mcMMO.p.getCommand("mcability"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcability")); + PluginCommand command = pluginRef.getCommand("mcability"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcability")); command.setPermission("mcmmo.commands.mcability;mcmmo.commands.mcability.others"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcability", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "mcability", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "]")); command.setExecutor(new McabilityCommand()); } private void registerMcmmoCommand() { - PluginCommand command = mcMMO.p.getCommand("mcmmo"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo")); + PluginCommand command = pluginRef.getCommand("mcmmo"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcmmo")); command.setPermission("mcmmo.commands.mcmmo.description;mcmmo.commands.mcmmo.help"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmo")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "mcmmo", "help")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "mcmmo")); + command.setUsage(command.getUsage() + "\n" + pluginRef.getLocaleManager().getString("Commands.Usage.1", "mcmmo", "help")); command.setExecutor(new McmmoCommand()); } private void registerMcrankCommand() { - PluginCommand command = mcMMO.p.getCommand("mcrank"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcrank")); + PluginCommand command = pluginRef.getCommand("mcrank"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcrank")); command.setPermission("mcmmo.commands.mcrank;mcmmo.commands.mcrank.others;mcmmo.commands.mcrank.others.far;mcmmo.commands.mcrank.others.offline"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcrank", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "mcrank", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + "]")); command.setExecutor(new McrankCommand()); } private void registerMcstatsCommand() { - PluginCommand command = mcMMO.p.getCommand("mcstats"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcstats")); + PluginCommand command = pluginRef.getCommand("mcstats"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcstats")); command.setPermission("mcmmo.commands.mcstats"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcstats")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "mcstats")); command.setExecutor(new McstatsCommand()); } private void registerMctopCommand() { - PluginCommand command = mcMMO.p.getCommand("mctop"); - command.setDescription(LocaleLoader.getString("Commands.Description.mctop")); + PluginCommand command = pluginRef.getCommand("mctop"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mctop")); command.setPermission("mcmmo.commands.mctop"); // Only need the main one, not the individual skill ones command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.2", "mctop", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "mctop", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Skill") + "]", "[" + pluginRef.getLocaleManager().getString("Commands.Usage.Page") + "]")); command.setExecutor(new MctopCommand()); } private void registerMcpurgeCommand() { - PluginCommand command = mcMMO.p.getCommand("mcpurge"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", mcMMO.getDatabaseCleaningSettings().getOldUserCutoffMonths())); + PluginCommand command = pluginRef.getCommand("mcpurge"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcpurge", pluginRef.getDatabaseCleaningSettings().getOldUserCutoffMonths())); command.setPermission("mcmmo.commands.mcpurge"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "mcpurge")); command.setExecutor(new McpurgeCommand()); } private void registerMcremoveCommand() { - PluginCommand command = mcMMO.p.getCommand("mcremove"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcremove")); + PluginCommand command = pluginRef.getCommand("mcremove"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcremove")); command.setPermission("mcmmo.commands.mcremove"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "mcremove", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">")); command.setExecutor(new McremoveCommand()); } private void registerMmoshowdbCommand() { - PluginCommand command = mcMMO.p.getCommand("mmoshowdb"); - command.setDescription(LocaleLoader.getString("Commands.Description.mmoshowdb")); + PluginCommand command = pluginRef.getCommand("mmoshowdb"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mmoshowdb")); command.setPermission("mcmmo.commands.mmoshowdb"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmoshowdb")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "mmoshowdb")); command.setExecutor(new MmoshowdbCommand()); } private void registerMcconvertCommand() { - PluginCommand command = mcMMO.p.getCommand("mcconvert"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcconvert")); + PluginCommand command = pluginRef.getCommand("mcconvert"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcconvert")); command.setPermission("mcmmo.commands.mcconvert;mcmmo.commands.mcconvert.experience;mcmmo.commands.mcconvert.database"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.2", "mcconvert", "database", "")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.2", "mcconvert", "experience", "")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "mcconvert", "database", "")); + command.setUsage(command.getUsage() + "\n" + pluginRef.getLocaleManager().getString("Commands.Usage.2", "mcconvert", "experience", "")); command.setExecutor(new McconvertCommand()); } private void registerAdminChatCommand() { - PluginCommand command = mcMMO.p.getCommand("adminchat"); - command.setDescription(LocaleLoader.getString("Commands.Description.adminchat")); + PluginCommand command = pluginRef.getCommand("adminchat"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.adminchat")); command.setPermission("mcmmo.chat.adminchat"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "adminchat")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "adminchat", "")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "adminchat", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "adminchat")); + command.setUsage(command.getUsage() + "\n" + pluginRef.getLocaleManager().getString("Commands.Usage.1", "adminchat", "")); + command.setUsage(command.getUsage() + "\n" + pluginRef.getLocaleManager().getString("Commands.Usage.1", "adminchat", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Message") + ">")); command.setExecutor(new AdminChatCommand()); } private void registerPartyChatCommand() { - PluginCommand command = mcMMO.p.getCommand("partychat"); - command.setDescription(LocaleLoader.getString("Commands.Description.partychat")); + PluginCommand command = pluginRef.getCommand("partychat"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.partychat")); command.setPermission("mcmmo.chat.partychat;mcmmo.commands.party"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "partychat")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "partychat", "")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "partychat", "<" + LocaleLoader.getString("Commands.Usage.Message") + ">")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "partychat")); + command.setUsage(command.getUsage() + "\n" + pluginRef.getLocaleManager().getString("Commands.Usage.1", "partychat", "")); + command.setUsage(command.getUsage() + "\n" + pluginRef.getLocaleManager().getString("Commands.Usage.1", "partychat", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Message") + ">")); command.setExecutor(new PartyChatCommand()); } private void registerPartyCommand() { - PluginCommand command = mcMMO.p.getCommand("party"); - command.setDescription(LocaleLoader.getString("Commands.Description.party")); + PluginCommand command = pluginRef.getCommand("party"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.party")); command.setPermission("mcmmo.commands.party;mcmmo.commands.party.accept;mcmmo.commands.party.create;mcmmo.commands.party.disband;" + "mcmmo.commands.party.xpshare;mcmmo.commands.party.invite;mcmmo.commands.party.itemshare;mcmmo.commands.party.join;" + "mcmmo.commands.party.kick;mcmmo.commands.party.lock;mcmmo.commands.party.owner;mcmmo.commands.party.password;" + @@ -345,78 +344,78 @@ public final class CommandRegistrationManager { } private void registerPtpCommand() { - PluginCommand command = mcMMO.p.getCommand("ptp"); - command.setDescription(LocaleLoader.getString("Commands.Description.ptp")); + PluginCommand command = pluginRef.getCommand("ptp"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.ptp")); command.setPermission("mcmmo.commands.ptp"); // Only need the main one, not the individual ones for toggle/accept/acceptall command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "ptp", "")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "ptp", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Player") + ">")); + command.setUsage(command.getUsage() + "\n" + pluginRef.getLocaleManager().getString("Commands.Usage.1", "ptp", "")); command.setExecutor(new PtpCommand()); } /*private void registerHardcoreCommand() { PluginCommand command = mcMMO.p.getCommand("hardcore"); - command.setDescription(LocaleLoader.getString("Commands.Description.hardcore")); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.hardcore")); command.setPermission("mcmmo.commands.hardcore;mcmmo.commands.hardcore.toggle;mcmmo.commands.hardcore.modify"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "hardcore", "[on|off]")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "hardcore", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "hardcore", "[on|off]")); + command.setUsage(command.getUsage() + "\n" + pluginRef.getLocaleManager().getString("Commands.Usage.1", "hardcore", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Rate") + ">")); command.setExecutor(new HardcoreCommand()); } private void registerVampirismCommand() { PluginCommand command = mcMMO.p.getCommand("vampirism"); - command.setDescription(LocaleLoader.getString("Commands.Description.vampirism")); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.vampirism")); command.setPermission("mcmmo.commands.vampirism;mcmmo.commands.vampirism.toggle;mcmmo.commands.vampirism.modify"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "vampirism", "[on|off]")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "vampirism", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "vampirism", "[on|off]")); + command.setUsage(command.getUsage() + "\n" + pluginRef.getLocaleManager().getString("Commands.Usage.1", "vampirism", "<" + pluginRef.getLocaleManager().getString("Commands.Usage.Rate") + ">")); command.setExecutor(new VampirismCommand()); }*/ private void registerMcnotifyCommand() { - PluginCommand command = mcMMO.p.getCommand("mcnotify"); - command.setDescription(LocaleLoader.getString("Commands.Description.mcnotify")); + PluginCommand command = pluginRef.getCommand("mcnotify"); + command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcnotify")); command.setPermission("mcmmo.commands.mcnotify"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcnotify")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "mcnotify")); command.setExecutor(new McnotifyCommand()); } private void registerMHDCommand() { - PluginCommand command = mcMMO.p.getCommand("mhd"); + PluginCommand command = pluginRef.getCommand("mhd"); command.setDescription("Resets all mob health bar settings for all players to the default"); //TODO: Localize command.setPermission("mcmmo.commands.mhd"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mhd")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "mhd")); command.setExecutor(new MHDCommand()); } private void registerMcscoreboardCommand() { - PluginCommand command = mcMMO.p.getCommand("mcscoreboard"); + PluginCommand command = pluginRef.getCommand("mcscoreboard"); command.setDescription("Change the current mcMMO scoreboard being displayed"); //TODO: Localize command.setPermission("mcmmo.commands.mcscoreboard"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcscoreboard", "")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.2", "mcscoreboard", "time", "")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.1", "mcscoreboard", "")); + command.setUsage(command.getUsage() + "\n" + pluginRef.getLocaleManager().getString("Commands.Usage.2", "mcscoreboard", "time", "")); command.setExecutor(new McscoreboardCommand()); } private void registerMcImportCommand() { - PluginCommand command = mcMMO.p.getCommand("mcimport"); + PluginCommand command = pluginRef.getCommand("mcimport"); command.setDescription("Import mod config files"); //TODO: Localize command.setPermission("mcmmo.commands.mcimport"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcimport")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "mcimport")); command.setExecutor(new McImportCommand()); } private void registerReloadLocaleCommand() { - PluginCommand command = mcMMO.p.getCommand("mcmmoreloadlocale"); + PluginCommand command = pluginRef.getCommand("mcmmoreloadlocale"); command.setDescription("Reloads locale"); // TODO: Localize command.setPermission("mcmmo.commands.reloadlocale"); command.setPermissionMessage(permissionsMessage); - command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmoreloadlocale")); + command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "mcmmoreloadlocale")); command.setExecutor(new McmmoReloadLocaleCommand()); } diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java index ec027f545..a1fe9335e 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java @@ -4,8 +4,6 @@ import com.gmail.nossr50.core.MetadataConstants; 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.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.player.UserManager; @@ -36,14 +34,14 @@ public final class CommandUtils { public static boolean tooFar(CommandSender sender, Player target, boolean hasPermission) { if(!target.isOnline() && !hasPermission) { - sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Offline")); return true; - } else if (mcMMO.getConfigManager().getConfigCommands().isLimitInspectRange() + } else if (pluginRef.getConfigManager().getConfigCommands().isLimitInspectRange() && sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), - mcMMO.getConfigManager().getConfigCommands().getInspectCommandMaxDistance()) + pluginRef.getConfigManager().getConfigCommands().getInspectCommandMaxDistance()) && !hasPermission) { - sender.sendMessage(LocaleLoader.getString("Inspect.TooFar")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.TooFar")); return true; } @@ -59,7 +57,7 @@ public final class CommandUtils { return false; } - sender.sendMessage(LocaleLoader.getString("Commands.NoConsole")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.NoConsole")); return true; } @@ -68,7 +66,7 @@ public final class CommandUtils { return false; } - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Offline")); return true; } @@ -83,7 +81,7 @@ public final class CommandUtils { public static boolean checkPlayerExistence(CommandSender sender, String playerName, McMMOPlayer mcMMOPlayer) { if (mcMMOPlayer != null) { if (CommandUtils.hidden(sender, mcMMOPlayer.getPlayer(), false)) { - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Offline")); return false; } return true; @@ -95,7 +93,7 @@ public final class CommandUtils { return false; } - sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.DoesNotExist")); return false; } @@ -104,7 +102,7 @@ public final class CommandUtils { return false; } - sender.sendMessage(LocaleLoader.getString("Commands.Offline")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Offline")); return true; } @@ -116,7 +114,7 @@ public final class CommandUtils { boolean hasPlayerDataKey = ((Player) sender).hasMetadata(MetadataConstants.PLAYER_DATA_METAKEY); if (!hasPlayerDataKey) { - sender.sendMessage(LocaleLoader.getString("Commands.NotLoaded")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.NotLoaded")); } return hasPlayerDataKey; @@ -127,7 +125,7 @@ public final class CommandUtils { return true; } - sender.sendMessage(LocaleLoader.getString("Commands.NotLoaded")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.NotLoaded")); return false; } @@ -154,7 +152,7 @@ public final class CommandUtils { return false; } - sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid")); + sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Skill.Invalid")); return true; } @@ -173,7 +171,7 @@ public final class CommandUtils { * @param display The sender to display stats to */ public static void printGatheringSkills(Player inspect, CommandSender display) { - printGroupedSkillData(inspect, display, LocaleLoader.getString("Stats.Header.Gathering"), PrimarySkillType.GATHERING_SKILLS); + printGroupedSkillData(inspect, display, pluginRef.getLocaleManager().getString("Stats.Header.Gathering"), PrimarySkillType.GATHERING_SKILLS); } public static void printGatheringSkills(Player player) { @@ -187,7 +185,7 @@ public final class CommandUtils { * @param display The sender to display stats to */ public static void printCombatSkills(Player inspect, CommandSender display) { - printGroupedSkillData(inspect, display, LocaleLoader.getString("Stats.Header.Combat"), PrimarySkillType.COMBAT_SKILLS); + printGroupedSkillData(inspect, display, pluginRef.getLocaleManager().getString("Stats.Header.Combat"), PrimarySkillType.COMBAT_SKILLS); } public static void printCombatSkills(Player player) { @@ -201,7 +199,7 @@ public final class CommandUtils { * @param display The sender to display stats to */ public static void printMiscSkills(Player inspect, CommandSender display) { - printGroupedSkillData(inspect, display, LocaleLoader.getString("Stats.Header.Misc"), PrimarySkillType.MISC_SKILLS); + printGroupedSkillData(inspect, display, pluginRef.getLocaleManager().getString("Stats.Header.Misc"), PrimarySkillType.MISC_SKILLS); } public static void printMiscSkills(Player player) { @@ -210,10 +208,10 @@ public final class CommandUtils { public static String displaySkill(PlayerProfile profile, PrimarySkillType skill) { if (skill.isChildSkill()) { - return LocaleLoader.getString("Skills.ChildStats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill)); + return pluginRef.getLocaleManager().getString("Skills.ChildStats", pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill)); } - return LocaleLoader.getString("Skills.Stats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)); + return pluginRef.getLocaleManager().getString("Skills.Stats", pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)); } private static void printGroupedSkillData(Player inspect, CommandSender display, String header, List skillGroup) { @@ -242,7 +240,7 @@ public final class CommandUtils { Player player = sender instanceof Player ? (Player) sender : null; List onlinePlayerNames = new ArrayList<>(); - for (Player onlinePlayer : mcMMO.p.getServer().getOnlinePlayers()) { + for (Player onlinePlayer : pluginRef.getServer().getOnlinePlayers()) { if (player != null && player.canSee(onlinePlayer)) { onlinePlayerNames.add(onlinePlayer.getName()); } @@ -258,14 +256,14 @@ public final class CommandUtils { * @return Matched name or {@code partialName} if no match was found */ public static String getMatchedPlayerName(String partialName) { - if (mcMMO.getConfigManager().getConfigCommands().getMisc().isMatchOfflinePlayers()) { + if (pluginRef.getConfigManager().getConfigCommands().getMisc().isMatchOfflinePlayers()) { List matches = matchPlayer(partialName); if (matches.size() == 1) { partialName = matches.get(0); } } else { - Player player = mcMMO.p.getServer().getPlayer(partialName); + Player player = pluginRef.getServer().getPlayer(partialName); if (player != null) { partialName = player.getName(); @@ -287,7 +285,7 @@ public final class CommandUtils { private static List matchPlayer(String partialName) { List matchedPlayers = new ArrayList<>(); - for (OfflinePlayer offlinePlayer : mcMMO.p.getServer().getOfflinePlayers()) { + for (OfflinePlayer offlinePlayer : pluginRef.getServer().getOfflinePlayers()) { String playerName = offlinePlayer.getName(); if (playerName == null) { //Do null checking here to detect corrupted data before sending it throuogh .equals diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java index dc7493ab2..69d2d477e 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarManager.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.util.experience; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.ExperienceBarHideTask; import org.bukkit.plugin.Plugin; @@ -26,7 +25,7 @@ public class ExperienceBarManager { } public void updateExperienceBar(PrimarySkillType primarySkillType, Plugin plugin) { - if (!mcMMO.getConfigManager().getConfigLeveling().isEnableXPBars() || !mcMMO.getConfigManager().getConfigLeveling().getXPBarToggle(primarySkillType)) + if (!pluginRef.getConfigManager().getConfigLeveling().isEnableXPBars() || !pluginRef.getConfigManager().getConfigLeveling().getXPBarToggle(primarySkillType)) return; //Init Bar diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java index c3162d7f5..e07e32866 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceBarWrapper.java @@ -2,8 +2,6 @@ package com.gmail.nossr50.util.experience; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.player.PlayerLevelUtils; import org.bukkit.boss.BarColor; @@ -54,12 +52,12 @@ public class ExperienceBarWrapper { private String getTitleTemplate() { //If they are using extra details - if(mcMMO.getConfigManager().getConfigLeveling().getEarlyGameBoost().isEnableEarlyGameBoost() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) { - return LocaleLoader.getString("XPBar.Template.EarlyGameBoost"); - } else if(mcMMO.getConfigManager().getConfigLeveling().getConfigExperienceBars().isMoreDetailedXPBars()) - return LocaleLoader.getString("XPBar.Complex.Template", LocaleLoader.getString("XPBar."+niceSkillName, getLevel()), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel()); + if(pluginRef.getConfigManager().getConfigLeveling().getEarlyGameBoost().isEnableEarlyGameBoost() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) { + return pluginRef.getLocaleManager().getString("XPBar.Template.EarlyGameBoost"); + } else if(pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceBars().isMoreDetailedXPBars()) + return pluginRef.getLocaleManager().getString("XPBar.Complex.Template", pluginRef.getLocaleManager().getString("XPBar."+niceSkillName, getLevel()), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel()); - return LocaleLoader.getString("XPBar." + niceSkillName, getLevel(), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel()); + return pluginRef.getLocaleManager().getString("XPBar." + niceSkillName, getLevel(), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel()); } private int getLevel() { @@ -121,14 +119,14 @@ public class ExperienceBarWrapper { bossBar.setProgress(v); //Check player level - if(mcMMO.getConfigManager().getConfigLeveling().getEarlyGameBoost().isEnableEarlyGameBoost() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) { + if(pluginRef.getConfigManager().getConfigLeveling().getEarlyGameBoost().isEnableEarlyGameBoost() && PlayerLevelUtils.qualifiesForEarlyGameBoost(mcMMOPlayer, primarySkillType)) { setColor(BarColor.YELLOW); } else { - setColor(mcMMO.getConfigManager().getConfigLeveling().getConfigExperienceBars().getXPBarColor(primarySkillType)); + setColor(pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceBars().getXPBarColor(primarySkillType)); } //Every time progress updates we need to check for a title update - if (getLevel() != lastLevelUpdated || mcMMO.getConfigManager().getConfigLeveling().isMoreDetailedXPBars()) { + if (getLevel() != lastLevelUpdated || pluginRef.getConfigManager().getConfigLeveling().isMoreDetailedXPBars()) { updateTitle(); lastLevelUpdated = getLevel(); } @@ -157,8 +155,8 @@ public class ExperienceBarWrapper { private void createBossBar() { bossBar = mcMMOPlayer.getPlayer().getServer().createBossBar(title, - mcMMO.getConfigManager().getConfigLeveling().getXPBarColor(primarySkillType), - mcMMO.getConfigManager().getConfigLeveling().getXPBarStyle(primarySkillType)); + pluginRef.getConfigManager().getConfigLeveling().getXPBarColor(primarySkillType), + pluginRef.getConfigManager().getConfigLeveling().getXPBarStyle(primarySkillType)); bossBar.addPlayer(mcMMOPlayer.getPlayer()); } } diff --git a/src/main/java/com/gmail/nossr50/util/experience/ExperienceManager.java b/src/main/java/com/gmail/nossr50/util/experience/ExperienceManager.java index 7370ded48..3c31ecd4a 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/ExperienceManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/ExperienceManager.java @@ -13,6 +13,8 @@ import java.util.HashMap; * This class handles the XP maps for various skills */ public class ExperienceManager { + private mcMMO pluginRef; + private HashMap> skillMaterialXPMap; private HashMap miningFullyQualifiedBlockXpMap; private HashMap herbalismFullyQualifiedBlockXpMap; @@ -25,7 +27,8 @@ public class ExperienceManager { private double globalXpMult; - public ExperienceManager() { + public ExperienceManager(mcMMO pluginRef) { + this.pluginRef = pluginRef; initExperienceMaps(); registerDefaultValues(); @@ -44,8 +47,8 @@ public class ExperienceManager { } private void registerDefaultValues() { - fillCombatXPMultiplierMap(mcMMO.getConfigManager().getConfigExperience().getCombatExperienceMap()); - registerSpecialCombatXPMultiplierMap(mcMMO.getConfigManager().getConfigExperience().getSpecialCombatExperienceMap()); + fillCombatXPMultiplierMap(pluginRef.getConfigManager().getConfigExperience().getCombatExperienceMap()); + registerSpecialCombatXPMultiplierMap(pluginRef.getConfigManager().getConfigExperience().getSpecialCombatExperienceMap()); buildBlockXPMaps(); buildFurnaceXPMap(); } @@ -58,7 +61,7 @@ public class ExperienceManager { * @param platformSafeMap the platform safe map */ public void fillCombatXPMultiplierMap(HashMap platformSafeMap) { - mcMMO.p.getLogger().info("Registering combat XP values..."); + pluginRef.getLogger().info("Registering combat XP values..."); for (String entityString : platformSafeMap.keySet()) { //Iterate over all EntityType(s) boolean foundMatch = false; @@ -68,7 +71,7 @@ public class ExperienceManager { if (entityString.equalsIgnoreCase(type.name())) { //Check for duplicates and warn the admin if (combatXPMultiplierMap.containsKey(entityString)) { - mcMMO.p.getLogger().severe("Entity named " + entityString + " has multiple values in the combat experience config!"); + pluginRef.getLogger().severe("Entity named " + entityString + " has multiple values in the combat experience config!"); } //Match found combatXPMultiplierMap.put(type, platformSafeMap.get(entityString)); @@ -77,7 +80,7 @@ public class ExperienceManager { } if(!foundMatch) { - mcMMO.p.getLogger().severe("No entity could be matched for the combat experience config value named - " + entityString); + pluginRef.getLogger().severe("No entity could be matched for the combat experience config value named - " + entityString); } } } @@ -88,13 +91,13 @@ public class ExperienceManager { * @param map target map */ public void registerSpecialCombatXPMultiplierMap(HashMap map) { - mcMMO.p.getLogger().info("Registering special combat XP values..."); + pluginRef.getLogger().info("Registering special combat XP values..."); specialCombatXPMultiplierMap = map; } private void buildFurnaceXPMap() { - mcMMO.p.getLogger().info("Mapping xp values for furnaces..."); - fillBlockXPMap(mcMMO.getConfigManager().getConfigExperience().getSmeltingExperienceMap(), furnaceFullyQualifiedItemXpMap); + pluginRef.getLogger().info("Mapping xp values for furnaces..."); + fillBlockXPMap(pluginRef.getConfigManager().getConfigExperience().getSmeltingExperienceMap(), furnaceFullyQualifiedItemXpMap); } /** @@ -117,8 +120,8 @@ public class ExperienceManager { * Taming entries in the config are case insensitive, but for faster lookups we convert them to ENUMs */ private void buildTamingXPMap() { - mcMMO.p.getLogger().info("Building Taming XP list..."); - HashMap userTamingConfigMap = mcMMO.getConfigManager().getConfigExperience().getTamingExperienceMap(); + pluginRef.getLogger().info("Building Taming XP list..."); + HashMap userTamingConfigMap = pluginRef.getConfigManager().getConfigExperience().getTamingExperienceMap(); for (String s : userTamingConfigMap.keySet()) { boolean matchFound = false; @@ -130,7 +133,7 @@ public class ExperienceManager { } } if (!matchFound) { - mcMMO.p.getLogger().info("Unable to find entity with matching name - " + s); + pluginRef.getLogger().info("Unable to find entity with matching name - " + s); } } } @@ -144,30 +147,30 @@ public class ExperienceManager { //Map the fully qualified name fullyQualifiedBlockXPMap.put(matchingMaterial.getKey().toString(), userConfigMap.get(string)); } else { - mcMMO.p.getLogger().info("Could not find a match for the block named '" + string + "' among vanilla block registers"); + pluginRef.getLogger().info("Could not find a match for the block named '" + string + "' among vanilla block registers"); } } } private void buildMiningBlockXPMap() { - mcMMO.p.getLogger().info("Mapping block break XP values for Mining..."); - fillBlockXPMap(mcMMO.getConfigManager().getConfigExperience().getMiningExperienceMap(), miningFullyQualifiedBlockXpMap); + pluginRef.getLogger().info("Mapping block break XP values for Mining..."); + fillBlockXPMap(pluginRef.getConfigManager().getConfigExperience().getMiningExperienceMap(), miningFullyQualifiedBlockXpMap); } private void buildHerbalismBlockXPMap() { - mcMMO.p.getLogger().info("Mapping block break XP values for Herbalism..."); - fillBlockXPMap(mcMMO.getConfigManager().getConfigExperience().getHerbalismXPMap(), herbalismFullyQualifiedBlockXpMap); + pluginRef.getLogger().info("Mapping block break XP values for Herbalism..."); + fillBlockXPMap(pluginRef.getConfigManager().getConfigExperience().getHerbalismXPMap(), herbalismFullyQualifiedBlockXpMap); } private void buildWoodcuttingBlockXPMap() { - mcMMO.p.getLogger().info("Mapping block break XP values for Woodcutting..."); - fillBlockXPMap(mcMMO.getConfigManager().getConfigExperience().getWoodcuttingExperienceMap(), woodcuttingFullyQualifiedBlockXpMap); + pluginRef.getLogger().info("Mapping block break XP values for Woodcutting..."); + fillBlockXPMap(pluginRef.getConfigManager().getConfigExperience().getWoodcuttingExperienceMap(), woodcuttingFullyQualifiedBlockXpMap); } private void buildExcavationBlockXPMap() { - mcMMO.p.getLogger().info("Mapping block break XP values for Excavation..."); - fillBlockXPMap(mcMMO.getConfigManager().getConfigExperience().getExcavationExperienceMap(), excavationFullyQualifiedBlockXpMap); + pluginRef.getLogger().info("Mapping block break XP values for Excavation..."); + fillBlockXPMap(pluginRef.getConfigManager().getConfigExperience().getExcavationExperienceMap(), excavationFullyQualifiedBlockXpMap); } /** @@ -176,7 +179,7 @@ public class ExperienceManager { * @param newGlobalXpMult new global xp multiplier value */ public void setGlobalXpMult(double newGlobalXpMult) { - mcMMO.p.getLogger().info("Setting the global XP multiplier -> " + newGlobalXpMult); + pluginRef.getLogger().info("Setting the global XP multiplier -> " + newGlobalXpMult); globalXpMult = newGlobalXpMult; } @@ -184,7 +187,7 @@ public class ExperienceManager { * Reset the Global XP multiplier to its original value */ public void resetGlobalXpMult() { - mcMMO.p.getLogger().info("Resetting the global XP multiplier " + globalXpMult + " -> " + getOriginalGlobalXpMult()); + pluginRef.getLogger().info("Resetting the global XP multiplier " + globalXpMult + " -> " + getOriginalGlobalXpMult()); globalXpMult = getOriginalGlobalXpMult(); } @@ -194,7 +197,7 @@ public class ExperienceManager { * @param miningFullyQualifiedBlockXpMap the XP map to change to */ public void setMiningFullyQualifiedBlockXpMap(HashMap miningFullyQualifiedBlockXpMap) { - mcMMO.p.getLogger().info("Changing Mining XP Values..."); + pluginRef.getLogger().info("Changing Mining XP Values..."); this.miningFullyQualifiedBlockXpMap = miningFullyQualifiedBlockXpMap; } @@ -204,7 +207,7 @@ public class ExperienceManager { * @param herbalismFullyQualifiedBlockXpMap the XP map to change to */ public void setHerbalismFullyQualifiedBlockXpMap(HashMap herbalismFullyQualifiedBlockXpMap) { - mcMMO.p.getLogger().info("Changing Herbalism XP Values..."); + pluginRef.getLogger().info("Changing Herbalism XP Values..."); this.herbalismFullyQualifiedBlockXpMap = herbalismFullyQualifiedBlockXpMap; } @@ -214,7 +217,7 @@ public class ExperienceManager { * @param woodcuttingFullyQualifiedBlockXpMap the XP map to change to */ public void setWoodcuttingFullyQualifiedBlockXpMap(HashMap woodcuttingFullyQualifiedBlockXpMap) { - mcMMO.p.getLogger().info("Changin Woodcutting XP Values..."); + pluginRef.getLogger().info("Changin Woodcutting XP Values..."); this.woodcuttingFullyQualifiedBlockXpMap = woodcuttingFullyQualifiedBlockXpMap; } @@ -224,7 +227,7 @@ public class ExperienceManager { * @param excavationFullyQualifiedBlockXpMap the XP map to change to */ public void setExcavationFullyQualifiedBlockXpMap(HashMap excavationFullyQualifiedBlockXpMap) { - mcMMO.p.getLogger().info("Changing Excavation XP Values..."); + pluginRef.getLogger().info("Changing Excavation XP Values..."); this.excavationFullyQualifiedBlockXpMap = excavationFullyQualifiedBlockXpMap; } @@ -281,7 +284,7 @@ public class ExperienceManager { * @return the original global xp multiplier value from the user config file */ public double getOriginalGlobalXpMult() { - return mcMMO.getConfigManager().getConfigExperience().getGlobalXPMultiplier(); + return pluginRef.getConfigManager().getConfigExperience().getGlobalXPMultiplier(); } /** diff --git a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java index aa20a04fb..34f6978e2 100644 --- a/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java +++ b/src/main/java/com/gmail/nossr50/util/experience/FormulaManager.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.util.experience; import com.gmail.nossr50.datatypes.experience.FormulaType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.mcMMO; import java.util.HashMap; import java.util.Map; @@ -17,7 +16,7 @@ public class FormulaManager { private FormulaType currentFormula; public FormulaManager() { - currentFormula = mcMMO.getConfigManager().getConfigLeveling().getFormulaType(); + currentFormula = pluginRef.getConfigManager().getConfigLeveling().getFormulaType(); initExperienceNeededMaps(); } @@ -64,7 +63,7 @@ public class FormulaManager { public int[] calculateNewLevel(PrimarySkillType primarySkillType, int experience) { int newLevel = 0; int remainder = 0; - int maxLevel = mcMMO.getConfigManager().getConfigLeveling().getSkillLevelCap(primarySkillType); + int maxLevel = pluginRef.getConfigManager().getConfigLeveling().getSkillLevelCap(primarySkillType); while (experience > 0 && newLevel < maxLevel) { int experienceToNextLevel = getXPtoNextLevel(newLevel, currentFormula); @@ -124,7 +123,7 @@ public class FormulaManager { * @param formulaType target formulaType */ private int processXPToNextLevel(int level, FormulaType formulaType) { - if(mcMMO.isRetroModeEnabled()) + if(pluginRef.isRetroModeEnabled()) { return processXPRetroToNextLevel(level, formulaType); } else { @@ -182,18 +181,18 @@ public class FormulaManager { * @return the raw XP needed for the next level based on formula type */ private int calculateXPNeeded(int level, FormulaType formulaType) { - int base = mcMMO.getConfigManager().getConfigLeveling().getConfigExperienceFormula().getBase(formulaType); - double multiplier = mcMMO.getConfigManager().getConfigLeveling().getConfigExperienceFormula().getMultiplier(formulaType); + int base = pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceFormula().getBase(formulaType); + double multiplier = pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceFormula().getMultiplier(formulaType); switch(formulaType) { case LINEAR: return (int) Math.floor(base + level * multiplier); case EXPONENTIAL: - double exponent = mcMMO.getConfigManager().getConfigLeveling().getConfigExperienceFormula().getExponentialExponent(); + double exponent = pluginRef.getConfigManager().getConfigLeveling().getConfigExperienceFormula().getExponentialExponent(); return (int) Math.floor(multiplier * Math.pow(level, exponent) + base); default: //TODO: Should never be called - mcMMO.p.getLogger().severe("Invalid formula specified for calculation, defaulting to Linear"); + pluginRef.getLogger().severe("Invalid formula specified for calculation, defaulting to Linear"); return calculateXPNeeded(level, FormulaType.LINEAR); } } diff --git a/src/main/java/com/gmail/nossr50/util/nbt/NBTManager.java b/src/main/java/com/gmail/nossr50/util/nbt/NBTManager.java index 39a9765b3..5de5c8ec9 100644 --- a/src/main/java/com/gmail/nossr50/util/nbt/NBTManager.java +++ b/src/main/java/com/gmail/nossr50/util/nbt/NBTManager.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.util.nbt; -import com.gmail.nossr50.mcMMO; import net.minecraft.server.v1_13_R2.NBTBase; import net.minecraft.server.v1_13_R2.NBTList; import net.minecraft.server.v1_13_R2.NBTTagCompound; @@ -39,7 +38,7 @@ public class NBTManager { return CraftNBTTagConfigSerializer.deserialize(nbtString); } catch (Exception e) { e.printStackTrace(); - mcMMO.p.getLogger().severe("mcMMO was unable parse the NBT string from your config! Double check that it is proper NBT!"); + pluginRef.getLogger().severe("mcMMO was unable parse the NBT string from your config! Double check that it is proper NBT!"); return null; } } diff --git a/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java b/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java index a74749489..9c3aa5c76 100644 --- a/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java +++ b/src/main/java/com/gmail/nossr50/util/nbt/RawNBT.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.nbt; -import com.gmail.nossr50.mcMMO; import net.minecraft.server.v1_13_R2.NBTBase; /** @@ -29,6 +28,6 @@ public class RawNBT { } public NBTBase getNbtData() { - return mcMMO.getNbtManager().constructNBT(nbtContents); + return pluginRef.getNbtManager().constructNBT(nbtContents); } } diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java index d910dac78..24322ee95 100644 --- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -7,8 +7,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; @@ -40,7 +38,7 @@ public class NotificationManager { private void initMaps() { //Copy the map - playerNotificationHashMap = new HashMap<>(mcMMO.getConfigManager().getConfigNotifications().getNotificationSettingHashMap()); + playerNotificationHashMap = new HashMap<>(pluginRef.getConfigManager().getConfigNotifications().getNotificationSettingHashMap()); } @@ -99,7 +97,7 @@ public class NotificationManager { * This event in particular is provided with a source player, and players near the source player are sent the information * @param targetPlayer the recipient player for this message * @param notificationType type of notification - * @param key Locale Key for the string to use with this event + * @param key LocaleManager Key for the string to use with this event * @param values values to be injected into the locale string */ public void sendNearbyPlayersInformation(Player targetPlayer, NotificationType notificationType, String key, String... values) @@ -112,7 +110,7 @@ public class NotificationManager { if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications()) return; - String preColoredString = LocaleLoader.getString(key, (Object[]) values); + String preColoredString = pluginRef.getLocaleManager().getString(key, (Object[]) values); player.sendMessage(preColoredString); } @@ -198,7 +196,7 @@ public class NotificationManager { /* * Determine the 'identity' of the one who executed the command to pass as a parameters */ - String senderName = LocaleLoader.getString("Server.ConsoleName"); + String senderName = pluginRef.getLocaleManager().getString("Server.ConsoleName"); if (commandSender instanceof Player) { senderName = ((Player) commandSender).getDisplayName() + ChatColor.RESET + "-" + ((Player) commandSender).getUniqueId(); @@ -207,12 +205,12 @@ public class NotificationManager { //Send the notification switch (sensitiveCommandType) { case XPRATE_MODIFY: - sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.Start.Others", addItemToFirstPositionOfArray(senderName, args))); - sendAdminCommandConfirmation(commandSender, LocaleLoader.getString("Notifications.Admin.XPRate.Start.Self", args)); + sendAdminNotification(pluginRef.getLocaleManager().getString("Notifications.Admin.XPRate.Start.Others", addItemToFirstPositionOfArray(senderName, args))); + sendAdminCommandConfirmation(commandSender, pluginRef.getLocaleManager().getString("Notifications.Admin.XPRate.Start.Self", args)); break; case XPRATE_END: - sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.End.Others", addItemToFirstPositionOfArray(senderName, args))); - sendAdminCommandConfirmation(commandSender, LocaleLoader.getString("Notifications.Admin.XPRate.End.Self", args)); + sendAdminNotification(pluginRef.getLocaleManager().getString("Notifications.Admin.XPRate.End.Others", addItemToFirstPositionOfArray(senderName, args))); + sendAdminCommandConfirmation(commandSender, pluginRef.getLocaleManager().getString("Notifications.Admin.XPRate.End.Self", args)); break; } } @@ -225,17 +223,17 @@ public class NotificationManager { */ private void sendAdminNotification(String msg) { //If its not enabled exit - if (!mcMMO.getConfigManager().getConfigAdmin().isSendAdminNotifications()) + if (!pluginRef.getConfigManager().getConfigAdmin().isSendAdminNotifications()) return; for (Player player : Bukkit.getServer().getOnlinePlayers()) { if (player.isOp() || Permissions.adminChat(player)) { - player.sendMessage(LocaleLoader.getString("Notifications.Admin.Format.Others", msg)); + player.sendMessage(pluginRef.getLocaleManager().getString("Notifications.Admin.Format.Others", msg)); } } //Copy it out to Console too - mcMMO.p.getLogger().info(LocaleLoader.getString("Notifications.Admin.Format.Others", msg)); + pluginRef.getLogger().info(pluginRef.getLocaleManager().getString("Notifications.Admin.Format.Others", msg)); } /** @@ -245,7 +243,7 @@ public class NotificationManager { * @param msg message fetched from locale */ private void sendAdminCommandConfirmation(CommandSender commandSender, String msg) { - commandSender.sendMessage(LocaleLoader.getString("Notifications.Admin.Format.Self", msg)); + commandSender.sendMessage(pluginRef.getLocaleManager().getString("Notifications.Admin.Format.Self", msg)); } /** diff --git a/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java b/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java index 373ca51e1..8f39e6ecb 100644 --- a/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java +++ b/src/main/java/com/gmail/nossr50/util/player/PlayerLevelUtils.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.util.player; import com.gmail.nossr50.datatypes.experience.CustomXPPerk; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import org.bukkit.entity.Player; @@ -30,7 +29,7 @@ public class PlayerLevelUtils { */ private void applyConfigPerks() { //Make a copy - customXpPerkNodes = new HashSet<>(mcMMO.getConfigManager().getConfigExperience().getCustomXPBoosts()); + customXpPerkNodes = new HashSet<>(pluginRef.getConfigManager().getConfigExperience().getCustomXPBoosts()); } /** diff --git a/src/main/java/com/gmail/nossr50/util/player/UserManager.java b/src/main/java/com/gmail/nossr50/util/player/UserManager.java index 17784f7db..45853844d 100644 --- a/src/main/java/com/gmail/nossr50/util/player/UserManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/UserManager.java @@ -2,7 +2,6 @@ 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; @@ -26,7 +25,7 @@ public final class UserManager { * @param mcMMOPlayer the player profile to start tracking */ public static void track(McMMOPlayer mcMMOPlayer) { - mcMMOPlayer.getPlayer().setMetadata(MetadataConstants.PLAYER_DATA_METAKEY, new FixedMetadataValue(mcMMO.p, mcMMOPlayer)); + mcMMOPlayer.getPlayer().setMetadata(MetadataConstants.PLAYER_DATA_METAKEY, new FixedMetadataValue(pluginRef, mcMMOPlayer)); if(playerDataSet == null) playerDataSet = new HashSet<>(); @@ -46,7 +45,7 @@ public final class UserManager { */ public static void remove(Player player) { McMMOPlayer mcMMOPlayer = getPlayer(player); - player.removeMetadata(MetadataConstants.PLAYER_DATA_METAKEY, mcMMO.p); + player.removeMetadata(MetadataConstants.PLAYER_DATA_METAKEY, pluginRef); if(playerDataSet != null && playerDataSet.contains(mcMMOPlayer)) playerDataSet.remove(mcMMOPlayer); //Clear sync save tracking @@ -56,7 +55,7 @@ public final class UserManager { * Clear all users. */ public static void clearAll() { - for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { + for (Player player : pluginRef.getServer().getOnlinePlayers()) { remove(player); } @@ -73,27 +72,27 @@ public final class UserManager { ImmutableList trackedSyncData = ImmutableList.copyOf(playerDataSet); - mcMMO.p.getLogger().info("Saving mcMMOPlayers... (" + trackedSyncData.size() + ")"); + pluginRef.getLogger().info("Saving mcMMOPlayers... (" + trackedSyncData.size() + ")"); for (McMMOPlayer playerData : trackedSyncData) { try { - mcMMO.p.getLogger().info("Saving data for player: "+playerData.getPlayerName()); + pluginRef.getLogger().info("Saving data for player: "+playerData.getPlayerName()); playerData.getProfile().save(true); } catch (Exception e) { - mcMMO.p.getLogger().warning("Could not save mcMMO player data for player: " + playerData.getPlayerName()); + pluginRef.getLogger().warning("Could not save mcMMO player data for player: " + playerData.getPlayerName()); } } - mcMMO.p.getLogger().info("Finished save operation for "+trackedSyncData.size()+" players!"); + pluginRef.getLogger().info("Finished save operation for "+trackedSyncData.size()+" players!"); } public static Collection getPlayers() { Collection playerCollection = new ArrayList<>(); - for (Player player : mcMMO.p.getServer().getOnlinePlayers()) { + for (Player player : pluginRef.getServer().getOnlinePlayers()) { if (hasPlayerDataKey(player)) { playerCollection.add(getPlayer(player)); } @@ -139,11 +138,11 @@ public final class UserManager { } private static McMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) { - Player player = mcMMO.p.getServer().getPlayerExact(playerName); + Player player = pluginRef.getServer().getPlayerExact(playerName); if (player == null) { if (!offlineValid) { - mcMMO.p.getLogger().warning("A valid mcMMOPlayer object could not be found for " + playerName + "."); + pluginRef.getLogger().warning("A valid mcMMOPlayer object could not be found for " + playerName + "."); } return null; diff --git a/src/main/java/com/gmail/nossr50/util/random/RandomChanceSkill.java b/src/main/java/com/gmail/nossr50/util/random/RandomChanceSkill.java index 532893c62..597934ede 100644 --- a/src/main/java/com/gmail/nossr50/util/random/RandomChanceSkill.java +++ b/src/main/java/com/gmail/nossr50/util/random/RandomChanceSkill.java @@ -2,7 +2,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.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.entity.Player; @@ -33,7 +32,7 @@ public class RandomChanceSkill implements RandomChanceExecution { public RandomChanceSkill(Player player, SubSkillType subSkillType, boolean hasCap) { if (hasCap) - this.probabilityCap = mcMMO.getDynamicSettingsManager().getSkillMaxChance(subSkillType); + this.probabilityCap = pluginRef.getDynamicSettingsManager().getSkillMaxChance(subSkillType); else this.probabilityCap = RandomChanceUtil.LINEAR_CURVE_VAR; @@ -86,7 +85,7 @@ public class RandomChanceSkill implements RandomChanceExecution { * @return the maximum bonus from skill level for this skill */ public double getMaximumBonusLevelCap() { - return mcMMO.getDynamicSettingsManager().getSkillMaxBonusLevel(subSkillType); + return pluginRef.getDynamicSettingsManager().getSkillMaxBonusLevel(subSkillType); } /** diff --git a/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java b/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java index e7baf5183..d3d0695c1 100644 --- a/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java +++ b/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent; import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillRandomCheckEvent; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.skills.SkillActivationType; @@ -219,7 +218,7 @@ public class RandomChanceUtil { * @throws InvalidStaticChance if the skill has no defined static chance this exception will be thrown and you should know you're a naughty boy */ public static double getStaticRandomChance(SubSkillType subSkillType) throws InvalidStaticChance { - return mcMMO.getDynamicSettingsManager().getSkillPropertiesManager().getStaticChanceProperty(subSkillType); + return pluginRef.getDynamicSettingsManager().getSkillPropertiesManager().getStaticChanceProperty(subSkillType); } public static boolean sendSkillEvent(Player player, SubSkillType subSkillType, double activationChance) { diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java index f5ccbb2de..57b8b4be2 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -5,8 +5,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.datatypes.skills.SuperAbilityType; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableList; @@ -29,19 +27,19 @@ public class ScoreboardManager { static final String SIDEBAR_OBJECTIVE = "mcmmo_sidebar"; static final String POWER_OBJECTIVE = "mcmmo_pwrlvl"; - static final String HEADER_STATS = LocaleLoader.getString("Scoreboard.Header.PlayerStats"); - static final String HEADER_COOLDOWNS = LocaleLoader.getString("Scoreboard.Header.PlayerCooldowns"); - static final String HEADER_RANK = LocaleLoader.getString("Scoreboard.Header.PlayerRank"); - static final String TAG_POWER_LEVEL = LocaleLoader.getString("Scoreboard.Header.PowerLevel"); + 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"); - static final String POWER_LEVEL = LocaleLoader.getString("Scoreboard.Misc.PowerLevel"); + static final String POWER_LEVEL = pluginRef.getLocaleManager().getString("Scoreboard.Misc.PowerLevel"); static final String LABEL_POWER_LEVEL = POWER_LEVEL; - static final String LABEL_LEVEL = LocaleLoader.getString("Scoreboard.Misc.Level"); - static final String LABEL_CURRENT_XP = LocaleLoader.getString("Scoreboard.Misc.CurrentXP"); - static final String LABEL_REMAINING_XP = LocaleLoader.getString("Scoreboard.Misc.RemainingXP"); - static final String LABEL_ABILITY_COOLDOWN = LocaleLoader.getString("Scoreboard.Misc.Cooldown"); - static final String LABEL_OVERALL = LocaleLoader.getString("Scoreboard.Misc.Overall"); + 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 skillLabels; static final Map abilityLabelsColored; @@ -64,7 +62,7 @@ public class ScoreboardManager { * Stylizes the targetBoard in a Rainbow Pattern * This is off by default */ - if (mcMMO.getScoreboardSettings().getUseRainbowSkillStyling()) { + if (pluginRef.getScoreboardSettings().getUseRainbowSkillStyling()) { // Everything but black, gray, gold List colors = Lists.newArrayList( ChatColor.WHITE, @@ -134,10 +132,10 @@ public class ScoreboardManager { } private static String formatAbility(ChatColor color, String abilityName) { - if (mcMMO.getScoreboardSettings().getUseAbilityNamesOverGenerics()) { + if (pluginRef.getScoreboardSettings().getUseAbilityNamesOverGenerics()) { return getShortenedName(color + abilityName); } else { - return color + LocaleLoader.getString("Scoreboard.Misc.Ability"); + return color + pluginRef.getLocaleManager().getString("Scoreboard.Misc.Ability"); } } @@ -172,8 +170,8 @@ public class ScoreboardManager { // Called in onDisable() public static void teardownAll() { - ImmutableList onlinePlayers = ImmutableList.copyOf(mcMMO.p.getServer().getOnlinePlayers()); - mcMMO.p.debug("Tearing down scoreboards... (" + onlinePlayers.size() + ")"); + ImmutableList onlinePlayers = ImmutableList.copyOf(pluginRef.getServer().getOnlinePlayers()); + pluginRef.debug("Tearing down scoreboards... (" + onlinePlayers.size() + ")"); for (Player player : onlinePlayers) { teardownPlayer(player); } @@ -206,11 +204,11 @@ public class ScoreboardManager { } } - if (mcMMO.getScoreboardSettings().getPowerLevelTagsEnabled() && !dirtyPowerLevels.contains(playerName)) { + if (pluginRef.getScoreboardSettings().getPowerLevelTagsEnabled() && !dirtyPowerLevels.contains(playerName)) { dirtyPowerLevels.add(playerName); } - if (mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionSkillBoard().isUseThisBoard()) { + if (pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionSkillBoard().isUseThisBoard()) { enablePlayerSkillLevelUpScoreboard(player, skill); } } @@ -241,7 +239,7 @@ public class ScoreboardManager { wrapper.setOldScoreboard(); wrapper.setTypeSkill(skill); - changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.SKILL_BOARD)); + changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.SKILL_BOARD)); } // **** Setup methods **** // @@ -257,7 +255,7 @@ public class ScoreboardManager { wrapper.setOldScoreboard(); wrapper.setTypeSkill(skill); - changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionSkillBoard().getShowBoardOnPlayerLevelUpTime()); + changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionSkillBoard().getShowBoardOnPlayerLevelUpTime()); } public static void enablePlayerStatsScoreboard(Player player) { @@ -266,7 +264,7 @@ public class ScoreboardManager { wrapper.setOldScoreboard(); wrapper.setTypeSelfStats(); - changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.STATS_BOARD)); + changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.STATS_BOARD)); } public static void enablePlayerInspectScoreboard(Player player, PlayerProfile targetProfile) { @@ -275,7 +273,7 @@ public class ScoreboardManager { wrapper.setOldScoreboard(); wrapper.setTypeInspectStats(targetProfile); - changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().getDisplayTimeInSeconds()); + changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().getDisplayTimeInSeconds()); } public static void enablePlayerCooldownScoreboard(Player player) { @@ -284,7 +282,7 @@ public class ScoreboardManager { wrapper.setOldScoreboard(); wrapper.setTypeCooldowns(); - changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.COOLDOWNS_BOARD)); + changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.COOLDOWNS_BOARD)); } public static void showPlayerRankScoreboard(Player player, Map rank) { @@ -294,7 +292,7 @@ public class ScoreboardManager { wrapper.setTypeSelfRank(); wrapper.acceptRankData(rank); - changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.RANK_BOARD)); + changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.RANK_BOARD)); } public static void showPlayerRankScoreboardOthers(Player player, String targetName, Map rank) { @@ -304,7 +302,7 @@ public class ScoreboardManager { wrapper.setTypeInspectRank(targetName); wrapper.acceptRankData(rank); - changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.RANK_BOARD)); + changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.RANK_BOARD)); } public static void showTopScoreboard(Player player, PrimarySkillType skill, int pageNumber, List stats) { @@ -314,7 +312,7 @@ public class ScoreboardManager { wrapper.setTypeTop(skill, pageNumber); wrapper.acceptLeaderboardData(stats); - changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.TOP_BOARD)); + changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.TOP_BOARD)); } public static void showTopPowerScoreboard(Player player, int pageNumber, List stats) { @@ -324,7 +322,7 @@ public class ScoreboardManager { wrapper.setTypeTopPower(pageNumber); wrapper.acceptLeaderboardData(stats); - changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.TOP_BOARD)); + changeScoreboard(wrapper, pluginRef.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.TOP_BOARD)); } /** @@ -369,21 +367,21 @@ public class ScoreboardManager { * @return the main targetBoard objective, or null if disabled */ public static Objective getPowerLevelObjective() { - if (!mcMMO.getScoreboardSettings().getPowerLevelTagsEnabled()) { - Objective objective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE); + if (!pluginRef.getScoreboardSettings().getPowerLevelTagsEnabled()) { + Objective objective = pluginRef.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE); if (objective != null) { objective.unregister(); - mcMMO.p.debug("Removed leftover targetBoard objects from Power Level Tags."); + pluginRef.debug("Removed leftover targetBoard objects from Power Level Tags."); } return null; } - Objective powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE); + Objective powerObjective = pluginRef.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE); if (powerObjective == null) { - powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy"); + powerObjective = pluginRef.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy"); powerObjective.setDisplayName(TAG_POWER_LEVEL); powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME); } diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java index 0b84d211e..7401bca45 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java @@ -6,8 +6,6 @@ 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.locale.LocaleLoader; -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; @@ -54,7 +52,7 @@ public class ScoreboardWrapper { sidebarObjective = this.scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy"); powerObjective = this.scoreboard.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy"); - if (mcMMO.getScoreboardSettings().getPowerLevelTagsEnabled()) { + if (pluginRef.getScoreboardSettings().getPowerLevelTagsEnabled()) { powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL); powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME); @@ -66,7 +64,7 @@ public class ScoreboardWrapper { public static ScoreboardWrapper create(Player player) { //Call our custom event - McMMOScoreboardMakeboardEvent event = new McMMOScoreboardMakeboardEvent(mcMMO.p.getServer().getScoreboardManager().getNewScoreboard(), player.getScoreboard(), player, ScoreboardEventReason.CREATING_NEW_SCOREBOARD); + 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()); @@ -75,7 +73,7 @@ public class ScoreboardWrapper { public void doSidebarUpdateSoon() { if (updateTask == null) { // To avoid spamming the scheduler, store the instance and run 2 ticks later - updateTask = new ScoreboardQuickUpdate().runTaskLater(mcMMO.p, 2L); + updateTask = new ScoreboardQuickUpdate().runTaskLater(pluginRef, 2L); } } @@ -83,7 +81,7 @@ public class ScoreboardWrapper { if (cooldownTask == null) { // Repeat every 5 seconds. // Cancels once all cooldowns are done, using stopCooldownUpdating(). - cooldownTask = new ScoreboardCooldownTask().runTaskTimer(mcMMO.p, 5 * Misc.TICK_CONVERSION_FACTOR, 5 * Misc.TICK_CONVERSION_FACTOR); + cooldownTask = new ScoreboardCooldownTask().runTaskTimer(pluginRef, 5 * Misc.TICK_CONVERSION_FACTOR, 5 * Misc.TICK_CONVERSION_FACTOR); } } @@ -114,7 +112,7 @@ public class ScoreboardWrapper { * Set the old targetBoard, for use in reverting. */ public void setOldScoreboard() { - Player player = mcMMO.p.getServer().getPlayerExact(playerName); + Player player = pluginRef.getServer().getPlayerExact(playerName); if (player == null) { ScoreboardManager.cleanup(this); @@ -126,7 +124,7 @@ public class ScoreboardWrapper { if (oldBoard == scoreboard) { // Already displaying it if (this.oldBoard == null) { // (Shouldn't happen) Use failsafe value - we're already displaying our board, but we don't have the one we should revert to - this.oldBoard = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard(); + this.oldBoard = pluginRef.getServer().getScoreboardManager().getMainScoreboard(); } } else { this.oldBoard = oldBoard; @@ -134,7 +132,7 @@ public class ScoreboardWrapper { } public void showBoardWithNoRevert() { - Player player = mcMMO.p.getServer().getPlayerExact(playerName); + Player player = pluginRef.getServer().getPlayerExact(playerName); if (player == null) { ScoreboardManager.cleanup(this); @@ -150,7 +148,7 @@ public class ScoreboardWrapper { } public void showBoardAndScheduleRevert(int ticks) { - Player player = mcMMO.p.getServer().getPlayerExact(playerName); + Player player = pluginRef.getServer().getPlayerExact(playerName); if (player == null) { ScoreboardManager.cleanup(this); @@ -162,32 +160,32 @@ public class ScoreboardWrapper { } player.setScoreboard(scoreboard); - revertTask = new ScoreboardChangeTask().runTaskLater(mcMMO.p, ticks); + revertTask = new ScoreboardChangeTask().runTaskLater(pluginRef, ticks); // TODO is there any way to do the time that looks acceptable? - // player.sendMessage(LocaleLoader.getString("Commands.ConfigScoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase()), ticks / 20F)); + // player.sendMessage(pluginRef.getLocaleManager().getString("Commands.ConfigScoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase()), ticks / 20F)); if (UserManager.getPlayer(playerName) == null) return; PlayerProfile profile = UserManager.getPlayer(player).getProfile(); - if (profile.getScoreboardTipsShown() >= mcMMO.getScoreboardSettings().getTipsAmount()) { + if (profile.getScoreboardTipsShown() >= pluginRef.getScoreboardSettings().getTipsAmount()) { return; } if (!tippedKeep) { tippedKeep = true; - player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Tip.Keep")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Tip.Keep")); } else if (!tippedClear) { tippedClear = true; - player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Tip.Clear")); + player.sendMessage(pluginRef.getLocaleManager().getString("Commands.Scoreboard.Tip.Clear")); profile.increaseTipsShown(); } } public void tryRevertBoard() { - Player player = mcMMO.p.getServer().getPlayerExact(playerName); + Player player = pluginRef.getServer().getPlayerExact(playerName); if (player == null) { ScoreboardManager.cleanup(this); @@ -205,7 +203,7 @@ public class ScoreboardWrapper { event.getTargetPlayer().setScoreboard(event.getTargetBoard()); oldBoard = null; } else { - mcMMO.p.debug("Not reverting targetBoard for " + playerName + " - targetBoard was changed by another plugin (Consider disabling the mcMMO scoreboards if you don't want them!)"); + pluginRef.debug("Not reverting targetBoard for " + playerName + " - targetBoard was changed by another plugin (Consider disabling the mcMMO scoreboards if you don't want them!)"); } } @@ -219,7 +217,7 @@ public class ScoreboardWrapper { } public boolean isBoardShown() { - Player player = mcMMO.p.getServer().getPlayerExact(playerName); + Player player = pluginRef.getServer().getPlayerExact(playerName); if (player == null) { ScoreboardManager.cleanup(this); @@ -281,7 +279,7 @@ public class ScoreboardWrapper { targetSkill = null; leaderboardPage = -1; - loadObjective(LocaleLoader.getString("Scoreboard.Header.PlayerInspect", targetPlayer)); + loadObjective(pluginRef.getLocaleManager().getString("Scoreboard.Header.PlayerInspect", targetPlayer)); } public void setTypeCooldowns() { @@ -388,7 +386,7 @@ public class ScoreboardWrapper { return; } - Player player = mcMMO.p.getServer().getPlayerExact(playerName); + Player player = pluginRef.getServer().getPlayerExact(playerName); if (player == null) { ScoreboardManager.cleanup(this); @@ -515,7 +513,7 @@ public class ScoreboardWrapper { public void acceptRankData(Map rankData) { Integer rank; - Player player = mcMMO.p.getServer().getPlayerExact(playerName); + Player player = pluginRef.getServer().getPlayerExact(playerName); for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) { if (!skill.getPermissions(player)) { diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 6c8c265ff..77da365b1 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -11,7 +11,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent; import com.gmail.nossr50.events.fake.FakeEntityDamageEvent; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.runnables.skills.AwardCombatXpTask; import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; import com.gmail.nossr50.skills.archery.ArcheryManager; @@ -493,7 +492,7 @@ public final class CombatUtils { switch (type) { case SWORDS: if (entity instanceof Player) { - mcMMO.getNotificationManager().sendPlayerInformation((Player) entity, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.SS.Struck"); + pluginRef.getNotificationManager().sendPlayerInformation((Player) entity, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.SS.Struck"); } UserManager.getPlayer(attacker).getSwordsManager().ruptureCheck(target); @@ -501,7 +500,7 @@ public final class CombatUtils { case AXES: if (entity instanceof Player) { - mcMMO.getNotificationManager().sendPlayerInformation((Player) entity, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.SS.Struck"); + pluginRef.getNotificationManager().sendPlayerInformation((Player) entity, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.SS.Struck"); } break; @@ -531,7 +530,7 @@ public final class CombatUtils { XPGainReason xpGainReason; if (target instanceof Player) { - if (!mcMMO.getConfigManager().getConfigExperience().isPvpXPEnabled() || PartyManager.inSameParty(mcMMOPlayer.getPlayer(), (Player) target)) { + if (!pluginRef.getConfigManager().getConfigExperience().isPvpXPEnabled() || pluginRef.getPartyManager().inSameParty(mcMMOPlayer.getPlayer(), (Player) target)) { return; } @@ -539,7 +538,7 @@ public final class CombatUtils { Player defender = (Player) target; if (defender.isOnline() && SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) { - baseXPMultiplier = 20 * mcMMO.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.PVP); + baseXPMultiplier = 20 * pluginRef.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.PVP); } } else { /*if (mcMMO.getModManager().isCustomEntity(target)) { @@ -547,21 +546,21 @@ public final class CombatUtils { }*/ //else if (target instanceof Animals) { if (target instanceof Animals) { - baseXPMultiplier = mcMMO.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.ANIMALS); + baseXPMultiplier = pluginRef.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.ANIMALS); } else if (target instanceof Monster) { EntityType type = target.getType(); - baseXPMultiplier = mcMMO.getDynamicSettingsManager().getExperienceManager().getCombatXPMultiplier(type); + baseXPMultiplier = pluginRef.getDynamicSettingsManager().getExperienceManager().getCombatXPMultiplier(type); } else { EntityType type = target.getType(); - if (mcMMO.getDynamicSettingsManager().getExperienceManager().hasCombatXP(type)) { + if (pluginRef.getDynamicSettingsManager().getExperienceManager().hasCombatXP(type)) { //Exploit stuff if (type == EntityType.IRON_GOLEM) { if (!((IronGolem) target).isPlayerCreated()) { - baseXPMultiplier = mcMMO.getDynamicSettingsManager().getExperienceManager().getCombatXPMultiplier(type); + baseXPMultiplier = pluginRef.getDynamicSettingsManager().getExperienceManager().getCombatXPMultiplier(type); } } else { - baseXPMultiplier = mcMMO.getDynamicSettingsManager().getExperienceManager().getCombatXPMultiplier(type); + baseXPMultiplier = pluginRef.getDynamicSettingsManager().getExperienceManager().getCombatXPMultiplier(type); } } else { baseXPMultiplier = 1.0f; @@ -569,11 +568,11 @@ public final class CombatUtils { } if (target.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY) || target.hasMetadata("ES")) { - baseXPMultiplier *= mcMMO.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.SPAWNED); + baseXPMultiplier *= pluginRef.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.SPAWNED); } if (target.hasMetadata(MetadataConstants.PETS_ANIMAL_TRACKING_METAKEY)) { - baseXPMultiplier *= mcMMO.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.PETS); + baseXPMultiplier *= pluginRef.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.PETS); } xpGainReason = XPGainReason.PVE; @@ -584,7 +583,7 @@ public final class CombatUtils { baseXPMultiplier *= multiplier; if (baseXPMultiplier != 0) { - new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXPMultiplier, target, xpGainReason).runTaskLater(mcMMO.p, 0); + new AwardCombatXpTask(mcMMOPlayer, primarySkillType, baseXPMultiplier, target, xpGainReason).runTaskLater(pluginRef, 0); } } @@ -607,7 +606,7 @@ public final class CombatUtils { return false; } - if ((PartyManager.inSameParty(player, defender) || PartyManager.areAllies(player, defender)) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) { + if ((pluginRef.getPartyManager().inSameParty(player, defender) || pluginRef.getPartyManager().areAllies(player, defender)) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) { return false; } @@ -668,7 +667,7 @@ public final class CombatUtils { if (tamer instanceof Player) { Player owner = (Player) tamer; - return (owner == attacker || PartyManager.inSameParty(attacker, owner) || PartyManager.areAllies(attacker, owner)); + return (owner == attacker || pluginRef.getPartyManager().inSameParty(attacker, owner) || pluginRef.getPartyManager().areAllies(attacker, owner)); } } @@ -703,7 +702,7 @@ public final class CombatUtils { public static EntityDamageEvent sendEntityDamageEvent(Entity attacker, Entity target, DamageCause damageCause, double damage) { EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, damageCause, damage) : new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage); - mcMMO.p.getServer().getPluginManager().callEvent(damageEvent); + pluginRef.getServer().getPluginManager().callEvent(damageEvent); return damageEvent; } @@ -717,7 +716,7 @@ public final class CombatUtils { public static double getFakeDamageFinalResult(Entity attacker, Entity target, DamageCause cause, Map modifiers) { EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, cause, modifiers) : new FakeEntityDamageByEntityEvent(attacker, target, cause, modifiers); - mcMMO.p.getServer().getPluginManager().callEvent(damageEvent); + pluginRef.getServer().getPluginManager().callEvent(damageEvent); if (damageEvent.isCancelled()) { return 0; diff --git a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java index 5a39cd61c..e597d8b07 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/RankUtils.java @@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.listeners.InteractionManager; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.skills.SkillUnlockNotificationTask; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; @@ -381,7 +380,7 @@ public class RankUtils { */ private static int findRankByRootAddress(int rank, SubSkillType subSkillType) { - CommentedConfigurationNode rankConfigRoot = mcMMO.getConfigManager().getConfigRanksRootNode(); + CommentedConfigurationNode rankConfigRoot = pluginRef.getConfigManager().getConfigRanksRootNode(); try { SkillRankProperty skillRankProperty @@ -389,17 +388,17 @@ public class RankUtils { .getNode(subSkillType.getHoconFriendlyConfigName()) .getValue(TypeToken.of(SkillRankProperty.class)); - int unlockLevel = skillRankProperty.getUnlockLevel(mcMMO.isRetroModeEnabled(), rank); + int unlockLevel = skillRankProperty.getUnlockLevel(pluginRef.isRetroModeEnabled(), rank); return unlockLevel; } catch (ObjectMappingException | MissingSkillPropertyDefinition | NullPointerException e) { - mcMMO.p.getLogger().severe("Error traversing nodes to SkillRankProperty for "+subSkillType.toString()); - mcMMO.p.getLogger().severe("This indicates a problem with your rank config file, edit the file and correct the issue or delete it to generate a new default one with correct values."); + pluginRef.getLogger().severe("Error traversing nodes to SkillRankProperty for "+subSkillType.toString()); + pluginRef.getLogger().severe("This indicates a problem with your rank config file, edit the file and correct the issue or delete it to generate a new default one with correct values."); e.printStackTrace(); } //Default to the max level for the skill if any errors were encountered incorrect - return mcMMO.getConfigManager().getConfigLeveling().getSkillLevelCap(subSkillType.getParentSkill()); + return pluginRef.getConfigManager().getConfigLeveling().getSkillLevelCap(subSkillType.getParentSkill()); } public static boolean isPlayerMaxRankInSubSkill(Player player, SubSkillType subSkillType) { diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index b156e9ade..2cea91574 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -7,8 +7,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -50,9 +48,9 @@ public class SkillUtils { */ public static int calculateAbilityLength(McMMOPlayer mcMMOPlayer, PrimarySkillType skill, SuperAbilityType superAbilityType) { //These values change depending on whether or not the server is in retro mode - int abilityLengthVar = mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityStartingSeconds(); + int abilityLengthVar = pluginRef.getConfigManager().getConfigSuperAbilities().getSuperAbilityStartingSeconds(); - int maxLength = mcMMO.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(superAbilityType); + int maxLength = pluginRef.getConfigManager().getConfigSuperAbilities().getMaxLengthForSuper(superAbilityType); int skillLevel = mcMMOPlayer.getSkillLevel(skill); @@ -134,7 +132,7 @@ public class SkillUtils { * @return true if this is a valid skill, false otherwise */ public static boolean isSkill(String skillName) { - return mcMMO.getConfigManager().getConfigLanguage().getTargetLanguage().equalsIgnoreCase("en_US") ? PrimarySkillType.getSkill(skillName) != null : isLocalizedSkill(skillName); + return pluginRef.getConfigManager().getConfigLanguage().getTargetLanguage().equalsIgnoreCase("en_US") ? PrimarySkillType.getSkill(skillName) != null : isLocalizedSkill(skillName); } public static void sendSkillMessage(Player player, NotificationType notificationType, String key) { @@ -142,7 +140,7 @@ public class SkillUtils { for (Player otherPlayer : player.getWorld().getPlayers()) { if (otherPlayer != player && Misc.isNear(location, otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) { - mcMMO.getNotificationManager().sendNearbyPlayersInformation(otherPlayer, notificationType, key, player.getName()); + pluginRef.getNotificationManager().sendNearbyPlayersInformation(otherPlayer, notificationType, key, player.getName()); } } } @@ -258,7 +256,7 @@ public class SkillUtils { } Material type = itemStack.getType(); - short maxDurability = mcMMO.getRepairableManager().isRepairable(type) ? mcMMO.getRepairableManager().getRepairable(type).getMaximumDurability() : type.getMaxDurability(); + short maxDurability = pluginRef.getRepairableManager().isRepairable(type) ? pluginRef.getRepairableManager().getRepairable(type).getMaximumDurability() : type.getMaxDurability(); durabilityModifier = (int) Math.min(durabilityModifier / (itemStack.getEnchantmentLevel(Enchantment.DURABILITY) + 1), maxDurability * maxDamageModifier); itemStack.setDurability((short) Math.min(itemStack.getDurability() + durabilityModifier, maxDurability)); @@ -266,7 +264,7 @@ public class SkillUtils { private static boolean isLocalizedSkill(String skillName) { for (PrimarySkillType skill : PrimarySkillType.values()) { - if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".SkillName"))) { + if (skillName.equalsIgnoreCase(pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(skill.toString()) + ".SkillName"))) { return true; } } diff --git a/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java b/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java index cbb02531f..ea4940eee 100644 --- a/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java +++ b/src/main/java/com/gmail/nossr50/util/sounds/SoundManager.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.util.sounds; import com.gmail.nossr50.config.hocon.sound.SoundSetting; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import org.bukkit.Location; import org.bukkit.Sound; @@ -16,24 +15,24 @@ public class SoundManager { * @param soundType the type of sound */ public static void sendSound(Player player, Location location, SoundType soundType) { - if (mcMMO.getConfigManager().getConfigSound().isSoundEnabled(soundType)) + if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType)) player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType)); } public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory) { - if (mcMMO.getConfigManager().getConfigSound().isSoundEnabled(soundType)) + if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType)) player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType)); } public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory, float pitchModifier) { float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier)); - if (mcMMO.getConfigManager().getConfigSound().isSoundEnabled(soundType)) + if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType)) player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch); } public static void worldSendSound(World world, Location location, SoundType soundType) { - if (mcMMO.getConfigManager().getConfigSound().isSoundEnabled(soundType)) + if (pluginRef.getConfigManager().getConfigSound().isSoundEnabled(soundType)) world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType)); } @@ -44,8 +43,8 @@ public class SoundManager { * @return the volume for this soundtype */ private static float getVolume(SoundType soundType) { - SoundSetting soundSetting = mcMMO.getConfigManager().getConfigSound().getSoundSetting(soundType); - return soundSetting.getVolume() * (float) mcMMO.getConfigManager().getConfigSound().getMasterVolume(); + SoundSetting soundSetting = pluginRef.getConfigManager().getConfigSound().getSoundSetting(soundType); + return soundSetting.getVolume() * (float) pluginRef.getConfigManager().getConfigSound().getMasterVolume(); } private static float getPitch(SoundType soundType) { @@ -54,7 +53,7 @@ public class SoundManager { else if (soundType == SoundType.POP) return getPopPitch(); else { - SoundSetting soundSetting = mcMMO.getConfigManager().getConfigSound().getSoundSetting(soundType); + SoundSetting soundSetting = pluginRef.getConfigManager().getConfigSound().getSoundSetting(soundType); return soundSetting.getPitch(); } } diff --git a/src/main/java/com/gmail/nossr50/worldguard/WorldGuardUtils.java b/src/main/java/com/gmail/nossr50/worldguard/WorldGuardUtils.java index 505dfd622..693bafd27 100644 --- a/src/main/java/com/gmail/nossr50/worldguard/WorldGuardUtils.java +++ b/src/main/java/com/gmail/nossr50/worldguard/WorldGuardUtils.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.worldguard; -import com.gmail.nossr50.mcMMO; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import org.bukkit.plugin.Plugin; @@ -65,7 +64,7 @@ public class WorldGuardUtils { if(plugin == null) { //WG is not present detectedIncompatibleWG = true; - mcMMO.p.getLogger().info("WorldGuard was not detected."); + pluginRef.getLogger().info("WorldGuard was not detected."); } else { //Check that its actually of class WorldGuardPlugin if(plugin instanceof WorldGuardPlugin) @@ -102,7 +101,7 @@ public class WorldGuardUtils { Class checkForClass = Class.forName(classString); detectedIncompatibleWG = false; //In case this was set to true previously } catch (ClassNotFoundException e) { - mcMMO.p.getLogger().severe("Missing WorldGuard class - "+classString); + pluginRef.getLogger().severe("Missing WorldGuard class - "+classString); markWGIncompatible(); return false; } @@ -116,10 +115,10 @@ public class WorldGuardUtils { * Mark WG as being incompatible to avoid unnecessary operations */ private static void markWGIncompatible() { - mcMMO.p.getLogger().severe("You are using a version of WG that is not compatible with mcMMO, " + + pluginRef.getLogger().severe("You are using a version of WG that is not compatible with mcMMO, " + "WG features for mcMMO will be disabled. mcMMO requires you to be using a new version of WG7 " + "in order for it to use WG features. Not all versions of WG7 are compatible."); - mcMMO.p.getLogger().severe("mcMMO will continue to function normally, but if you wish to use WG support you must use a compatible version."); + pluginRef.getLogger().severe("mcMMO will continue to function normally, but if you wish to use WG support you must use a compatible version."); detectedIncompatibleWG = true; } } diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 613e6cb20..900e84500 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -1096,7 +1096,7 @@ Reminder.Squelched=[[GRAY]]Reminder: You are currently not receiving notificatio #Misc Commands.Reload.Start=mcMMO is reloading... this may take a moment Commands.Reload.Finished=mcMMO has finished reloading! -#Locale +#LocaleManager Locale.Reloaded=[[GREEN]]Locale reloaded! #Player Leveling Stuff LevelCap.PowerLevel=[[GOLD]]([[GREEN]]mcMMO[[GOLD]]) [[YELLOW]]You have reached the power level cap of [[RED]]{0}[[YELLOW]]. You will cease to level in skills from this point on. diff --git a/src/main/resources/locale/locale_hu_HU.properties b/src/main/resources/locale/locale_hu_HU.properties index 2667072e3..b5ac2601f 100644 --- a/src/main/resources/locale/locale_hu_HU.properties +++ b/src/main/resources/locale/locale_hu_HU.properties @@ -1094,5 +1094,5 @@ Holiday.AprilFools.Levelup=[[GOLD]]{0} jelenlegi szint [[GREEN]]{1}[[GOLD]]! Holiday.Anniversary=[[BLUE]]Boldog {0}. \u00C9vfordul\u00F3t!\n[[BLUE]]nossr50, \u00E9s az \u00F6sszes fejleszt\u0151 tisztelet\u00E9re itt egy t\u0171zij\u00E1t\u00E9k show! #Reminder Messages Reminder.Squelched=[[GRAY]]Eml\u00E9keztet\u0151: jelenleg nem kapsz \u00E9rtes\u00EDt\u00E9seket az mcMMO-t\u00F3l. Ahhoz, hogy enged\u00E9lyezd az \u00E9rtes\u00EDt\u00E9seket, futtasd \u00FAjra a /mcnotify parancsot. Ez egy automatikus, \u00F3r\u00E1nk\u00E9nti eml\u00E9keztet\u0151. -#Locale +#LocaleManager Locale.Reloaded=[[GREEN]]Ford\u00EDt\u00E1s \u00FAjrat\u00F6ltve! \ No newline at end of file diff --git a/src/main/resources/locale/locale_ja_JP.properties b/src/main/resources/locale/locale_ja_JP.properties index a36c97d4e..b4ff3d35e 100644 --- a/src/main/resources/locale/locale_ja_JP.properties +++ b/src/main/resources/locale/locale_ja_JP.properties @@ -912,7 +912,7 @@ Holiday.Anniversary=[[BLUE]]{0}\u5468\u5e74\u8a18\u5ff5\uff01\n[[BLUE]]nossr50\u #Reminder Messages Reminder.Squelched=[[GRAY]]\u30ea\u30de\u30a4\u30f3\u30c0\u30fc: \u3042\u306a\u305f\u306f\u73fe\u5728mcMMO\u304b\u3089\u901a\u77e5\u3092\u53d7\u3051\u53d6\u3063\u3066\u3044\u307e\u305b\u3093\u3002\u901a\u77e5\u3092\u6709\u52b9\u306b\u3059\u308b\u305f\u3081\u306b\u306f\/mcnotify\u30b3\u30de\u30f3\u30c9\u3092\u3082\u3046\u4e00\u5ea6\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u308c\u306f\u81ea\u52d5\u5316\u3055\u308c\u305f1\u6642\u9593\u3054\u3068\u306e\u901a\u77e5\u3067\u3059\u3002 -#Locale +#LocaleManager Locale.Reloaded=[[GREEN]]\u30ed\u30b1\u30fc\u30eb \u30ea\u30ed\u30fc\u30c9\uff01 #Player Leveling Stuff diff --git a/src/main/resources/locale/locale_zh_CN.properties b/src/main/resources/locale/locale_zh_CN.properties index 4f1046b1e..e1d959803 100644 --- a/src/main/resources/locale/locale_zh_CN.properties +++ b/src/main/resources/locale/locale_zh_CN.properties @@ -1085,5 +1085,5 @@ Holiday.AprilFools.Levelup=[[GOLD]]{0} \u73b0\u5728 [[GREEN]]{1}[[GOLD]] \u7ea7! Holiday.Anniversary=[[BLUE]]mcMMO {0} \u5468\u5e74\u5feb\u4e50!\n[[BLUE]]\u4e3a\u4e86\u7eaa\u5ff5 nossr50 \u548c\u6240\u6709\u5f00\u53d1\u8005\u7684\u5de5\u4f5c, \u8fd9\u91cc\u6709\u4e00\u573a\u70df\u706b\u8868\u6f14! #Reminder Messages Reminder.Squelched=[[GRAY]]\u63d0\u9192: \u4f60\u73b0\u5728\u4e0d\u63a5\u6536\u6765\u81eamcMMO\u7684\u901a\u77e5\u6d88\u606f, \u5982\u60f3\u542f\u7528\u8bf7\u518d\u6b21\u4f7f\u7528 /mcnotify \u547d\u4ee4. \u8be5\u63d0\u793a\u6bcf\u5c0f\u65f6\u4e00\u6b21. -#Locale +#LocaleManager Locale.Reloaded=[[GREEN]]\u8bed\u8a00\u914d\u7f6e\u5df2\u91cd\u65b0\u52a0\u8f7d\uff0c\u4e2d\u6587\u6c49\u5316By: Fu_Meng (\u53d1\u73b0\u9519\u522b\u5b57\u8bf7\u8054\u7cfb\u6211QQ:89009332)