MmoupdateCommand.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.gmail.nossr50.commands.general;
  2. import org.bukkit.ChatColor;
  3. import org.bukkit.command.Command;
  4. import org.bukkit.command.CommandExecutor;
  5. import org.bukkit.command.CommandSender;
  6. import org.bukkit.entity.Player;
  7. import com.gmail.nossr50.Users;
  8. import com.gmail.nossr50.mcMMO;
  9. import com.gmail.nossr50.commands.CommandHelper;
  10. import com.gmail.nossr50.config.Config;
  11. import com.gmail.nossr50.runnables.SQLConversionTask;
  12. public class MmoupdateCommand implements CommandExecutor {
  13. private final mcMMO plugin;
  14. public MmoupdateCommand (mcMMO plugin) {
  15. this.plugin = plugin;
  16. }
  17. @Override
  18. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  19. if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
  20. return true;
  21. }
  22. sender.sendMessage(ChatColor.GRAY + "Starting conversion..."); //TODO: Needs more locale.
  23. Users.clearUsers();
  24. convertToMySQL();
  25. for (Player x : plugin.getServer().getOnlinePlayers()) {
  26. Users.addUser(x);
  27. }
  28. sender.sendMessage(ChatColor.GREEN + "Conversion finished!"); //TODO: Needs more locale.
  29. return true;
  30. }
  31. /**
  32. * Convert FlatFile data to MySQL data.
  33. */
  34. private void convertToMySQL() {
  35. if (!Config.getUseMySQL()) {
  36. return;
  37. }
  38. plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new SQLConversionTask(plugin), 1);
  39. }
  40. }