Major cleanup

This commit is contained in:
bm01
2013-01-26 23:01:55 +01:00
parent f1075f800f
commit bff7919c21
101 changed files with 689 additions and 768 deletions

View File

@@ -4,15 +4,12 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.Database;
import com.gmail.nossr50.locale.LocaleLoader;
public class McpurgeCommand implements CommandExecutor{
private Database database = mcMMO.getPlayerDatabase();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) {
@@ -20,10 +17,10 @@ public class McpurgeCommand implements CommandExecutor{
}
if (Config.getInstance().getUseMySQL()) {
database.purgePowerlessSQL();
Database.purgePowerlessSQL();
if (Config.getInstance().getOldUsersCutoff() != -1) {
database.purgeOldSQL();
Database.purgeOldSQL();
}
}
else {

View File

@@ -16,14 +16,6 @@ import com.gmail.nossr50.database.Database;
import com.gmail.nossr50.locale.LocaleLoader;
public class McremoveCommand implements CommandExecutor {
private final String location;
private final mcMMO plugin;
public McremoveCommand (mcMMO plugin) {
this.plugin = plugin;
this.location = mcMMO.getUsersFile();
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String playerName;
@@ -49,9 +41,8 @@ public class McremoveCommand implements CommandExecutor {
/* MySQL */
if (Config.getInstance().getUseMySQL()) {
Database database = mcMMO.getPlayerDatabase();
int affected = 0;
affected = database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + playerName + "'");
affected = Database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + playerName + "'");
if (affected > 0) {
sender.sendMessage(success);
@@ -78,9 +69,10 @@ public class McremoveCommand implements CommandExecutor {
BufferedReader in = null;
FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath();
try {
FileReader file = new FileReader(location);
FileReader file = new FileReader(usersFilePath);
in = new BufferedReader(file);
StringBuilder writer = new StringBuilder();
String line = "";
@@ -98,11 +90,11 @@ public class McremoveCommand implements CommandExecutor {
}
}
out = new FileWriter(location); //Write out the new file
out = new FileWriter(usersFilePath); //Write out the new file
out.write(writer.toString());
}
catch (Exception e) {
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
}
finally {
if (in != null) {

View File

@@ -13,12 +13,6 @@ import com.gmail.nossr50.runnables.SQLConversionTask;
import com.gmail.nossr50.util.Users;
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) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
@@ -29,7 +23,7 @@ public class MmoupdateCommand implements CommandExecutor {
Users.clearAll();
convertToMySQL();
for (Player x : plugin.getServer().getOnlinePlayers()) {
for (Player x : mcMMO.p.getServer().getOnlinePlayers()) {
Users.addUser(x);
}
@@ -46,6 +40,6 @@ public class MmoupdateCommand implements CommandExecutor {
return;
}
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new SQLConversionTask(plugin), 1);
mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1);
}
}