Static ALL the things!

This commit is contained in:
GJ 2012-06-05 10:42:40 -04:00
parent ca6cafaebd
commit 71446a12af
21 changed files with 47 additions and 56 deletions

View File

@ -12,12 +12,6 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public class McmmoCommand implements CommandExecutor { public class McmmoCommand implements CommandExecutor {
private final mcMMO plugin;
public McmmoCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String description = LocaleLoader.getString("mcMMO.Description"); String description = LocaleLoader.getString("mcMMO.Description");
@ -25,7 +19,7 @@ public class McmmoCommand implements CommandExecutor {
sender.sendMessage(mcSplit); sender.sendMessage(mcSplit);
if (Config.getInstance().getDonateMessageEnabled()) { if (Config.getInstance().getDonateMessageEnabled()) {
if (plugin.spoutEnabled && sender instanceof SpoutPlayer) { if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
SpoutPlayer sPlayer = (SpoutPlayer) sender; SpoutPlayer sPlayer = (SpoutPlayer) sender;
sPlayer.sendNotification(ChatColor.YELLOW + "[mcMMO]" + ChatColor.GOLD + " Donate!", ChatColor.GREEN + "mcmmodev@gmail.com", Material.DIAMOND); sPlayer.sendNotification(ChatColor.YELLOW + "[mcMMO]" + ChatColor.GOLD + " Donate!", ChatColor.GREEN + "mcmmodev@gmail.com", Material.DIAMOND);

View File

@ -22,7 +22,7 @@ public class McremoveCommand implements CommandExecutor {
public McremoveCommand (mcMMO plugin) { public McremoveCommand (mcMMO plugin) {
this.plugin = plugin; this.plugin = plugin;
this.location = plugin.usersFile; this.location = mcMMO.usersFile;
} }
@Override @Override

View File

@ -32,7 +32,7 @@ public class MchudCommand implements CommandExecutor {
return true; return true;
} }
if (!plugin.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) { if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true; return true;
} }

View File

@ -20,12 +20,6 @@ import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users; import com.gmail.nossr50.util.Users;
public class XplockCommand implements CommandExecutor { public class XplockCommand implements CommandExecutor {
private final mcMMO plugin;
public XplockCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage = ChatColor.RED + "Proper usage is /xplock [skill]"; String usage = ChatColor.RED + "Proper usage is /xplock [skill]";
@ -34,7 +28,7 @@ public class XplockCommand implements CommandExecutor {
return true; return true;
} }
if (!plugin.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled() || !Config.getInstance().getCommandXPLockEnabled()) { if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled() || !Config.getInstance().getCommandXPLockEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true; return true;
} }

View File

@ -61,7 +61,7 @@ public class PlayerProfile {
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>(); HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
private String playerName; private String playerName;
private final String location = mcMMO.p.usersFile; private final static String location = mcMMO.usersFile;
public PlayerProfile(String name, boolean addNew) { public PlayerProfile(String name, boolean addNew) {
hud = SpoutConfig.getInstance().defaulthud; hud = SpoutConfig.getInstance().defaulthud;

View File

@ -301,7 +301,7 @@ public class BlockListener implements Listener {
} }
/* TREE FELLER SOUNDS */ /* TREE FELLER SOUNDS */
if (plugin.spoutEnabled && BlockChecks.isLog(block) && PP.getAbilityMode(AbilityType.TREE_FELLER)) { if (mcMMO.spoutEnabled && BlockChecks.isLog(block) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation()); SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
} }
@ -346,7 +346,7 @@ public class BlockListener implements Listener {
event.setInstaBreak(true); event.setInstaBreak(true);
} }
if (plugin.spoutEnabled) { if (mcMMO.spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
} }
} }

View File

@ -139,7 +139,7 @@ public class PlayerListener implements Listener {
/* GARBAGE COLLECTION */ /* GARBAGE COLLECTION */
//Remove Spout Stuff //Remove Spout Stuff
if (plugin.spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) { if (mcMMO.spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) {
SpoutStuff.playerHUDs.remove(player); SpoutStuff.playerHUDs.remove(player);
} }

View File

@ -100,10 +100,14 @@ public class mcMMO extends JavaPlugin {
public File mcmmo; public File mcmmo;
//File Paths //File Paths
public String mainDirectory, flatFileDirectory, usersFile, leaderboardDirectory, modDirectory; public static String mainDirectory;
public static String flatFileDirectory;
public static String usersFile;
public static String leaderboardDirectory;
public static String modDirectory;
//Spout Check //Spout Check
public boolean spoutEnabled; public static boolean spoutEnabled;
/** /**
* Things to be run when the plugin is enabled. * Things to be run when the plugin is enabled.
@ -351,7 +355,7 @@ public class mcMMO extends JavaPlugin {
} }
if (configInstance.getCommandmcMMOEnabled()) { if (configInstance.getCommandmcMMOEnabled()) {
getCommand("mcmmo").setExecutor(new McmmoCommand(this)); getCommand("mcmmo").setExecutor(new McmmoCommand());
} }
if (configInstance.getCommandMCRefreshEnabled()) { if (configInstance.getCommandMCRefreshEnabled()) {
@ -416,7 +420,7 @@ public class mcMMO extends JavaPlugin {
//Spout commands //Spout commands
if (configInstance.getCommandXPLockEnabled()) { if (configInstance.getCommandXPLockEnabled()) {
getCommand("xplock").setExecutor(new XplockCommand(this)); getCommand("xplock").setExecutor(new XplockCommand());
} }
getCommand("mchud").setExecutor(new MchudCommand(this)); getCommand("mchud").setExecutor(new MchudCommand(this));

View File

@ -170,7 +170,7 @@ public class Party {
* @return the list of parties. * @return the list of parties.
*/ */
public ArrayList<String> getParties() { public ArrayList<String> getParties() {
String location = plugin.usersFile; String location = mcMMO.usersFile;
ArrayList<String> parties = new ArrayList<String>(); ArrayList<String> parties = new ArrayList<String>();
try { try {

View File

@ -17,7 +17,7 @@ public class SQLConversionTask implements Runnable {
@Override @Override
public void run() { public void run() {
String location = plugin.usersFile; String location = mcMMO.usersFile;
try { try {
FileReader file = new FileReader(location); FileReader file = new FileReader(location);

View File

@ -17,14 +17,14 @@ public class SpoutStart implements Runnable{
@Override @Override
public void run() { public void run() {
if (plugin.getServer().getPluginManager().getPlugin("Spout") != null) { if (plugin.getServer().getPluginManager().getPlugin("Spout") != null) {
plugin.spoutEnabled = true; mcMMO.spoutEnabled = true;
} }
else { else {
plugin.spoutEnabled = false; mcMMO.spoutEnabled = false;
} }
//Spout Stuff //Spout Stuff
if (plugin.spoutEnabled) { if (mcMMO.spoutEnabled) {
SpoutConfig.getInstance(); SpoutConfig.getInstance();
SpoutStuff.setupSpoutConfigs(); SpoutStuff.setupSpoutConfigs();
SpoutStuff.registerCustomEvent(); SpoutStuff.registerCustomEvent();

View File

@ -126,7 +126,7 @@ public class Excavation {
Excavation.excavationProcCheck(block, player); Excavation.excavationProcCheck(block, player);
} }
if (mcMMO.p.spoutEnabled) { if (mcMMO.spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
} }
} }

View File

@ -331,7 +331,7 @@ public class Mining {
miningBlockCheck(player, block); miningBlockCheck(player, block);
if (mcMMO.p.spoutEnabled) { if (mcMMO.spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
} }
} }
@ -376,7 +376,7 @@ public class Mining {
miningBlockCheck(player, block); miningBlockCheck(player, block);
if (mcMMO.p.spoutEnabled) { if (mcMMO.spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
} }
} }

View File

@ -399,7 +399,7 @@ public class WoodCutting {
Skills.abilityDurabilityLoss(player.getItemInHand(), Config.getInstance().getAbilityToolDamage()); Skills.abilityDurabilityLoss(player.getItemInHand(), Config.getInstance().getAbilityToolDamage());
} }
if (mcMMO.p.spoutEnabled) { if (mcMMO.spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
} }
} }

View File

@ -45,7 +45,7 @@ public class Repair {
Skills.xpProcessing(player, PP, SkillType.REPAIR, dif * 10); Skills.xpProcessing(player, PP, SkillType.REPAIR, dif * 10);
//CLANG CLANG //CLANG CLANG
if (mcMMO.p.spoutEnabled) { if (mcMMO.spoutEnabled) {
SpoutSounds.playRepairNoise(player, mcMMO.p); SpoutSounds.playRepairNoise(player, mcMMO.p);
} }
} }
@ -241,7 +241,7 @@ public class Repair {
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
if (!PP.getPlacedAnvil()) { if (!PP.getPlacedAnvil()) {
if (mcMMO.p.spoutEnabled) { if (mcMMO.spoutEnabled) {
SpoutPlayer sPlayer = SpoutManager.getPlayer(player); SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
if (sPlayer.isSpoutCraftEnabled()) { if (sPlayer.isSpoutCraftEnabled()) {

View File

@ -32,7 +32,7 @@ import com.gmail.nossr50.util.Users;
public class SpoutStuff { public class SpoutStuff {
private static mcMMO plugin = mcMMO.p; private static mcMMO plugin = mcMMO.p;
public final static String spoutDirectory = plugin.mainDirectory + "Resources" + File.separator; public final static String spoutDirectory = mcMMO.mainDirectory + "Resources" + File.separator;
public final static String hudDirectory = spoutDirectory + "HUD" + File.separator; public final static String hudDirectory = spoutDirectory + "HUD" + File.separator;
public final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator; public final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator;
public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator; public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator;

View File

@ -32,7 +32,7 @@ public class ItemChecks {
if (customToolsEnabled && CustomToolsConfig.getInstance().customSwordIDs.contains(is.getTypeId())) { if (customToolsEnabled && CustomToolsConfig.getInstance().customSwordIDs.contains(is.getTypeId())) {
return true; return true;
} }
else if (mcMMO.p.spoutEnabled && SpoutToolsAPI.spoutSwords.contains(is)) { else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutSwords.contains(is)) {
return true; return true;
} }
else { else {
@ -60,7 +60,7 @@ public class ItemChecks {
if (customToolsEnabled && CustomToolsConfig.getInstance().customHoeIDs.contains(is.getTypeId())) { if (customToolsEnabled && CustomToolsConfig.getInstance().customHoeIDs.contains(is.getTypeId())) {
return true; return true;
} }
else if (mcMMO.p.spoutEnabled && SpoutToolsAPI.spoutHoes.contains(is)) { else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutHoes.contains(is)) {
return true; return true;
} }
else { else {
@ -88,7 +88,7 @@ public class ItemChecks {
if (customToolsEnabled && CustomToolsConfig.getInstance().customShovelIDs.contains(is.getTypeId())) { if (customToolsEnabled && CustomToolsConfig.getInstance().customShovelIDs.contains(is.getTypeId())) {
return true; return true;
} }
else if (mcMMO.p.spoutEnabled && SpoutToolsAPI.spoutShovels.contains(is)) { else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutShovels.contains(is)) {
return true; return true;
} }
else { else {
@ -116,7 +116,7 @@ public class ItemChecks {
if (customToolsEnabled && CustomToolsConfig.getInstance().customAxeIDs.contains(is.getTypeId())) { if (customToolsEnabled && CustomToolsConfig.getInstance().customAxeIDs.contains(is.getTypeId())) {
return true; return true;
} }
else if (mcMMO.p.spoutEnabled && SpoutToolsAPI.spoutAxes.contains(is)) { else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutAxes.contains(is)) {
return true; return true;
} }
else { else {
@ -144,7 +144,7 @@ public class ItemChecks {
if (customToolsEnabled && CustomToolsConfig.getInstance().customPickaxeIDs.contains(is.getTypeId())) { if (customToolsEnabled && CustomToolsConfig.getInstance().customPickaxeIDs.contains(is.getTypeId())) {
return true; return true;
} }
else if (mcMMO.p.spoutEnabled && SpoutToolsAPI.spoutPickaxes.contains(is)) { else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutPickaxes.contains(is)) {
return true; return true;
} }
else { else {

View File

@ -15,8 +15,8 @@ import com.gmail.nossr50.datatypes.Tree;
public class Leaderboard { public class Leaderboard {
private static mcMMO plugin = mcMMO.p; private static mcMMO plugin = mcMMO.p;
private static String leaderboardsDirectory = plugin.leaderboardDirectory; private static String leaderboardsDirectory = mcMMO.leaderboardDirectory;
private static String location = plugin.usersFile; private final static String location = mcMMO.usersFile;
/** /**
* Create the leaderboards. * Create the leaderboards.

View File

@ -209,7 +209,7 @@ public class Skills {
String capitalized = Misc.getCapitalized(skillType.toString()); String capitalized = Misc.getCapitalized(skillType.toString());
/* Spout Stuff */ /* Spout Stuff */
if (mcMMO.p.spoutEnabled && player instanceof SpoutPlayer) { if (mcMMO.spoutEnabled && player instanceof SpoutPlayer) {
SpoutPlayer sPlayer = SpoutManager.getPlayer(player); SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
if (sPlayer.isSpoutCraftEnabled()) { if (sPlayer.isSpoutCraftEnabled()) {
@ -234,7 +234,7 @@ public class Skills {
} }
/* Always update XP Bar (Check if no levels were gained first to remove redundancy) */ /* Always update XP Bar (Check if no levels were gained first to remove redundancy) */
if (skillups == 0 && mcMMO.p.spoutEnabled && player instanceof SpoutPlayer) { if (skillups == 0 && mcMMO.spoutEnabled && player instanceof SpoutPlayer) {
SpoutPlayer sPlayer = (SpoutPlayer) player; SpoutPlayer sPlayer = (SpoutPlayer) player;
if (sPlayer.isSpoutCraftEnabled()) { if (sPlayer.isSpoutCraftEnabled()) {
if (SpoutConfig.getInstance().getXPBarEnabled()) { if (SpoutConfig.getInstance().getXPBarEnabled()) {

View File

@ -22,9 +22,9 @@ public class Users {
public static void loadUsers() { public static void loadUsers() {
new File(plugin.flatFileDirectory).mkdir(); new File(mcMMO.flatFileDirectory).mkdir();
new File(plugin.leaderboardDirectory).mkdir(); new File(mcMMO.leaderboardDirectory).mkdir();
File theDir = new File(plugin.usersFile); File theDir = new File(mcMMO.usersFile);
if (!theDir.exists()) { if (!theDir.exists()) {
try { try {

View File

@ -16,15 +16,14 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
public class ZipLibrary { public class ZipLibrary {
private final static mcMMO plugin = mcMMO.p; private static String BackupDirectory = mcMMO.mainDirectory + "backup" + File.separator;
private static String BackupDirectory = plugin.mainDirectory + "backup" + File.separator;
private static File BackupDir = new File(BackupDirectory); private static File BackupDir = new File(BackupDirectory);
private static File FlatFileDirectory = new File(plugin.flatFileDirectory); private static File FlatFileDirectory = new File(mcMMO.flatFileDirectory);
private static File ModFileDirectory = new File(plugin.modDirectory); private static File ModFileDirectory = new File(mcMMO.modDirectory);
private static File UsersFile = new File(plugin.usersFile); private static File UsersFile = new File(mcMMO.usersFile);
private static File ConfigFile = new File(plugin.mainDirectory + "config.yml"); private static File ConfigFile = new File(mcMMO.mainDirectory + "config.yml");
private static File TreasuresFile = new File(plugin.mainDirectory + "treasures.yml"); private static File TreasuresFile = new File(mcMMO.mainDirectory + "treasures.yml");
private static File Leaderboards = new File(plugin.leaderboardDirectory); private static File Leaderboards = new File(mcMMO.leaderboardDirectory);
public static void mcMMObackup() throws IOException { public static void mcMMObackup() throws IOException {
if (Config.getInstance().getUseMySQL()) { if (Config.getInstance().getUseMySQL()) {