mcremove command is now fully functional for MySQL

This commit is contained in:
nossr50 2012-02-28 12:16:23 -08:00
parent 649ce1c147
commit 6cc22a3b63
16 changed files with 69 additions and 18 deletions

View File

@ -91,6 +91,21 @@ public class Users {
}
}
public static void removeUserByName(String playerName)
{
Player target = null;
for(Player player : players.keySet())
{
PlayerProfile PP = players.get(player);
if(PP.getPlayerName().equals(playerName))
{
target = player;
}
}
players.remove(target);
}
public static PlayerProfile getProfile(Player player){
if(players.get(player) != null)
return players.get(player);

View File

@ -10,7 +10,6 @@ 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.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.skills.Skills;

View File

@ -10,7 +10,6 @@ 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.locale.mcLocale;
import com.gmail.nossr50.skills.Skills;

View File

@ -10,7 +10,6 @@ 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.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;

View File

@ -10,7 +10,6 @@ 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.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.skills.Skills;

View File

@ -10,7 +10,6 @@ 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.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;

View File

@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;

View File

@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.locale.mcLocale;
public class MccCommand implements CommandExecutor {

View File

@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;

View File

@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;

View File

@ -1,11 +1,14 @@
package com.gmail.nossr50.commands.mc;
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.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.locale.mcLocale;
@ -24,14 +27,10 @@ public class McremoveCommand implements CommandExecutor {
return true;
}
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
return true;
}
if(args.length == 0)
{
sender.sendMessage("Correct usage is /mcremove [Player Name]");
return true;
}
String playerName = args[0]; //Player that we are going to remove
@ -39,12 +38,58 @@ public class McremoveCommand implements CommandExecutor {
//If the server is using MySQL
if(LoadProperties.useMySQL)
{
int userId = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
//Remove user from tables
mcMMO.database.Write("DELETE FROM "
+LoadProperties.MySQLdbName+"."
+LoadProperties.MySQLtablePrefix+"users WHERE "
+LoadProperties.MySQLtablePrefix+"users.id="+userId);
mcMMO.database.Write("DELETE FROM "
+LoadProperties.MySQLdbName+"."
+LoadProperties.MySQLtablePrefix+"cooldowns WHERE "
+LoadProperties.MySQLtablePrefix+"cooldowns.user_id="+userId);
mcMMO.database.Write("DELETE FROM "
+LoadProperties.MySQLdbName+"."
+LoadProperties.MySQLtablePrefix+"huds WHERE "
+LoadProperties.MySQLtablePrefix+"huds.user_id="+userId);
mcMMO.database.Write("DELETE FROM "
+LoadProperties.MySQLdbName+"."
+LoadProperties.MySQLtablePrefix+"spawn WHERE "
+LoadProperties.MySQLtablePrefix+"spawn.user_id="+userId);
mcMMO.database.Write("DELETE FROM "
+LoadProperties.MySQLdbName+"."
+LoadProperties.MySQLtablePrefix+"skills WHERE "
+LoadProperties.MySQLtablePrefix+"skills.user_id="+userId);
mcMMO.database.Write("DELETE FROM "
+LoadProperties.MySQLdbName+"."
+LoadProperties.MySQLtablePrefix+"experience WHERE "
+LoadProperties.MySQLtablePrefix+"experience.user_id="+userId);
System.out.println("User "+playerName+" removed from MySQL DB!");
} else {
}
if(Bukkit.getServer().getPlayer(playerName) != null)
{
Player targetPlayer = Bukkit.getServer().getPlayer(playerName);
if(targetPlayer.isOnline())
{
targetPlayer.kickPlayer("[mcMMO] Stats have been reset! Rejoin!");
Users.removeUserByName(playerName);
} else {
Users.removeUser(targetPlayer);
}
} else {
Users.removeUserByName(playerName);
}
return true;
}
}

View File

@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;

View File

@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;

View File

@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;

View File

@ -9,7 +9,6 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;

View File

@ -1210,4 +1210,8 @@ public class PlayerProfile
return null;
}
}
public String getPlayerName()
{
return playerName;
}
}