Formatting and localizing.

This commit is contained in:
GJ
2013-08-21 13:18:50 -04:00
committed by TfT_02
parent 68e433b3b7
commit 223649ec28
7 changed files with 81 additions and 70 deletions

View File

@ -1,11 +1,14 @@
package com.gmail.nossr50.commands.database;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.datatypes.experience.FormulaType;
@ -15,6 +18,18 @@ import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public class McconvertCommand implements TabExecutor {
private static final List<String> FORMULA_TYPES;
static {
ArrayList<String> types = new ArrayList<String>();
for (FormulaType type : FormulaType.values()) {
types.add(type.toString());
}
Collections.sort(types);
FORMULA_TYPES = ImmutableList.copyOf(types);
}
/*
* Do this later; Use mcconvert instead of mmoupdate:
@ -28,16 +43,12 @@ public class McconvertCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
sender.sendMessage("Usage is /mcconvert <linear | exponential>");
return true;
case 1:
FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType();
FormulaType newType = FormulaType.getFormulaType(args[0].toUpperCase());
if (newType == FormulaType.UNKNOWN) {
sender.sendMessage("Unknown formula type! Valid types are: LINEAR and EXPONENTIAL");
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Invalid"));
return true;
}
@ -47,23 +58,30 @@ public class McconvertCommand implements TabExecutor {
}
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Start", previousType.toString(), newType.toString()));
UserManager.saveAll();
UserManager.clearAll();
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
UserManager.addUser(player);
}
return true;
default:
break;
return false;
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<String>(FORMULA_TYPES.size()));
default:
return ImmutableList.of();
}
}
}