mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-04-03 18:26:24 +02:00
50 lines
1.9 KiB
Java
50 lines
1.9 KiB
Java
package com.gmail.nossr50.commands.experience;
|
|
|
|
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
import com.gmail.nossr50.mcMMO;
|
|
import com.gmail.nossr50.runnables.database.FormulaConversionTask;
|
|
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
|
import com.gmail.nossr50.util.player.UserManager;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandExecutor;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
public class ConvertExperienceCommand implements CommandExecutor {
|
|
@Override
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
switch (args.length) {
|
|
case 2:
|
|
|
|
|
|
for(FormulaType formulaType : FormulaType.values()) {
|
|
if(formulaType.toString().equalsIgnoreCase(args[1])) {
|
|
FormulaType previousType = formulaType;
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), mcMMO.getConfigManager().getConfigLeveling().getFormulaType().toString()));
|
|
|
|
UserManager.saveAll();
|
|
UserManager.clearAll();
|
|
|
|
new FormulaConversionTask(sender, previousType).runTaskLater(mcMMO.p, 1);
|
|
|
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
|
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid"));
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
}
|