mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Even more locale.
This commit is contained in:
parent
ea350c30c8
commit
46d7212d1b
@ -13,104 +13,108 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.Users;
|
import com.gmail.nossr50.Users;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.mcPermissions;
|
import com.gmail.nossr50.commands.CommandHelper;
|
||||||
import com.gmail.nossr50.config.LoadProperties;
|
import com.gmail.nossr50.config.LoadProperties;
|
||||||
import com.gmail.nossr50.locale.mcLocale;
|
import com.gmail.nossr50.locale.mcLocale;
|
||||||
|
|
||||||
public class McremoveCommand implements CommandExecutor {
|
public class McremoveCommand implements CommandExecutor {
|
||||||
String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
|
private final String LOCATION = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
Player player = null;
|
String playerName;
|
||||||
|
String usage = ChatColor.RED + "Correct usage is /mcremove <playername>"; //TODO: Needs more locale.
|
||||||
|
String success;
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) {
|
||||||
player = (Player) sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player != null && !mcPermissions.getInstance().mcremove(player)) {
|
|
||||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.length == 0)
|
switch (args.length) {
|
||||||
{
|
case 1:
|
||||||
sender.sendMessage("Correct usage is /mcremove [Player Name]"); //TODO: Needs more locale.
|
playerName = args[0];
|
||||||
|
success = ChatColor.GREEN + playerName + "was successfully removed from the database!"; //TODO: Locale
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(usage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String playerName = args[0]; //Player that we are going to remove
|
/* MySQL */
|
||||||
|
if (LoadProperties.useMySQL) {
|
||||||
//If the server is using MySQL
|
|
||||||
if(LoadProperties.useMySQL)
|
|
||||||
{
|
|
||||||
int userId = 0;
|
int userId = 0;
|
||||||
userId = mcMMO.database.getInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
|
userId = mcMMO.database.getInt("SELECT id FROM " + LoadProperties.MySQLtablePrefix + "users WHERE user = '" + playerName + "'");
|
||||||
|
|
||||||
if(userId > 0) {
|
if (userId > 0) {
|
||||||
//Remove user from tables
|
|
||||||
mcMMO.database.write("DELETE FROM "
|
mcMMO.database.write("DELETE FROM "
|
||||||
+LoadProperties.MySQLdbName+"."
|
+ LoadProperties.MySQLdbName + "."
|
||||||
+LoadProperties.MySQLtablePrefix+"users WHERE "
|
+ LoadProperties.MySQLtablePrefix + "users WHERE "
|
||||||
+LoadProperties.MySQLtablePrefix+"users.id="+userId);
|
+ LoadProperties.MySQLtablePrefix + "users.id=" + userId);
|
||||||
|
|
||||||
mcMMO.database.write("DELETE FROM "
|
mcMMO.database.write("DELETE FROM "
|
||||||
+LoadProperties.MySQLdbName+"."
|
+ LoadProperties.MySQLdbName + "."
|
||||||
+LoadProperties.MySQLtablePrefix+"cooldowns WHERE "
|
+ LoadProperties.MySQLtablePrefix + "cooldowns WHERE "
|
||||||
+LoadProperties.MySQLtablePrefix+"cooldowns.user_id="+userId);
|
+ LoadProperties.MySQLtablePrefix + "cooldowns.user_id=" + userId);
|
||||||
|
|
||||||
mcMMO.database.write("DELETE FROM "
|
mcMMO.database.write("DELETE FROM "
|
||||||
+LoadProperties.MySQLdbName+"."
|
+ LoadProperties.MySQLdbName + "."
|
||||||
+LoadProperties.MySQLtablePrefix+"huds WHERE "
|
+ LoadProperties.MySQLtablePrefix + "huds WHERE "
|
||||||
+LoadProperties.MySQLtablePrefix+"huds.user_id="+userId);
|
+ LoadProperties.MySQLtablePrefix + "huds.user_id=" + userId);
|
||||||
|
|
||||||
mcMMO.database.write("DELETE FROM "
|
mcMMO.database.write("DELETE FROM "
|
||||||
+LoadProperties.MySQLdbName+"."
|
+ LoadProperties.MySQLdbName + "."
|
||||||
+LoadProperties.MySQLtablePrefix+"skills WHERE "
|
+ LoadProperties.MySQLtablePrefix + "skills WHERE "
|
||||||
+LoadProperties.MySQLtablePrefix+"skills.user_id="+userId);
|
+ LoadProperties.MySQLtablePrefix + "skills.user_id=" + userId);
|
||||||
|
|
||||||
mcMMO.database.write("DELETE FROM "
|
mcMMO.database.write("DELETE FROM "
|
||||||
+LoadProperties.MySQLdbName+"."
|
+ LoadProperties.MySQLdbName + "."
|
||||||
+LoadProperties.MySQLtablePrefix+"experience WHERE "
|
+ LoadProperties.MySQLtablePrefix + "experience WHERE "
|
||||||
+LoadProperties.MySQLtablePrefix+"experience.user_id="+userId);
|
+ LoadProperties.MySQLtablePrefix + "experience.user_id=" + userId);
|
||||||
|
|
||||||
|
sender.sendMessage(success);
|
||||||
|
|
||||||
sender.sendMessage("User "+playerName+" removed from MySQL DB!"); //TODO: Needs more locale.
|
|
||||||
} else {
|
|
||||||
sender.sendMessage("Unable to find player named "+playerName+" in the database!");
|
|
||||||
}
|
}
|
||||||
} else {
|
else {
|
||||||
if(removeFlatFileUser(playerName)) {
|
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
|
||||||
sender.sendMessage(ChatColor.GREEN+"[mcMMO] It worked! User was removed.");
|
}
|
||||||
} else {
|
}
|
||||||
sender.sendMessage(ChatColor.RED+"[mcMMO] Couldn't find the user, remember its case sensitive!");
|
else {
|
||||||
|
if (removeFlatFileUser(playerName)) {
|
||||||
|
sender.sendMessage(success);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Force PlayerProfile stuff to update
|
//Force PlayerProfile stuff to update
|
||||||
if(Bukkit.getServer().getPlayer(playerName) != null && Users.players.containsKey(playerName.toLowerCase()))
|
Player player = Bukkit.getServer().getPlayer(playerName);
|
||||||
{
|
|
||||||
Users.players.remove(playerName.toLowerCase());
|
|
||||||
Users.addUser(Bukkit.getServer().getPlayer(playerName));
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage("[mcMMO] mcremove operation completed."); //TODO: Needs more locale.
|
if (player != null && Users.players.containsKey(playerName.toLowerCase())) {
|
||||||
|
Users.removeUser(player);
|
||||||
|
Users.addUser(player);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean removeFlatFileUser(String playerName) {
|
private boolean removeFlatFileUser(String playerName) {
|
||||||
boolean worked = false;
|
boolean worked = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileReader file = new FileReader(location);
|
FileReader file = new FileReader(LOCATION);
|
||||||
BufferedReader in = new BufferedReader(file);
|
BufferedReader in = new BufferedReader(file);
|
||||||
StringBuilder writer = new StringBuilder();
|
StringBuilder writer = new StringBuilder();
|
||||||
String line = "";
|
String line = "";
|
||||||
|
|
||||||
while ((line = in.readLine()) != null) {
|
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(!line.split(":")[0].equalsIgnoreCase(playerName))
|
/* Write out the same file but when we get to the player we want to remove, we skip his line. */
|
||||||
{
|
if (!line.split(":")[0].equalsIgnoreCase(playerName)) {
|
||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
System.out.println("User found, removing...");
|
System.out.println("User found, removing...");
|
||||||
worked = true;
|
worked = true;
|
||||||
continue; //Skip the player
|
continue; //Skip the player
|
||||||
@ -118,12 +122,14 @@ public class McremoveCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
in.close();
|
in.close();
|
||||||
FileWriter out = new FileWriter(location); //Write out the new file
|
FileWriter out = new FileWriter(LOCATION); //Write out the new file
|
||||||
out.write(writer.toString());
|
out.write(writer.toString());
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
return worked;
|
return worked;
|
||||||
} catch (Exception e) {
|
}
|
||||||
Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
catch (Exception e) {
|
||||||
|
Bukkit.getLogger().severe("Exception while reading " + LOCATION + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
return worked;
|
return worked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,7 +402,7 @@ Commands.Party.None=[[RED]]You are not in a party.
|
|||||||
Commands.Party.Quit=[[RED]]- Leave your current party
|
Commands.Party.Quit=[[RED]]- Leave your current party
|
||||||
Commands.Party.Teleport=<playername> [[RED]]- Teleport to party member
|
Commands.Party.Teleport=<playername> [[RED]]- Teleport to party member
|
||||||
Commands.Party.Toggle=[[RED]]- Toggle Party Chat
|
Commands.Party.Toggle=[[RED]]- Toggle Party Chat
|
||||||
Commands.Party=<party name> [[RED]]- Create/Join designated party
|
Commands.Party=<partyname> [[RED]]- Create/Join designated party
|
||||||
Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Leaderboard--
|
Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Leaderboard--
|
||||||
Commands.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0}
|
Commands.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0}
|
||||||
Commands.SkillInfo=/<skillname> [[RED]]- View detailed information about a skill
|
Commands.SkillInfo=/<skillname> [[RED]]- View detailed information about a skill
|
||||||
|
Loading…
Reference in New Issue
Block a user