From f94a617d94adb4626d64bc04b54ea21a09a9e09e Mon Sep 17 00:00:00 2001 From: GJ Date: Fri, 20 Apr 2012 18:09:50 -0400 Subject: [PATCH] Cleanup & refactoring, part 1. --- src/main/java/com/gmail/nossr50/Database.java | 9 +- src/main/java/com/gmail/nossr50/Metrics.java | 2 +- .../commands/general/AddlevelsCommand.java | 4 +- .../commands/general/AddxpCommand.java | 4 +- .../commands/general/InspectCommand.java | 4 +- .../commands/general/MmoeditCommand.java | 4 +- .../commands/general/MmoupdateCommand.java | 11 +- .../commands/general/XprateCommand.java | 11 +- .../gmail/nossr50/commands/mc/MccCommand.java | 2 +- .../nossr50/commands/mc/McremoveCommand.java | 10 +- .../nossr50/commands/party/ACommand.java | 109 +++++++++--------- .../nossr50/commands/party/AcceptCommand.java | 64 +++++----- .../nossr50/commands/party/PCommand.java | 14 ++- .../nossr50/commands/party/PartyCommand.java | 30 +++-- .../nossr50/commands/party/PtpCommand.java | 3 +- .../nossr50/commands/spout/MchudCommand.java | 9 +- .../gmail/nossr50/config/LoadTreasures.java | 3 +- .../com/gmail/nossr50/datatypes/HUDmmo.java | 11 +- .../nossr50/datatypes/PlayerProfile.java | 8 +- .../nossr50/listeners/mcPlayerListener.java | 11 +- .../nossr50/listeners/mcSpoutListener.java | 2 +- .../listeners/mcSpoutScreenListener.java | 2 +- src/main/java/com/gmail/nossr50/mcMMO.java | 22 ++-- .../java/com/gmail/nossr50/party/Party.java | 17 ++- .../nossr50/runnables/SQLConversionTask.java | 9 +- .../gmail/nossr50/runnables/SpoutStart.java | 7 +- .../java/com/gmail/nossr50/skills/Mining.java | 4 +- .../java/com/gmail/nossr50/skills/Repair.java | 3 +- .../java/com/gmail/nossr50/skills/Skills.java | 5 +- .../com/gmail/nossr50/spout/SpoutSounds.java | 11 +- .../com/gmail/nossr50/spout/SpoutStuff.java | 5 +- .../resources/locale/locale_en_us.properties | 2 +- 32 files changed, 224 insertions(+), 188 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/Database.java b/src/main/java/com/gmail/nossr50/Database.java index aaa0109b4..3f1aab191 100644 --- a/src/main/java/com/gmail/nossr50/Database.java +++ b/src/main/java/com/gmail/nossr50/Database.java @@ -9,7 +9,6 @@ import java.util.HashMap; import java.util.ArrayList; import java.util.Properties; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.gmail.nossr50.config.LoadProperties; @@ -33,10 +32,10 @@ public class Database { DriverManager.getConnection(connectionString); } catch (ClassNotFoundException e) { - Bukkit.getLogger().warning(e.getLocalizedMessage()); + plugin.getLogger().warning(e.getLocalizedMessage()); } catch (SQLException ex) { - Bukkit.getLogger().warning(ex.getLocalizedMessage()); + plugin.getLogger().warning(ex.getLocalizedMessage()); printErrors(ex); } } @@ -250,7 +249,7 @@ public class Database { { System.out.println("[mcMMO] Connection to MySQL was lost! Attempting to reconnect in 60 seconds..."); reconnectTimestamp = System.currentTimeMillis(); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() { if (!isConnected()) { @@ -260,7 +259,7 @@ public class Database { x.save(); //Save all profiles } Users.players.clear(); //Clear the profiles - for(Player x : Bukkit.getOnlinePlayers()) { + for(Player x : plugin.getServer().getOnlinePlayers()) { Users.addUser(x); //Add in new profiles, forcing them to 'load' again from MySQL } } diff --git a/src/main/java/com/gmail/nossr50/Metrics.java b/src/main/java/com/gmail/nossr50/Metrics.java index 112bd25c8..f13d7c481 100644 --- a/src/main/java/com/gmail/nossr50/Metrics.java +++ b/src/main/java/com/gmail/nossr50/Metrics.java @@ -201,7 +201,7 @@ public class Metrics { + encodeDataPair("authors", authors) + encodeDataPair("version", description.getVersion()) + encodeDataPair("server", Bukkit.getVersion()) - + encodeDataPair("players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length)) + + encodeDataPair("players", Integer.toString(plugin.getServer().getOnlinePlayers().length)) + encodeDataPair("revision", String.valueOf(REVISION)); // If we're pinging, append it diff --git a/src/main/java/com/gmail/nossr50/commands/general/AddlevelsCommand.java b/src/main/java/com/gmail/nossr50/commands/general/AddlevelsCommand.java index 76f5ae612..bf802cf2c 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/AddlevelsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/AddlevelsCommand.java @@ -19,8 +19,8 @@ import com.gmail.nossr50.skills.Skills; public class AddlevelsCommand implements CommandExecutor{ private final mcMMO plugin; - public AddlevelsCommand(mcMMO instance) { - this.plugin = instance; + public AddlevelsCommand (mcMMO plugin) { + this.plugin = plugin; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java index f81bac05f..073924daf 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java @@ -17,8 +17,8 @@ import com.gmail.nossr50.skills.Skills; public class AddxpCommand implements CommandExecutor { private final mcMMO plugin; - public AddxpCommand(mcMMO instance) { - this.plugin = instance; + public AddxpCommand (mcMMO plugin) { + this.plugin = plugin; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java index d88029e1b..3d1242818 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java @@ -17,8 +17,8 @@ import com.gmail.nossr50.locale.mcLocale; public class InspectCommand implements CommandExecutor { private final mcMMO plugin; - public InspectCommand(mcMMO instance) { - this.plugin = instance; + public InspectCommand (mcMMO plugin) { + this.plugin = plugin; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java b/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java index 9e34a5644..7813a8857 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java @@ -19,8 +19,8 @@ import com.gmail.nossr50.skills.Skills; public class MmoeditCommand implements CommandExecutor { private final mcMMO plugin; - public MmoeditCommand(mcMMO instance) { - this.plugin = instance; + public MmoeditCommand (mcMMO plugin) { + this.plugin = plugin; } @Override diff --git a/src/main/java/com/gmail/nossr50/commands/general/MmoupdateCommand.java b/src/main/java/com/gmail/nossr50/commands/general/MmoupdateCommand.java index 40d23dc7c..02fd5f241 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/MmoupdateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/MmoupdateCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.general; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -8,11 +7,17 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.Users; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.runnables.SQLConversionTask; public class MmoupdateCommand implements CommandExecutor { + private final mcMMO plugin; + + public MmoupdateCommand (mcMMO plugin) { + this.plugin = plugin; + } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -24,7 +29,7 @@ public class MmoupdateCommand implements CommandExecutor { Users.clearUsers(); convertToMySQL(); - for (Player x : Bukkit.getServer().getOnlinePlayers()) { + for (Player x : plugin.getServer().getOnlinePlayers()) { Users.addUser(x); } @@ -41,6 +46,6 @@ public class MmoupdateCommand implements CommandExecutor { return; } - Bukkit.getScheduler().scheduleAsyncDelayedTask(Bukkit.getPluginManager().getPlugin("mcMMO"), new SQLConversionTask(), 1); + plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new SQLConversionTask(plugin), 1); } } diff --git a/src/main/java/com/gmail/nossr50/commands/general/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/general/XprateCommand.java index f53f4b000..69c4861c2 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/XprateCommand.java @@ -1,20 +1,25 @@ package com.gmail.nossr50.commands.general; -import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.m; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.locale.mcLocale; public class XprateCommand implements CommandExecutor { + private final mcMMO plugin; private static int oldrate = LoadProperties.xpGainMultiplier; public static boolean xpevent = false; + public XprateCommand (mcMMO plugin) { + this.plugin = plugin; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { String usage1 = mcLocale.getString("Commands.xprate.proper"); @@ -29,7 +34,7 @@ public class XprateCommand implements CommandExecutor { case 1: if (args[0].equalsIgnoreCase("reset")) { if (xpevent) { - for (Player x : Bukkit.getServer().getOnlinePlayers()) { + for (Player x : plugin.getServer().getOnlinePlayers()) { x.sendMessage(mcLocale.getString("Commands.xprate.over")); } @@ -63,7 +68,7 @@ public class XprateCommand implements CommandExecutor { LoadProperties.xpGainMultiplier = m.getInt(args[0]); if (xpevent) { - for (Player x : Bukkit.getServer().getOnlinePlayers()) { + for (Player x : plugin.getServer().getOnlinePlayers()) { x.sendMessage(mcLocale.getString("Commands.xprate.started")); x.sendMessage(mcLocale.getString("Commands.xprate.started2", new Object[] {LoadProperties.xpGainMultiplier})); } diff --git a/src/main/java/com/gmail/nossr50/commands/mc/MccCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/MccCommand.java index 2ec1a10d5..afc6fc431 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/MccCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/MccCommand.java @@ -33,7 +33,7 @@ public class MccCommand implements CommandExecutor { } player.sendMessage("/invite " + mcLocale.getString("Commands.Party.Invite")); - player.sendMessage("/invite " + mcLocale.getString("Commands.Party.Accept")); + player.sendMessage("/accept " + mcLocale.getString("Commands.Party.Accept")); if (mcPermissions.getInstance().partyTeleport(player)) { player.sendMessage("/ptp " + mcLocale.getString("Commands.Party.Teleport")); diff --git a/src/main/java/com/gmail/nossr50/commands/mc/McremoveCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/McremoveCommand.java index b63cb3e72..f6201be2e 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/McremoveCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/McremoveCommand.java @@ -4,7 +4,6 @@ import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -19,6 +18,11 @@ import com.gmail.nossr50.locale.mcLocale; public class McremoveCommand implements CommandExecutor { private final String LOCATION = "plugins/mcMMO/FlatFileStuff/mcmmo.users"; + private final mcMMO plugin; + + public McremoveCommand (mcMMO plugin) { + this.plugin = plugin; + } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -89,7 +93,7 @@ public class McremoveCommand implements CommandExecutor { } //Force PlayerProfile stuff to update - Player player = Bukkit.getServer().getPlayer(playerName); + Player player = plugin.getServer().getPlayer(playerName); if (player != null && Users.players.containsKey(playerName.toLowerCase())) { Users.removeUser(player); @@ -129,7 +133,7 @@ public class McremoveCommand implements CommandExecutor { return worked; } catch (Exception e) { - Bukkit.getLogger().severe("Exception while reading " + LOCATION + " (Are you sure you formatted it correctly?)" + e.toString()); + plugin.getLogger().severe("Exception while reading " + LOCATION + " (Are you sure you formatted it correctly?)" + e.toString()); return worked; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/ACommand.java b/src/main/java/com/gmail/nossr50/commands/party/ACommand.java index 9f4d909de..bd1b1c0c2 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/ACommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/ACommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.party; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -8,83 +7,87 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.Users; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.events.chat.McMMOAdminChatEvent; import com.gmail.nossr50.locale.mcLocale; public class ACommand implements CommandExecutor { + private final mcMMO plugin; - public ACommand() {} + public ACommand (mcMMO plugin) { + this.plugin = plugin; + } - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - // Console message? - if (!(sender instanceof Player) && args.length >= 1) { - String aMessage = args[0]; - for (int i = 1; i <= args.length - 1; i++) { - aMessage = aMessage + " " + args[i]; - } + // Console message? + if (!(sender instanceof Player) && args.length >= 1) { + String aMessage = args[0]; + for (int i = 1; i <= args.length - 1; i++) { + aMessage = aMessage + " " + args[i]; + } - McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", aMessage); - Bukkit.getPluginManager().callEvent(chatEvent); + McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", aMessage); + plugin.getServer().getPluginManager().callEvent(chatEvent); - if(chatEvent.isCancelled()) return true; + if(chatEvent.isCancelled()) return true; - aMessage = chatEvent.getMessage(); + aMessage = chatEvent.getMessage(); - String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} "; + String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} "; - Bukkit.getLogger().info("[A]<*Console*> " + aMessage); + plugin.getLogger().info("[A]<*Console*> " + aMessage); - for (Player herp : Bukkit.getServer().getOnlinePlayers()) { - if (mcPermissions.getInstance().adminChat(herp) || herp.isOp()) - herp.sendMessage(aPrefix + aMessage); - } - return true; - } + for (Player herp : plugin.getServer().getOnlinePlayers()) { + if (mcPermissions.getInstance().adminChat(herp) || herp.isOp()) + herp.sendMessage(aPrefix + aMessage); + } + return true; + } - Player player = null; + Player player = null; if (sender instanceof Player) { player = (Player) sender; } - if (player != null && !mcPermissions.getInstance().adminChat(player) && !player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); - return true; - } + if (player != null && !mcPermissions.getInstance().adminChat(player) && !player.isOp()) { + player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); + return true; + } - // Not a toggle, a message + // Not a toggle, a message - if (args.length >= 1) { - String aMessage = args[0]; - for (int i = 1; i <= args.length - 1; i++) { - aMessage = aMessage + " " + args[i]; - } - + if (args.length >= 1) { + String aMessage = args[0]; + for (int i = 1; i <= args.length - 1; i++) { + aMessage = aMessage + " " + args[i]; + } + Users.getProfile(player).toggleAdminChat(); player.chat(aMessage); Users.getProfile(player).toggleAdminChat(); - return true; - } + return true; + } - if(player != null) - { - PlayerProfile PP = Users.getProfile(player); - - if (PP.getPartyChatMode()) - PP.togglePartyChat(); - - PP.toggleAdminChat(); - - if (PP.getAdminChatMode()) { - player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOn")); - } else { - player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOff")); - } - } - return true; - } + if(player != null) + { + PlayerProfile PP = Users.getProfile(player); + + if (PP.getPartyChatMode()) + PP.togglePartyChat(); + + PP.toggleAdminChat(); + + if (PP.getAdminChatMode()) { + player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOn")); + } else { + player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOff")); + } + } + return true; + } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/AcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/AcceptCommand.java index cc1520461..7327128d9 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/AcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/AcceptCommand.java @@ -1,14 +1,13 @@ package com.gmail.nossr50.commands.party; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.Users; -import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; @@ -16,50 +15,55 @@ import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.party.Party; public class AcceptCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + private final mcMMO plugin; - if (!(sender instanceof Player)) { - sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale. - return true; - } + public AcceptCommand (mcMMO plugin) { + this.plugin = plugin; + } - Player player = (Player) sender; - PlayerProfile PP = Users.getProfile(player); + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!mcPermissions.getInstance().party(player)) { - player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); - return true; - } + if (CommandHelper.noConsoleUsage(sender)) { + return true; + } - if (PP.hasPartyInvite()) { - Party Pinstance = Party.getInstance(); + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) { + return true; + } - if (PP.inParty()) { + Player player = (Player) sender; + PlayerProfile PP = Users.getProfile(player); + + if (PP.hasPartyInvite()) { + Party partyInstance = Party.getInstance(); + + if (PP.inParty()) { McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), PP.getInvite(), EventReason.CHANGED_PARTIES); - Bukkit.getPluginManager().callEvent(event); + plugin.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } - Pinstance.removeFromParty(player, PP); - } - else { + partyInstance.removeFromParty(player, PP); + } + else { McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, PP.getInvite(), EventReason.JOINED_PARTY); - Bukkit.getPluginManager().callEvent(event); + plugin.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } - } + } PP.acceptInvite(); - Pinstance.addToParty(player, PP, PP.getParty(), true, null); + partyInstance.addToParty(player, PP, PP.getParty(), true, null); - } else { - player.sendMessage(mcLocale.getString("mcPlayerListener.NoInvites")); - } + } + else { + player.sendMessage(mcLocale.getString("mcMMO.NoInvites")); + } - return true; - } + return true; + } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PCommand.java index 5179adfc2..8ed91b20c 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.party; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -8,13 +7,18 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.Users; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; import com.gmail.nossr50.locale.mcLocale; public class PCommand implements CommandExecutor { - public PCommand() {} + private final mcMMO plugin; + + public PCommand (mcMMO plugin) { + this.plugin = plugin; + } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -29,7 +33,7 @@ public class PCommand implements CommandExecutor { } McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent("Console", args[0], pMessage); - Bukkit.getPluginManager().callEvent(chatEvent); + plugin.getServer().getPluginManager().callEvent(chatEvent); if(chatEvent.isCancelled()) return true; @@ -37,9 +41,9 @@ public class PCommand implements CommandExecutor { String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + "*Console*" + ChatColor.GREEN + ") "; - Bukkit.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + pMessage); + plugin.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + pMessage); - for (Player herp : Bukkit.getServer().getOnlinePlayers()) { + for (Player herp : plugin.getServer().getOnlinePlayers()) { if (Users.getProfile(herp).inParty()) { if (Users.getProfile(herp).getParty().equalsIgnoreCase(args[0])) { herp.sendMessage(pPrefix + pMessage); 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 c63aaaaaf..6650475f8 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.party; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -8,6 +7,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.Users; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent; @@ -16,6 +16,12 @@ import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.party.Party; public class PartyCommand implements CommandExecutor { + private final mcMMO plugin; + + public PartyCommand (mcMMO plugin) { + this.plugin = plugin; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -46,7 +52,7 @@ public class PartyCommand implements CommandExecutor { } else if (args.length == 0 && PP.inParty()) { String tempList = ""; int x = 0; - for (Player p : Bukkit.getServer().getOnlinePlayers()) { + for (Player p : plugin.getServer().getOnlinePlayers()) { if (PP.getParty().equals(Users.getProfile(p).getParty())) { if (p != null && x + 1 >= Pinstance.partyCount(player)) { if (Pinstance.isPartyLeader(p.getName(), PP.getParty())) { @@ -113,7 +119,7 @@ public class PartyCommand implements CommandExecutor { if (args[0].equals("q") && PP.inParty()) { McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), null, EventReason.LEFT_PARTY); - Bukkit.getPluginManager().callEvent(event); + plugin.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; @@ -159,7 +165,7 @@ public class PartyCommand implements CommandExecutor { } else { if (PP.inParty()) { McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), args[0], EventReason.CHANGED_PARTIES); - Bukkit.getPluginManager().callEvent(event); + plugin.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; @@ -169,7 +175,7 @@ public class PartyCommand implements CommandExecutor { } else { McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY); - Bukkit.getPluginManager().callEvent(event); + plugin.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; @@ -194,8 +200,8 @@ public class PartyCommand implements CommandExecutor { if (Pinstance.isPartyLeader(player.getName(), PP.getParty())) { if (Pinstance.isPartyLocked(PP.getParty())) { Player tPlayer = null; - if (Bukkit.getServer().getPlayer(args[1]) != null) - tPlayer = Bukkit.getServer().getPlayer(args[1]); + if (plugin.getServer().getPlayer(args[1]) != null) + tPlayer = plugin.getServer().getPlayer(args[1]); if (tPlayer == null) { player.sendMessage(mcLocale.getString("Party.CouldNotKick", new Object[] { args[1] })); } @@ -212,7 +218,7 @@ public class PartyCommand implements CommandExecutor { PlayerProfile tPP = Users.getProfile(tPlayer); McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, tPP.getParty(), null, EventReason.KICKED_FROM_PARTY); - Bukkit.getPluginManager().callEvent(event); + plugin.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; @@ -231,8 +237,8 @@ public class PartyCommand implements CommandExecutor { } else if (args[0].equalsIgnoreCase("owner")) { if (Pinstance.isPartyLeader(player.getName(), PP.getParty())) { Player tPlayer = null; - if (Bukkit.getServer().getPlayer(args[1]) != null) - tPlayer = Bukkit.getServer().getPlayer(args[1]); + if (plugin.getServer().getPlayer(args[1]) != null) + tPlayer = plugin.getServer().getPlayer(args[1]); if (tPlayer == null) { player.sendMessage(mcLocale.getString("Party.CouldNotSetOwner", new Object[] { args[1] })); } @@ -246,7 +252,7 @@ public class PartyCommand implements CommandExecutor { } } else { McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), args[0], EventReason.CHANGED_PARTIES); - Bukkit.getPluginManager().callEvent(event); + plugin.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; @@ -256,7 +262,7 @@ public class PartyCommand implements CommandExecutor { } } else if (args.length == 2 && !PP.inParty()) { McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY); - Bukkit.getPluginManager().callEvent(event); + plugin.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; diff --git a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java index 81671c8be..d3e0332c1 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PtpCommand.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.commands.party; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -71,7 +70,7 @@ public class PtpCommand implements CommandExecutor { if (PP.getParty().equals(PPt.getParty())) { McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty()); - Bukkit.getPluginManager().callEvent(event); + plugin.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { player.teleport(target); diff --git a/src/main/java/com/gmail/nossr50/commands/spout/MchudCommand.java b/src/main/java/com/gmail/nossr50/commands/spout/MchudCommand.java index 12b4ee965..0302fb474 100644 --- a/src/main/java/com/gmail/nossr50/commands/spout/MchudCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/spout/MchudCommand.java @@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.Users; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.HUDType; import com.gmail.nossr50.datatypes.HUDmmo; @@ -13,6 +14,12 @@ import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.spout.SpoutStuff; public class MchudCommand implements CommandExecutor { + private final mcMMO plugin; + + public MchudCommand (mcMMO plugin) { + this.plugin = plugin; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!LoadProperties.spoutEnabled) { @@ -39,7 +46,7 @@ public class MchudCommand implements CommandExecutor { SpoutStuff.playerHUDs.get(player).resetHUD(); SpoutStuff.playerHUDs.remove(player); PP.setHUDType(x); - SpoutStuff.playerHUDs.put(player, new HUDmmo(player)); + SpoutStuff.playerHUDs.put(player, new HUDmmo(player, plugin)); } } } diff --git a/src/main/java/com/gmail/nossr50/config/LoadTreasures.java b/src/main/java/com/gmail/nossr50/config/LoadTreasures.java index 3a155310b..f7d42d147 100644 --- a/src/main/java/com/gmail/nossr50/config/LoadTreasures.java +++ b/src/main/java/com/gmail/nossr50/config/LoadTreasures.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.inventory.ItemStack; @@ -278,7 +277,7 @@ public class LoadTreasures extends ConfigLoader{ } else { for (String issue : issues) { - Bukkit.getLogger().warning(issue); + plugin.getLogger().warning(issue); } return false; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/HUDmmo.java b/src/main/java/com/gmail/nossr50/datatypes/HUDmmo.java index 0c037e8a2..bf9fe778f 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/HUDmmo.java +++ b/src/main/java/com/gmail/nossr50/datatypes/HUDmmo.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.datatypes; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.getspout.spoutapi.SpoutManager; import org.getspout.spoutapi.gui.Color; @@ -19,7 +18,8 @@ import com.gmail.nossr50.spout.SpoutStuff; public class HUDmmo { private int center_x = 427 / 2; - private String playerName = null; + private String playerName; + private final mcMMO plugin; private Widget xpbar = null; private GenericGradient xpfill = null; @@ -28,10 +28,9 @@ public class HUDmmo { private GenericGradient xpicon_border = null; private GenericTexture xpicon = null; - private mcMMO plugin = (mcMMO) Bukkit.getServer().getPluginManager().getPlugin("mcMMO"); - - public HUDmmo(Player player) { - playerName = player.getName(); + public HUDmmo(Player player, mcMMO plugin) { + this.playerName = player.getName(); + this.plugin = plugin; initializeHUD(player); } diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index cb503fa6e..d8aa288e9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -1001,12 +1001,12 @@ public class PlayerProfile { continue; } - Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue)); + mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue)); skillsXp.put(x, skillsXp.get(x) + newValue); } } else { - Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue)); + mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue)); skillsXp.put(skillType, skillsXp.get(skillType) + newValue); lastgained = skillType; } @@ -1031,7 +1031,7 @@ public class PlayerProfile { * @param player The player to add XP to */ public void addXP(SkillType skillType, int newValue) { - Player player = Bukkit.getPlayer(playerName); + Player player = mcMMO.p.getServer().getPlayer(playerName); if (System.currentTimeMillis() < ((xpGainATS * 1000) + 250) || player.getGameMode().equals(GameMode.CREATIVE)) { return; @@ -1055,7 +1055,7 @@ public class PlayerProfile { xp += trueBonus; } - Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp)); + mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp)); skillsXp.put(skillType, skillsXp.get(skillType) + xp); lastgained = skillType; } diff --git a/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java index b1363e2ad..37b836b2e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.listeners; import java.util.HashSet; import java.util.Set; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.block.Block; @@ -51,10 +50,10 @@ import com.gmail.nossr50.skills.Skills; import com.gmail.nossr50.skills.Taming; public class mcPlayerListener implements Listener { - private mcMMO plugin; + private final mcMMO plugin; - public mcPlayerListener(mcMMO instance) { - plugin = instance; + public mcPlayerListener(final mcMMO plugin) { + this.plugin = plugin; } /** @@ -152,11 +151,11 @@ public class mcPlayerListener implements Listener { //Bleed it out if(PP.getBleedTicks() > 0) { - Combat.dealDamage(player, PP.getBleedTicks()*2); + Combat.dealDamage(player, PP.getBleedTicks() * 2); } //Schedule PlayerProfile removal 2 minutes after quitting - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player), 2400); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player), 2400); } /** diff --git a/src/main/java/com/gmail/nossr50/listeners/mcSpoutListener.java b/src/main/java/com/gmail/nossr50/listeners/mcSpoutListener.java index 9111ba15e..713fa55e3 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcSpoutListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcSpoutListener.java @@ -38,7 +38,7 @@ public class mcSpoutListener implements Listener { } if (sPlayer.isSpoutCraftEnabled()) { - SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer)); //Setup Party HUD stuff + SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); //Setup Party HUD stuff PPs.toggleSpoutEnabled(); } diff --git a/src/main/java/com/gmail/nossr50/listeners/mcSpoutScreenListener.java b/src/main/java/com/gmail/nossr50/listeners/mcSpoutScreenListener.java index 123a68a6f..5f3711180 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcSpoutScreenListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcSpoutScreenListener.java @@ -61,7 +61,7 @@ public class mcSpoutScreenListener implements Listener { break; } - SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer)); + SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP); } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index f09d04075..ca28db241 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -26,7 +26,6 @@ import java.util.HashMap; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.PluginManager; @@ -52,6 +51,7 @@ public class mcMMO extends JavaPlugin { public HashMap tntTracker = new HashMap(); public static Database database = null; + public static mcMMO p; //Config file stuff LoadProperties config; @@ -64,7 +64,7 @@ public class mcMMO extends JavaPlugin { * Things to be run when the plugin is enabled. */ public void onEnable() { - final Plugin thisPlugin = this; + p = this; mcmmo = this.getFile(); new File(maindirectory).mkdir(); @@ -146,7 +146,7 @@ public class mcMMO extends JavaPlugin { Metrics metrics = new Metrics(); // 'this' in this context is the Plugin object - metrics.beginMeasuringPlugin(thisPlugin); + metrics.beginMeasuringPlugin(p); } catch (IOException e) { System.out.println("Failed to submit stats."); @@ -243,7 +243,7 @@ public class mcMMO extends JavaPlugin { //mc* commands if (LoadProperties.mcremoveEnable) { - getCommand("mcremove").setExecutor(new McremoveCommand()); + getCommand("mcremove").setExecutor(new McremoveCommand(this)); } if (LoadProperties.mcabilityEnable) { @@ -276,11 +276,11 @@ public class mcMMO extends JavaPlugin { //Party commands if (LoadProperties.acceptEnable) { - getCommand("accept").setExecutor(new AcceptCommand()); + getCommand("accept").setExecutor(new AcceptCommand(this)); } if (LoadProperties.aEnable) { - getCommand("a").setExecutor(new ACommand()); + getCommand("a").setExecutor(new ACommand(this)); } if (LoadProperties.inviteEnable) { @@ -288,11 +288,11 @@ public class mcMMO extends JavaPlugin { } if (LoadProperties.partyEnable) { - getCommand("party").setExecutor(new PartyCommand()); + getCommand("party").setExecutor(new PartyCommand(this)); } if (LoadProperties.pEnable) { - getCommand("p").setExecutor(new PCommand()); + getCommand("p").setExecutor(new PCommand(this)); } if (LoadProperties.ptpEnable) { @@ -317,17 +317,17 @@ public class mcMMO extends JavaPlugin { } if (LoadProperties.xprateEnable) { - getCommand("xprate").setExecutor(new XprateCommand()); + getCommand("xprate").setExecutor(new XprateCommand(this)); } - getCommand("mmoupdate").setExecutor(new MmoupdateCommand()); + getCommand("mmoupdate").setExecutor(new MmoupdateCommand(this)); //Spout commands if (LoadProperties.xplockEnable) { getCommand("xplock").setExecutor(new XplockCommand()); } - getCommand("mchud").setExecutor(new MchudCommand()); + getCommand("mchud").setExecutor(new MchudCommand(this)); } /** diff --git a/src/main/java/com/gmail/nossr50/party/Party.java b/src/main/java/com/gmail/nossr50/party/Party.java index 94b6904cd..101a33bf6 100644 --- a/src/main/java/com/gmail/nossr50/party/Party.java +++ b/src/main/java/com/gmail/nossr50/party/Party.java @@ -10,7 +10,6 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.HashMap; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.gmail.nossr50.Users; @@ -72,7 +71,7 @@ public class Party { PlayerProfile PP = Users.getProfile(player); int partyMembers = 0; - for (Player p : Bukkit.getServer().getOnlinePlayers()) { + for (Player p : plugin.getServer().getOnlinePlayers()) { if (player != null && p != null) { //Is this even possible? if (PP.getParty().equals(Users.getProfile(p).getParty())) { partyMembers++; @@ -86,7 +85,7 @@ public class Party { private void informPartyMembers(Player player) { String playerName = player.getName(); - for (Player p : Bukkit.getServer().getOnlinePlayers()) { + for (Player p : plugin.getServer().getOnlinePlayers()) { if (player != null && p != null) { if (inSameParty(player, p) && !p.getName().equals(playerName)) { p.sendMessage(mcLocale.getString("Party.InformedOnJoin", new Object[] {playerName})); @@ -104,7 +103,7 @@ public class Party { public ArrayList getPartyMembers(Player player) { ArrayList players = new ArrayList(); - for (Player p : Bukkit.getServer().getOnlinePlayers()) { + for (Player p : plugin.getServer().getOnlinePlayers()) { if (p.isOnline() && player != null && p != null) { if (inSameParty(player, p) && !p.getName().equals(player.getName())) { players.add(p); @@ -122,7 +121,7 @@ public class Party { private void informPartyMembersOwnerChange(String newOwnerName) { Player newOwner = plugin.getServer().getPlayer(newOwnerName); - for (Player p : Bukkit.getServer().getOnlinePlayers()){ + for (Player p : plugin.getServer().getOnlinePlayers()){ if (newOwner != null && p != null) { if (inSameParty(newOwner, p)) { p.sendMessage(newOwnerName + " is the new party owner."); //TODO: Needs more locale @@ -139,7 +138,7 @@ public class Party { private void informPartyMembersQuit(Player player) { String playerName = player.getName(); - for (Player p : Bukkit.getServer().getOnlinePlayers()){ + for (Player p : plugin.getServer().getOnlinePlayers()){ if (player != null && p != null){ if (inSameParty(player, p) && !p.getName().equals(playerName)) { p.sendMessage(mcLocale.getString("Party.InformedOnQuit", new Object[] {playerName})); @@ -458,7 +457,7 @@ public class Party { e.printStackTrace(); } catch (EOFException e) { - Bukkit.getLogger().info("partyPlayersFile empty."); + plugin.getLogger().info("partyPlayersFile empty."); } catch (IOException e) { e.printStackTrace(); @@ -477,7 +476,7 @@ public class Party { e.printStackTrace(); } catch (EOFException e) { - Bukkit.getLogger().info("partyLocksFile empty."); + plugin.getLogger().info("partyLocksFile empty."); } catch (IOException e) { e.printStackTrace(); @@ -496,7 +495,7 @@ public class Party { e.printStackTrace(); } catch (EOFException e) { - Bukkit.getLogger().info("partyPasswordsFile empty."); + plugin.getLogger().info("partyPasswordsFile empty."); } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/com/gmail/nossr50/runnables/SQLConversionTask.java b/src/main/java/com/gmail/nossr50/runnables/SQLConversionTask.java index 34efbda9d..b2ab59dcf 100644 --- a/src/main/java/com/gmail/nossr50/runnables/SQLConversionTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/SQLConversionTask.java @@ -3,13 +3,16 @@ package com.gmail.nossr50.runnables; import java.io.BufferedReader; import java.io.FileReader; -import org.bukkit.Bukkit; - import com.gmail.nossr50.m; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.LoadProperties; public class SQLConversionTask implements Runnable { + private final mcMMO plugin; + + public SQLConversionTask(mcMMO plugin) { + this.plugin = plugin; + } @Override public void run() { @@ -273,7 +276,7 @@ public class SQLConversionTask implements Runnable { in.close(); } catch (Exception e) { - Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString()); + plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString()); } } } diff --git a/src/main/java/com/gmail/nossr50/runnables/SpoutStart.java b/src/main/java/com/gmail/nossr50/runnables/SpoutStart.java index 574fb28d8..6db7a413c 100644 --- a/src/main/java/com/gmail/nossr50/runnables/SpoutStart.java +++ b/src/main/java/com/gmail/nossr50/runnables/SpoutStart.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.runnables; -import org.bukkit.Bukkit; import org.getspout.spoutapi.SpoutManager; import org.getspout.spoutapi.player.FileManager; @@ -11,13 +10,13 @@ import com.gmail.nossr50.spout.SpoutStuff; public class SpoutStart implements Runnable{ private final mcMMO plugin; - public SpoutStart(mcMMO m) { - this.plugin = m; + public SpoutStart(final mcMMO plugin) { + this.plugin = plugin; } @Override public void run() { - if (Bukkit.getPluginManager().getPlugin("Spout") != null) { + if (plugin.getServer().getPluginManager().getPlugin("Spout") != null) { LoadProperties.spoutEnabled = true; } else { diff --git a/src/main/java/com/gmail/nossr50/skills/Mining.java b/src/main/java/com/gmail/nossr50/skills/Mining.java index 04623444d..63d3fa7d9 100644 --- a/src/main/java/com/gmail/nossr50/skills/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/Mining.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.skills; import java.util.Random; -import org.bukkit.Bukkit; import org.bukkit.CoalType; import org.bukkit.Location; import org.bukkit.Material; @@ -14,6 +13,7 @@ import org.bukkit.enchantments.Enchantment; import com.gmail.nossr50.Users; import com.gmail.nossr50.m; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.spout.SpoutSounds; @@ -254,7 +254,7 @@ public class Mining { return; } - Bukkit.getPluginManager().callEvent(armswing); + mcMMO.p.getServer().getPluginManager().callEvent(armswing); Skills.abilityDurabilityLoss(player.getItemInHand(), durabilityLoss); miningBlockCheck(player, block); diff --git a/src/main/java/com/gmail/nossr50/skills/Repair.java b/src/main/java/com/gmail/nossr50/skills/Repair.java index 8a37dd84f..73cedda4d 100644 --- a/src/main/java/com/gmail/nossr50/skills/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/Repair.java @@ -18,6 +18,7 @@ import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.ItemChecks; import com.gmail.nossr50.Users; import com.gmail.nossr50.m; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.spout.SpoutSounds; @@ -143,7 +144,7 @@ public class Repair { //CLANG CLANG if (LoadProperties.spoutEnabled) { - SpoutSounds.playRepairNoise(player); + SpoutSounds.playRepairNoise(player, mcMMO.p); } } diff --git a/src/main/java/com/gmail/nossr50/skills/Skills.java b/src/main/java/com/gmail/nossr50/skills/Skills.java index e841f548e..0391de661 100644 --- a/src/main/java/com/gmail/nossr50/skills/Skills.java +++ b/src/main/java/com/gmail/nossr50/skills/Skills.java @@ -1,17 +1,18 @@ package com.gmail.nossr50.skills; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; + import org.getspout.spoutapi.SpoutManager; import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.Leaderboard; import com.gmail.nossr50.Users; import com.gmail.nossr50.m; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.spout.SpoutStuff; @@ -193,7 +194,7 @@ public class Skills { PP.skillUp(skillType, 1); McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType); - Bukkit.getPluginManager().callEvent(eventToFire); + mcMMO.p.getServer().getPluginManager().callEvent(eventToFire); } else { PP.addLevels(skillType, 0); diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutSounds.java b/src/main/java/com/gmail/nossr50/spout/SpoutSounds.java index 70579c214..f677cf6a0 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutSounds.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutSounds.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.spout; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -9,6 +8,8 @@ import org.getspout.spoutapi.player.SpoutPlayer; import org.getspout.spoutapi.sound.SoundEffect; import org.getspout.spoutapi.sound.SoundManager; +import com.gmail.nossr50.mcMMO; + public class SpoutSounds { /** @@ -30,12 +31,12 @@ public class SpoutSounds { * * @param player The player who repaired an item */ - public static void playRepairNoise(Player player) { + public static void playRepairNoise(Player player, mcMMO plugin) { SoundManager SM = SpoutManager.getSoundManager(); SpoutPlayer sPlayer = SpoutManager.getPlayer(player); //If this is pulling from online, why have it in the jar? - SM.playCustomSoundEffect(Bukkit.getServer().getPluginManager().getPlugin("mcMMO"), sPlayer, "repair.wav", false); + SM.playCustomSoundEffect(plugin, sPlayer, "repair.wav", false); } /** @@ -43,11 +44,11 @@ public class SpoutSounds { * * @param player The player who leveled up */ - protected static void playLevelUpNoise(Player player) { + protected static void playLevelUpNoise(Player player, mcMMO plugin) { SoundManager SM = SpoutManager.getSoundManager(); SpoutPlayer sPlayer = SpoutManager.getPlayer(player); //If this is pulling from online, why have it in the jar? - SM.playCustomSoundEffect(Bukkit.getServer().getPluginManager().getPlugin("mcMMO"), sPlayer, "level.wav", false); + SM.playCustomSoundEffect(plugin, sPlayer, "level.wav", false); } } diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java b/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java index f20d6a103..d613ca292 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutStuff.java @@ -32,8 +32,7 @@ import com.gmail.nossr50.listeners.mcSpoutListener; import com.gmail.nossr50.listeners.mcSpoutScreenListener; public class SpoutStuff { - - static mcMMO plugin = (mcMMO) Bukkit.getServer().getPluginManager().getPlugin("mcMMO"); + static mcMMO plugin = mcMMO.p; private final static mcSpoutListener spoutListener = new mcSpoutListener(plugin); private final static mcSpoutInputListener spoutInputListener = new mcSpoutInputListener(plugin); @@ -548,7 +547,7 @@ public class SpoutStuff { //TODO: Use Locale sPlayer.sendNotification(ChatColor.GREEN + "Level Up!", ChatColor.YELLOW + m.getCapitalized(skillType.toString()) + ChatColor.DARK_AQUA + " (" + ChatColor.GREEN + PP.getSkillLevel(skillType) + ChatColor.DARK_AQUA + ")", mat); - SpoutSounds.playLevelUpNoise(sPlayer); + SpoutSounds.playLevelUpNoise(sPlayer, plugin); } /** diff --git a/src/main/resources/locale/locale_en_us.properties b/src/main/resources/locale/locale_en_us.properties index 3d0f208dd..86a289879 100644 --- a/src/main/resources/locale/locale_en_us.properties +++ b/src/main/resources/locale/locale_en_us.properties @@ -405,6 +405,7 @@ Commands.Party.Toggle=[[RED]]- Toggle Party Chat Commands.Party= [[RED]]- Create/Join designated party Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Leaderboard-- Commands.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0} +Commands.Skill.Leaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard-- Commands.SkillInfo=/ [[RED]]- View detailed information about a skill Commands.Stats.Self=YOUR STATS Commands.Stats=[[RED]]- View your mcMMO stats @@ -498,7 +499,6 @@ Item.Injured.Wait=You were injured recently and must wait to use this. [[YELLOW] #SKILLS Skills.Disarmed=[[DARK_RED]]You have been disarmed! Skills.Header=[[RED]]-----[][[GREEN]]{0}[[RED]][]----- -Skills.Leaderboard.Listener=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard-- Skills.NeedMore=[[DARK_RED]]You need more Skills.Stats=[[YELLOW]]{0}[[GREEN]]{1}[[DARK_AQUA]] XP([[GRAY]]{2}[[DARK_AQUA]]/[[GRAY]]{3}[[DARK_AQUA]]) Skills.TooTired=[[RED]]You are too tired to use that ability again.