mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Optimized our String/number conversions a bit. Also moved all
String-related util functions from Misc.java to StringUtils.java
This commit is contained in:
parent
b1db0d037d
commit
2ad73e9b2c
@ -46,7 +46,7 @@ import com.gmail.nossr50.skills.utilities.SkillType;
|
|||||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingCommand;
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingCommand;
|
||||||
import com.gmail.nossr50.spout.commands.MchudCommand;
|
import com.gmail.nossr50.spout.commands.MchudCommand;
|
||||||
import com.gmail.nossr50.spout.commands.XplockCommand;
|
import com.gmail.nossr50.spout.commands.XplockCommand;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public final class CommandRegistrationHelper {
|
public final class CommandRegistrationHelper {
|
||||||
private CommandRegistrationHelper() {};
|
private CommandRegistrationHelper() {};
|
||||||
@ -55,12 +55,12 @@ public final class CommandRegistrationHelper {
|
|||||||
public static void registerSkillCommands() {
|
public static void registerSkillCommands() {
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.values()) {
|
||||||
String commandName = skill.toString().toLowerCase();
|
String commandName = skill.toString().toLowerCase();
|
||||||
String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase();
|
String localizedName = LocaleLoader.getString(StringUtils.getCapitalized(commandName) + ".SkillName").toLowerCase();
|
||||||
|
|
||||||
PluginCommand command;
|
PluginCommand command;
|
||||||
|
|
||||||
command = mcMMO.p.getCommand(commandName);
|
command = mcMMO.p.getCommand(commandName);
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", Misc.getCapitalized(localizedName)));
|
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", StringUtils.getCapitalized(localizedName)));
|
||||||
command.setPermission("mcmmo.commands." + commandName);
|
command.setPermission("mcmmo.commands." + commandName);
|
||||||
command.setPermissionMessage(permissionsMessage);
|
command.setPermissionMessage(permissionsMessage);
|
||||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", localizedName));
|
command.setUsage(LocaleLoader.getString("Commands.Usage.0", localizedName));
|
||||||
|
@ -10,7 +10,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class AddlevelsCommand implements CommandExecutor{
|
public class AddlevelsCommand implements CommandExecutor{
|
||||||
@ -39,11 +39,11 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Misc.isInt(args[1])) {
|
if (!StringUtils.isInt(args[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
levels = Integer.valueOf(args[1]);
|
levels = Integer.parseInt(args[1]);
|
||||||
profile = Users.getPlayer((Player) sender).getProfile();
|
profile = Users.getPlayer((Player) sender).getProfile();
|
||||||
|
|
||||||
if (allSkills) {
|
if (allSkills) {
|
||||||
@ -63,7 +63,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(args[0])));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, StringUtils.getCapitalized(args[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -82,12 +82,12 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Misc.isInt(args[2])) {
|
if (!StringUtils.isInt(args[2])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||||
levels = Integer.valueOf(args[2]);
|
levels = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
if (mcMMOPlayer == null) {
|
if (mcMMOPlayer == null) {
|
||||||
@ -129,7 +129,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile.addLevels(SkillType.getSkill(args[1]), levels);
|
profile.addLevels(SkillType.getSkill(args[1]), levels);
|
||||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(args[1])));
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, StringUtils.getCapitalized(args[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(args[1]), args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", StringUtils.getCapitalized(args[1]), args[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -9,7 +9,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class AddxpCommand implements CommandExecutor {
|
public class AddxpCommand implements CommandExecutor {
|
||||||
@ -39,11 +39,11 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Misc.isInt(args[1])) {
|
if (!StringUtils.isInt(args[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp = Integer.valueOf(args[1]);
|
xp = Integer.parseInt(args[1]);
|
||||||
mcMMOPlayer = Users.getPlayer((Player) sender);
|
mcMMOPlayer = Users.getPlayer((Player) sender);
|
||||||
profile = mcMMOPlayer.getProfile();
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mcMMOPlayer.applyXpGain(SkillType.getSkill(args[0]), xp);
|
mcMMOPlayer.applyXpGain(SkillType.getSkill(args[0]), xp);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(args[0])));
|
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, StringUtils.getCapitalized(args[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -79,12 +79,12 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Misc.isInt(args[2])) {
|
if (!StringUtils.isInt(args[2])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer = Users.getPlayer(args[0]);
|
mcMMOPlayer = Users.getPlayer(args[0]);
|
||||||
xp = Integer.valueOf(args[2]);
|
xp = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
if (mcMMOPlayer == null) {
|
if (mcMMOPlayer == null) {
|
||||||
@ -125,7 +125,7 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mcMMOPlayer.applyXpGain(SkillType.getSkill(args[1]), xp);
|
mcMMOPlayer.applyXpGain(SkillType.getSkill(args[1]), xp);
|
||||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(args[1])));
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, StringUtils.getCapitalized(args[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(args[1]), args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", StringUtils.getCapitalized(args[1]), args[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class HardcoreCommand implements CommandExecutor{
|
public class HardcoreCommand implements CommandExecutor{
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ public class HardcoreCommand implements CommandExecutor{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Misc.isDouble(args[0])) {
|
if (!StringUtils.isDouble(args[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ public class HardcoreCommand implements CommandExecutor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||||
double newPercent = Misc.getDouble(args[0]);
|
double newPercent = Double.parseDouble(args[0]);
|
||||||
|
|
||||||
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent);
|
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent);
|
||||||
sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D)));
|
sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D)));
|
||||||
|
@ -10,7 +10,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class MmoeditCommand implements CommandExecutor {
|
public class MmoeditCommand implements CommandExecutor {
|
||||||
@ -39,11 +39,11 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Misc.isInt(args[1])) {
|
if (!StringUtils.isInt(args[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
newValue = Integer.valueOf(args[1]);
|
newValue = Integer.parseInt(args[1]);
|
||||||
profile = Users.getPlayer((Player) sender).getProfile();
|
profile = Users.getPlayer((Player) sender).getProfile();
|
||||||
|
|
||||||
if (allSkills) {
|
if (allSkills) {
|
||||||
@ -59,7 +59,7 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile.modifySkill(SkillType.getSkill(args[0]), newValue);
|
profile.modifySkill(SkillType.getSkill(args[0]), newValue);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(args[0]), newValue));
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", StringUtils.getCapitalized(args[0]), newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -78,11 +78,11 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Misc.isInt(args[2])) {
|
if (!StringUtils.isInt(args[2])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
newValue = Integer.valueOf(args[2]);
|
newValue = Integer.parseInt(args[2]);
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
@ -125,7 +125,7 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile.modifySkill(SkillType.getSkill(args[1]), newValue);
|
profile.modifySkill(SkillType.getSkill(args[1]), newValue);
|
||||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(args[1]), newValue));
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", StringUtils.getCapitalized(args[1]), newValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(args[1]), args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", StringUtils.getCapitalized(args[1]), args[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -10,7 +10,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class SkillresetCommand implements CommandExecutor {
|
public class SkillresetCommand implements CommandExecutor {
|
||||||
@ -72,7 +72,7 @@ public class SkillresetCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile.modifySkill(SkillType.getSkill(args[0]), 0);
|
profile.modifySkill(SkillType.getSkill(args[0]), 0);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(args[0])));
|
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", StringUtils.getCapitalized(args[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -152,7 +152,7 @@ public class SkillresetCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile.modifySkill(SkillType.getSkill(args[1]), 0);
|
profile.modifySkill(SkillType.getSkill(args[1]), 0);
|
||||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(args[1])));
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", StringUtils.getCapitalized(args[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ public class SkillresetCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(args[1]), args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", StringUtils.getCapitalized(args[1]), args[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class VampirismCommand implements CommandExecutor {
|
public class VampirismCommand implements CommandExecutor {
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public class VampirismCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Misc.isDouble(args[0])) {
|
if (!StringUtils.isDouble(args[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class VampirismCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||||
double newPercent = Misc.getDouble(args[0]);
|
double newPercent = Double.parseDouble(args[0]);
|
||||||
|
|
||||||
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent);
|
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent);
|
||||||
sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
|
sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class XprateCommand implements CommandExecutor {
|
public class XprateCommand implements CommandExecutor {
|
||||||
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||||
@ -34,7 +34,7 @@ public class XprateCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (!Misc.isInt(args[0])) {
|
if (!StringUtils.isInt(args[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public class XprateCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
||||||
int newXpRate = Misc.getInt(args[0]);
|
int newXpRate = Integer.parseInt(args[0]);
|
||||||
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
||||||
|
|
||||||
if (mcMMO.p.isXPEventEnabled()) {
|
if (mcMMO.p.isXPEventEnabled()) {
|
||||||
|
@ -13,7 +13,7 @@ import com.gmail.nossr50.database.Database;
|
|||||||
import com.gmail.nossr50.database.Leaderboard;
|
import com.gmail.nossr50.database.Leaderboard;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class MctopCommand implements CommandExecutor {
|
public class MctopCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
@ -26,8 +26,8 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (Misc.isInt(args[0])) {
|
if (StringUtils.isInt(args[0])) {
|
||||||
display(Integer.valueOf(args[0]), "ALL", sender, useMySQL, command);
|
display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command);
|
||||||
}
|
}
|
||||||
else if (SkillTools.isSkill(args[0])) {
|
else if (SkillTools.isSkill(args[0])) {
|
||||||
display(1, args[0], sender, useMySQL, command);
|
display(1, args[0], sender, useMySQL, command);
|
||||||
@ -42,15 +42,15 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (!Misc.isInt(args[1])) {
|
if (!StringUtils.isInt(args[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SkillTools.isSkill(args[0])) {
|
if (SkillTools.isSkill(args[0])) {
|
||||||
display(Integer.valueOf(args[1]), args[0], sender, useMySQL, command);
|
display(Integer.parseInt(args[1]), args[0], sender, useMySQL, command);
|
||||||
}
|
}
|
||||||
else if (SkillTools.isLocalizedSkill(args[0])) {
|
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||||
display(Integer.valueOf(args[1]), SkillTools.translateLocalizedSkill(args[0]), sender, useMySQL, command);
|
display(Integer.parseInt(args[1]), SkillTools.translateLocalizedSkill(args[0]), sender, useMySQL, command);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
@ -91,7 +91,7 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", Misc.getCapitalized(skill)));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int n = (page * 10) - 9; // Position
|
int n = (page * 10) - 9; // Position
|
||||||
@ -128,7 +128,7 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", Misc.getCapitalized(query)));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int place = (page * 10) - 9;
|
int place = (page * 10) - 9;
|
||||||
|
@ -15,7 +15,7 @@ import org.bukkit.Bukkit;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public final class Leaderboard {
|
public final class Leaderboard {
|
||||||
private static HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
private static HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
||||||
@ -71,64 +71,64 @@ public final class Leaderboard {
|
|||||||
|
|
||||||
players.add(p);
|
players.add(p);
|
||||||
|
|
||||||
if (character.length > 1 && Misc.isInt(character[1])) {
|
if (character.length > 1 && StringUtils.isInt(character[1])) {
|
||||||
mining.add(new PlayerStat(p, Integer.valueOf(character[1])));
|
mining.add(new PlayerStat(p, Integer.parseInt(character[1])));
|
||||||
powerLevel += Integer.valueOf(character[1]);
|
powerLevel += Integer.parseInt(character[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.length > 5 && Misc.isInt(character[5])) {
|
if (character.length > 5 && StringUtils.isInt(character[5])) {
|
||||||
woodcutting.add(new PlayerStat(p, Integer.valueOf(character[5])));
|
woodcutting.add(new PlayerStat(p, Integer.parseInt(character[5])));
|
||||||
powerLevel += Integer.valueOf(character[5]);
|
powerLevel += Integer.parseInt(character[5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.length > 7 && Misc.isInt(character[7])) {
|
if (character.length > 7 && StringUtils.isInt(character[7])) {
|
||||||
repair.add(new PlayerStat(p, Integer.valueOf(character[7])));
|
repair.add(new PlayerStat(p, Integer.parseInt(character[7])));
|
||||||
powerLevel += Integer.valueOf(character[7]);
|
powerLevel += Integer.parseInt(character[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.length > 8 && Misc.isInt(character[8])) {
|
if (character.length > 8 && StringUtils.isInt(character[8])) {
|
||||||
unarmed.add(new PlayerStat(p, Integer.valueOf(character[8])));
|
unarmed.add(new PlayerStat(p, Integer.parseInt(character[8])));
|
||||||
powerLevel += Integer.valueOf(character[8]);
|
powerLevel += Integer.parseInt(character[8]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.length > 9 && Misc.isInt(character[9])) {
|
if (character.length > 9 && StringUtils.isInt(character[9])) {
|
||||||
herbalism.add(new PlayerStat(p, Integer.valueOf(character[9])));
|
herbalism.add(new PlayerStat(p, Integer.parseInt(character[9])));
|
||||||
powerLevel += Integer.valueOf(character[9]);
|
powerLevel += Integer.parseInt(character[9]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.length > 10 && Misc.isInt(character[10])) {
|
if (character.length > 10 && StringUtils.isInt(character[10])) {
|
||||||
excavation.add(new PlayerStat(p, Integer.valueOf(character[10])));
|
excavation.add(new PlayerStat(p, Integer.parseInt(character[10])));
|
||||||
powerLevel += Integer.valueOf(character[10]);
|
powerLevel += Integer.parseInt(character[10]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.length > 11 && Misc.isInt(character[11])) {
|
if (character.length > 11 && StringUtils.isInt(character[11])) {
|
||||||
archery.add(new PlayerStat(p, Integer.valueOf(character[11])));
|
archery.add(new PlayerStat(p, Integer.parseInt(character[11])));
|
||||||
powerLevel += Integer.valueOf(character[11]);
|
powerLevel += Integer.parseInt(character[11]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.length > 12 && Misc.isInt(character[12])) {
|
if (character.length > 12 && StringUtils.isInt(character[12])) {
|
||||||
swords.add(new PlayerStat(p, Integer.valueOf(character[12])));
|
swords.add(new PlayerStat(p, Integer.parseInt(character[12])));
|
||||||
powerLevel += Integer.valueOf(character[12]);
|
powerLevel += Integer.parseInt(character[12]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.length > 13 && Misc.isInt(character[13])) {
|
if (character.length > 13 && StringUtils.isInt(character[13])) {
|
||||||
axes.add(new PlayerStat(p, Integer.valueOf(character[13])));
|
axes.add(new PlayerStat(p, Integer.parseInt(character[13])));
|
||||||
powerLevel += Integer.valueOf(character[13]);
|
powerLevel += Integer.parseInt(character[13]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.length > 14 && Misc.isInt(character[14])) {
|
if (character.length > 14 && StringUtils.isInt(character[14])) {
|
||||||
acrobatics.add(new PlayerStat(p, Integer.valueOf(character[14])));
|
acrobatics.add(new PlayerStat(p, Integer.parseInt(character[14])));
|
||||||
powerLevel += Integer.valueOf(character[14]);
|
powerLevel += Integer.parseInt(character[14]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.length > 24 && Misc.isInt(character[24])) {
|
if (character.length > 24 && StringUtils.isInt(character[24])) {
|
||||||
taming.add(new PlayerStat(p, Integer.valueOf(character[24])));
|
taming.add(new PlayerStat(p, Integer.parseInt(character[24])));
|
||||||
powerLevel += Integer.valueOf(character[24]);
|
powerLevel += Integer.parseInt(character[24]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.length > 34 && Misc.isInt(character[34])) {
|
if (character.length > 34 && StringUtils.isInt(character[34])) {
|
||||||
fishing.add(new PlayerStat(p, Integer.valueOf(character[34])));
|
fishing.add(new PlayerStat(p, Integer.parseInt(character[34])));
|
||||||
powerLevel += Integer.valueOf(character[34]);
|
powerLevel += Integer.parseInt(character[34]);
|
||||||
}
|
}
|
||||||
|
|
||||||
powerLevels.add(new PlayerStat(p, powerLevel));
|
powerLevels.add(new PlayerStat(p, powerLevel));
|
||||||
@ -355,7 +355,7 @@ public final class Leaderboard {
|
|||||||
String[] splitLine = line.split(":");
|
String[] splitLine = line.split(":");
|
||||||
|
|
||||||
if (splitLine.length > 37) {
|
if (splitLine.length > 37) {
|
||||||
if (currentTime - (Misc.getLong(line.split(":")[37]) * 1000) <= purgeTime) {
|
if (currentTime - (StringUtils.getLong(line.split(":")[37]) * 1000) <= purgeTime) {
|
||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -7,6 +7,7 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.Database;
|
import com.gmail.nossr50.database.Database;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class SQLConversionTask implements Runnable {
|
public class SQLConversionTask implements Runnable {
|
||||||
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||||
@ -175,34 +176,34 @@ public class SQLConversionTask implements Runnable {
|
|||||||
Database.write("UPDATE "
|
Database.write("UPDATE "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "skills SET "
|
+ "skills SET "
|
||||||
+ " taming = taming+" + Misc.getInt(taming)
|
+ " taming = taming+" + StringUtils.getInt(taming)
|
||||||
+ ", mining = mining+" + Misc.getInt(mining)
|
+ ", mining = mining+" + StringUtils.getInt(mining)
|
||||||
+ ", repair = repair+" + Misc.getInt(repair)
|
+ ", repair = repair+" + StringUtils.getInt(repair)
|
||||||
+ ", woodcutting = woodcutting+" + Misc.getInt(woodcutting)
|
+ ", woodcutting = woodcutting+" + StringUtils.getInt(woodcutting)
|
||||||
+ ", unarmed = unarmed+" + Misc.getInt(unarmed)
|
+ ", unarmed = unarmed+" + StringUtils.getInt(unarmed)
|
||||||
+ ", herbalism = herbalism+" + Misc.getInt(herbalism)
|
+ ", herbalism = herbalism+" + StringUtils.getInt(herbalism)
|
||||||
+ ", excavation = excavation+" + Misc.getInt(excavation)
|
+ ", excavation = excavation+" + StringUtils.getInt(excavation)
|
||||||
+ ", archery = archery+" + Misc.getInt(archery)
|
+ ", archery = archery+" + StringUtils.getInt(archery)
|
||||||
+ ", swords = swords+" + Misc.getInt(swords)
|
+ ", swords = swords+" + StringUtils.getInt(swords)
|
||||||
+ ", axes = axes+" + Misc.getInt(axes)
|
+ ", axes = axes+" + StringUtils.getInt(axes)
|
||||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
+ ", acrobatics = acrobatics+" + StringUtils.getInt(acrobatics)
|
||||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
+ ", fishing = fishing+" + StringUtils.getInt(fishing)
|
||||||
+ " WHERE user_id = " + id);
|
+ " WHERE user_id = " + id);
|
||||||
Database.write("UPDATE "
|
Database.write("UPDATE "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "experience SET "
|
+ "experience SET "
|
||||||
+ " taming = " + Misc.getInt(tamingXP)
|
+ " taming = " + StringUtils.getInt(tamingXP)
|
||||||
+ ", mining = " + Misc.getInt(miningXP)
|
+ ", mining = " + StringUtils.getInt(miningXP)
|
||||||
+ ", repair = " + Misc.getInt(repairXP)
|
+ ", repair = " + StringUtils.getInt(repairXP)
|
||||||
+ ", woodcutting = " + Misc.getInt(woodCuttingXP)
|
+ ", woodcutting = " + StringUtils.getInt(woodCuttingXP)
|
||||||
+ ", unarmed = " + Misc.getInt(unarmedXP)
|
+ ", unarmed = " + StringUtils.getInt(unarmedXP)
|
||||||
+ ", herbalism = " + Misc.getInt(herbalismXP)
|
+ ", herbalism = " + StringUtils.getInt(herbalismXP)
|
||||||
+ ", excavation = " + Misc.getInt(excavationXP)
|
+ ", excavation = " + StringUtils.getInt(excavationXP)
|
||||||
+ ", archery = " + Misc.getInt(archeryXP)
|
+ ", archery = " + StringUtils.getInt(archeryXP)
|
||||||
+ ", swords = " + Misc.getInt(swordsXP)
|
+ ", swords = " + StringUtils.getInt(swordsXP)
|
||||||
+ ", axes = " + Misc.getInt(axesXP)
|
+ ", axes = " + StringUtils.getInt(axesXP)
|
||||||
+ ", acrobatics = " + Misc.getInt(acrobaticsXP)
|
+ ", acrobatics = " + StringUtils.getInt(acrobaticsXP)
|
||||||
+ ", fishing = " + Misc.getInt(fishingXP)
|
+ ", fishing = " + StringUtils.getInt(fishingXP)
|
||||||
+ " WHERE user_id = " + id);
|
+ " WHERE user_id = " + id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -237,34 +238,34 @@ public class SQLConversionTask implements Runnable {
|
|||||||
Database.write("UPDATE "
|
Database.write("UPDATE "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "skills SET "
|
+ "skills SET "
|
||||||
+ " taming = taming+" + Misc.getInt(taming)
|
+ " taming = taming+" + StringUtils.getInt(taming)
|
||||||
+ ", mining = mining+" + Misc.getInt(mining)
|
+ ", mining = mining+" + StringUtils.getInt(mining)
|
||||||
+ ", repair = repair+" + Misc.getInt(repair)
|
+ ", repair = repair+" + StringUtils.getInt(repair)
|
||||||
+ ", woodcutting = woodcutting+" + Misc.getInt(woodcutting)
|
+ ", woodcutting = woodcutting+" + StringUtils.getInt(woodcutting)
|
||||||
+ ", unarmed = unarmed+" + Misc.getInt(unarmed)
|
+ ", unarmed = unarmed+" + StringUtils.getInt(unarmed)
|
||||||
+ ", herbalism = herbalism+" + Misc.getInt(herbalism)
|
+ ", herbalism = herbalism+" + StringUtils.getInt(herbalism)
|
||||||
+ ", excavation = excavation+" + Misc.getInt(excavation)
|
+ ", excavation = excavation+" + StringUtils.getInt(excavation)
|
||||||
+ ", archery = archery+" + Misc.getInt(archery)
|
+ ", archery = archery+" + StringUtils.getInt(archery)
|
||||||
+ ", swords = swords+" + Misc.getInt(swords)
|
+ ", swords = swords+" + StringUtils.getInt(swords)
|
||||||
+ ", axes = axes+" + Misc.getInt(axes)
|
+ ", axes = axes+" + StringUtils.getInt(axes)
|
||||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
+ ", acrobatics = acrobatics+" + StringUtils.getInt(acrobatics)
|
||||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
+ ", fishing = fishing+" + StringUtils.getInt(fishing)
|
||||||
+ " WHERE user_id = " + id);
|
+ " WHERE user_id = " + id);
|
||||||
Database.write("UPDATE "
|
Database.write("UPDATE "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "experience SET "
|
+ "experience SET "
|
||||||
+ " taming = " + Misc.getInt(tamingXP)
|
+ " taming = " + StringUtils.getInt(tamingXP)
|
||||||
+ ", mining = " + Misc.getInt(miningXP)
|
+ ", mining = " + StringUtils.getInt(miningXP)
|
||||||
+ ", repair = " + Misc.getInt(repairXP)
|
+ ", repair = " + StringUtils.getInt(repairXP)
|
||||||
+ ", woodcutting = " + Misc.getInt(woodCuttingXP)
|
+ ", woodcutting = " + StringUtils.getInt(woodCuttingXP)
|
||||||
+ ", unarmed = " + Misc.getInt(unarmedXP)
|
+ ", unarmed = " + StringUtils.getInt(unarmedXP)
|
||||||
+ ", herbalism = " + Misc.getInt(herbalismXP)
|
+ ", herbalism = " + StringUtils.getInt(herbalismXP)
|
||||||
+ ", excavation = " + Misc.getInt(excavationXP)
|
+ ", excavation = " + StringUtils.getInt(excavationXP)
|
||||||
+ ", archery = " + Misc.getInt(archeryXP)
|
+ ", archery = " + StringUtils.getInt(archeryXP)
|
||||||
+ ", swords = " + Misc.getInt(swordsXP)
|
+ ", swords = " + StringUtils.getInt(swordsXP)
|
||||||
+ ", axes = " + Misc.getInt(axesXP)
|
+ ", axes = " + StringUtils.getInt(axesXP)
|
||||||
+ ", acrobatics = " + Misc.getInt(acrobaticsXP)
|
+ ", acrobatics = " + StringUtils.getInt(acrobaticsXP)
|
||||||
+ ", fishing = " + Misc.getInt(fishingXP)
|
+ ", fishing = " + StringUtils.getInt(fishingXP)
|
||||||
+ " WHERE user_id = " + id);
|
+ " WHERE user_id = " + id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import com.gmail.nossr50.spout.SpoutConfig;
|
|||||||
import com.gmail.nossr50.spout.huds.HudType;
|
import com.gmail.nossr50.spout.huds.HudType;
|
||||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
import com.gmail.nossr50.spout.huds.SpoutHud;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class PlayerProfile {
|
public class PlayerProfile {
|
||||||
private String playerName;
|
private String playerName;
|
||||||
@ -205,49 +206,49 @@ public class PlayerProfile {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character.length > 1 && Misc.isInt(character[1]))
|
if (character.length > 1 && StringUtils.isInt(character[1]))
|
||||||
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
||||||
if (character.length > 4 && Misc.isInt(character[4]))
|
if (character.length > 4 && StringUtils.isInt(character[4]))
|
||||||
skillsXp.put(SkillType.MINING, Integer.valueOf(character[4]));
|
skillsXp.put(SkillType.MINING, Integer.valueOf(character[4]));
|
||||||
if (character.length > 5 && Misc.isInt(character[5]))
|
if (character.length > 5 && StringUtils.isInt(character[5]))
|
||||||
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
|
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
|
||||||
if (character.length > 6 && Misc.isInt(character[6]))
|
if (character.length > 6 && StringUtils.isInt(character[6]))
|
||||||
skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6]));
|
skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6]));
|
||||||
if (character.length > 7 && Misc.isInt(character[7]))
|
if (character.length > 7 && StringUtils.isInt(character[7]))
|
||||||
skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
|
skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
|
||||||
if (character.length > 8 && Misc.isInt(character[8]))
|
if (character.length > 8 && StringUtils.isInt(character[8]))
|
||||||
skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
|
skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
|
||||||
if (character.length > 9 && Misc.isInt(character[9]))
|
if (character.length > 9 && StringUtils.isInt(character[9]))
|
||||||
skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
|
skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
|
||||||
if (character.length > 10 && Misc.isInt(character[10]))
|
if (character.length > 10 && StringUtils.isInt(character[10]))
|
||||||
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
|
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
|
||||||
if (character.length > 11 && Misc.isInt(character[11]))
|
if (character.length > 11 && StringUtils.isInt(character[11]))
|
||||||
skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
|
skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
|
||||||
if (character.length > 12 && Misc.isInt(character[12]))
|
if (character.length > 12 && StringUtils.isInt(character[12]))
|
||||||
skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
|
skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
|
||||||
if (character.length > 13 && Misc.isInt(character[13]))
|
if (character.length > 13 && StringUtils.isInt(character[13]))
|
||||||
skills.put(SkillType.AXES, Integer.valueOf(character[13]));
|
skills.put(SkillType.AXES, Integer.valueOf(character[13]));
|
||||||
if (character.length > 14 && Misc.isInt(character[14]))
|
if (character.length > 14 && StringUtils.isInt(character[14]))
|
||||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
|
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
|
||||||
if (character.length > 15 && Misc.isInt(character[15]))
|
if (character.length > 15 && StringUtils.isInt(character[15]))
|
||||||
skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15]));
|
skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15]));
|
||||||
if (character.length > 16 && Misc.isInt(character[16]))
|
if (character.length > 16 && StringUtils.isInt(character[16]))
|
||||||
skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16]));
|
skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16]));
|
||||||
if (character.length > 17 && Misc.isInt(character[17]))
|
if (character.length > 17 && StringUtils.isInt(character[17]))
|
||||||
skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17]));
|
skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17]));
|
||||||
if (character.length > 18 && Misc.isInt(character[18]))
|
if (character.length > 18 && StringUtils.isInt(character[18]))
|
||||||
skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18]));
|
skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18]));
|
||||||
if (character.length > 19 && Misc.isInt(character[19]))
|
if (character.length > 19 && StringUtils.isInt(character[19]))
|
||||||
skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19]));
|
skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19]));
|
||||||
if (character.length > 20 && Misc.isInt(character[20]))
|
if (character.length > 20 && StringUtils.isInt(character[20]))
|
||||||
skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20]));
|
skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20]));
|
||||||
if (character.length > 21 && Misc.isInt(character[21]))
|
if (character.length > 21 && StringUtils.isInt(character[21]))
|
||||||
skillsXp.put(SkillType.AXES, Integer.valueOf(character[21]));
|
skillsXp.put(SkillType.AXES, Integer.valueOf(character[21]));
|
||||||
if (character.length > 22 && Misc.isInt(character[22]))
|
if (character.length > 22 && StringUtils.isInt(character[22]))
|
||||||
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22]));
|
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22]));
|
||||||
if (character.length > 24 && Misc.isInt(character[24]))
|
if (character.length > 24 && StringUtils.isInt(character[24]))
|
||||||
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
|
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
|
||||||
if (character.length > 25 && Misc.isInt(character[25]))
|
if (character.length > 25 && StringUtils.isInt(character[25]))
|
||||||
skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25]));
|
skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25]));
|
||||||
if (character.length > 26)
|
if (character.length > 26)
|
||||||
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26]));
|
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26]));
|
||||||
@ -384,18 +385,18 @@ public class PlayerProfile {
|
|||||||
writer.append(skillsXp.get(SkillType.TAMING)).append(":");
|
writer.append(skillsXp.get(SkillType.TAMING)).append(":");
|
||||||
// Need to store the DATS of abilities nao
|
// Need to store the DATS of abilities nao
|
||||||
// Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker
|
// Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker
|
||||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.BERSERK))).append(":");
|
writer.append(skillsDATS.get(AbilityType.BERSERK)).append(":");
|
||||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER))).append(":");
|
writer.append(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)).append(":");
|
||||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.TREE_FELLER))).append(":");
|
writer.append(skillsDATS.get(AbilityType.TREE_FELLER)).append(":");
|
||||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.GREEN_TERRA))).append(":");
|
writer.append(skillsDATS.get(AbilityType.GREEN_TERRA)).append(":");
|
||||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SERRATED_STRIKES))).append(":");
|
writer.append(skillsDATS.get(AbilityType.SERRATED_STRIKES)).append(":");
|
||||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER))).append(":");
|
writer.append(skillsDATS.get(AbilityType.SKULL_SPLIITER)).append(":");
|
||||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER))).append(":");
|
writer.append(skillsDATS.get(AbilityType.SUPER_BREAKER)).append(":");
|
||||||
writer.append(hudType.toString()).append(":");
|
writer.append(hudType.toString()).append(":");
|
||||||
writer.append(skills.get(SkillType.FISHING)).append(":");
|
writer.append(skills.get(SkillType.FISHING)).append(":");
|
||||||
writer.append(skillsXp.get(SkillType.FISHING)).append(":");
|
writer.append(skillsXp.get(SkillType.FISHING)).append(":");
|
||||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.BLAST_MINING))).append(":");
|
writer.append(skillsDATS.get(AbilityType.BLAST_MINING)).append(":");
|
||||||
writer.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":");
|
writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":");
|
||||||
writer.append("\r\n");
|
writer.append("\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ import com.gmail.nossr50.util.ItemChecks;
|
|||||||
import com.gmail.nossr50.util.Motd;
|
import com.gmail.nossr50.util.Motd;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
@ -373,7 +374,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.values()) {
|
||||||
String skillName = skill.toString().toLowerCase();
|
String skillName = skill.toString().toLowerCase();
|
||||||
String localizedName = LocaleLoader.getString(Misc.getCapitalized(skillName) + ".SkillName").toLowerCase();
|
String localizedName = LocaleLoader.getString(StringUtils.getCapitalized(skillName) + ".SkillName").toLowerCase();
|
||||||
|
|
||||||
if (lowerCaseCommand.equals(localizedName)) {
|
if (lowerCaseCommand.equals(localizedName)) {
|
||||||
event.setMessage(message.replace(command, skillName));
|
event.setMessage(message.replace(command, skillName));
|
||||||
|
@ -10,8 +10,8 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class PartyExpShareCommand implements CommandExecutor {
|
public class PartyExpShareCommand implements CommandExecutor {
|
||||||
@ -55,7 +55,7 @@ public class PartyExpShareCommand implements CommandExecutor {
|
|||||||
playerParty.setXpShareMode(mode);
|
playerParty.setXpShareMode(mode);
|
||||||
|
|
||||||
for (Player member : playerParty.getOnlineMembers()) {
|
for (Player member : playerParty.getOnlineMembers()) {
|
||||||
member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + Misc.getCapitalized(mode.toString()))));
|
member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class PartyItemShareCommand implements CommandExecutor {
|
public class PartyItemShareCommand implements CommandExecutor {
|
||||||
@ -60,7 +60,7 @@ public class PartyItemShareCommand implements CommandExecutor {
|
|||||||
playerParty.setItemShareMode(mode);
|
playerParty.setItemShareMode(mode);
|
||||||
|
|
||||||
for (Player member : playerParty.getOnlineMembers()) {
|
for (Player member : playerParty.getOnlineMembers()) {
|
||||||
member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + Misc.getCapitalized(mode.toString()))));
|
member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,6 +14,7 @@ import com.gmail.nossr50.skills.utilities.SkillTools;
|
|||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public abstract class SkillCommand implements CommandExecutor {
|
public abstract class SkillCommand implements CommandExecutor {
|
||||||
@ -31,7 +32,7 @@ public abstract class SkillCommand implements CommandExecutor {
|
|||||||
|
|
||||||
public SkillCommand(SkillType skill) {
|
public SkillCommand(SkillType skill) {
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
this.skillString = Misc.getCapitalized(skill.toString());
|
this.skillString = StringUtils.getCapitalized(skill.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public final class SkillGuide {
|
public final class SkillGuide {
|
||||||
private SkillGuide() {}
|
private SkillGuide() {}
|
||||||
@ -55,7 +55,7 @@ public final class SkillGuide {
|
|||||||
|
|
||||||
public static boolean grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) {
|
public static boolean grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) {
|
||||||
String skillName = skilltype.toString();
|
String skillName = skilltype.toString();
|
||||||
String capitalized = Misc.getCapitalized(skillName);
|
String capitalized = StringUtils.getCapitalized(skillName);
|
||||||
String localized = SkillTools.localizeSkillName(skilltype);
|
String localized = SkillTools.localizeSkillName(skilltype);
|
||||||
player.sendMessage(LocaleLoader.getString("Guides.Available", localized, localized.toLowerCase()));
|
player.sendMessage(LocaleLoader.getString("Guides.Available", localized, localized.toLowerCase()));
|
||||||
|
|
||||||
@ -82,19 +82,19 @@ public final class SkillGuide {
|
|||||||
case 2:
|
case 2:
|
||||||
int totalPages = SkillGuide.getTotalPageNumber(address);
|
int totalPages = SkillGuide.getTotalPageNumber(address);
|
||||||
|
|
||||||
if (!Misc.isInt(args[1])) {
|
if (!StringUtils.isInt(args[1])) {
|
||||||
player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid"));
|
player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Misc.getInt(args[1]) > totalPages) {
|
if (Integer.parseInt(args[1]) > totalPages) {
|
||||||
player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages));
|
player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkillGuide.clearChat(player);
|
SkillGuide.clearChat(player);
|
||||||
|
|
||||||
for (String target : SkillGuide.grabPageContents(localized, address, Misc.getInt(args[1]))) {
|
for (String target : SkillGuide.grabPageContents(localized, address, Integer.parseInt(args[1]))) {
|
||||||
player.sendMessage(target);
|
player.sendMessage(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.mining;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillCommand;
|
import com.gmail.nossr50.skills.SkillCommand;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class MiningCommand extends SkillCommand {
|
public class MiningCommand extends SkillCommand {
|
||||||
@ -156,7 +155,7 @@ public class MiningCommand extends SkillCommand {
|
|||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", BlastMining.rank1)));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", BlastMining.rank1)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (Misc.getInt(blastMiningRank) - 1))));
|
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (Integer.parseInt(blastMiningRank) - 1))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ import com.gmail.nossr50.datatypes.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent;
|
import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class SimpleRepairManager implements RepairManager {
|
public class SimpleRepairManager implements RepairManager {
|
||||||
private HashMap<Integer, Repairable> repairables;
|
private HashMap<Integer, Repairable> repairables;
|
||||||
@ -76,7 +76,7 @@ public class SimpleRepairManager implements RepairManager {
|
|||||||
|
|
||||||
// Level check
|
// Level check
|
||||||
if (skillLevel < repairable.getMinimumLevel()) {
|
if (skillLevel < repairable.getMinimumLevel()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", String.valueOf(repairable.getMinimumLevel()), Misc.prettyItemString(item.getTypeId())));
|
player.sendMessage(LocaleLoader.getString("Repair.Skills.Adept", String.valueOf(repairable.getMinimumLevel()), StringUtils.getPrettyItemString(item.getTypeId())));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ public class SimpleRepairManager implements RepairManager {
|
|||||||
|
|
||||||
// Check if they have the proper material to repair with
|
// Check if they have the proper material to repair with
|
||||||
if (!inventory.contains(repairable.getRepairMaterialId())) {
|
if (!inventory.contains(repairable.getRepairMaterialId())) {
|
||||||
String message = LocaleLoader.getString("Skills.NeedMore", Misc.prettyItemString(repairable.getRepairMaterialId()));
|
String message = LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(repairable.getRepairMaterialId()));
|
||||||
if (repairable.getRepairMaterialMetadata() != (byte) -1) {
|
if (repairable.getRepairMaterialMetadata() != (byte) -1) {
|
||||||
// TODO: Do something nicer than append the metadata as a :# ?
|
// TODO: Do something nicer than append the metadata as a :# ?
|
||||||
if (findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata()) == -1) {
|
if (findInInventory(inventory, repairable.getRepairMaterialId(), repairable.getRepairMaterialMetadata()) == -1) {
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class CallOfTheWildEventHandler {
|
public class CallOfTheWildEventHandler {
|
||||||
protected Player player;
|
protected Player player;
|
||||||
@ -30,7 +31,7 @@ public class CallOfTheWildEventHandler {
|
|||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", Misc.prettyItemString(inHand.getTypeId())));
|
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(inHand.getTypeId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean nearbyEntityExists() {
|
protected boolean nearbyEntityExists() {
|
||||||
|
@ -19,6 +19,7 @@ import com.gmail.nossr50.spout.SpoutConfig;
|
|||||||
import com.gmail.nossr50.spout.SpoutTools;
|
import com.gmail.nossr50.spout.SpoutTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class SkillTools {
|
public class SkillTools {
|
||||||
@ -235,7 +236,7 @@ public class SkillTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String capitalized = Misc.getCapitalized(skillType.toString());
|
String capitalized = StringUtils.getCapitalized(skillType.toString());
|
||||||
|
|
||||||
/* Spout Stuff */
|
/* Spout Stuff */
|
||||||
if (mcMMO.spoutEnabled) {
|
if (mcMMO.spoutEnabled) {
|
||||||
@ -285,7 +286,7 @@ public class SkillTools {
|
|||||||
|
|
||||||
public static boolean isLocalizedSkill(String skillName) {
|
public static boolean isLocalizedSkill(String skillName) {
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.values()) {
|
||||||
if (skillName.equalsIgnoreCase(LocaleLoader.getString(Misc.getCapitalized(skill.toString() + ".SkillName")))) {
|
if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString() + ".SkillName")))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,7 +296,7 @@ public class SkillTools {
|
|||||||
|
|
||||||
public static String translateLocalizedSkill(String skillName) {
|
public static String translateLocalizedSkill(String skillName) {
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.values()) {
|
||||||
if (skillName.equalsIgnoreCase(LocaleLoader.getString(Misc.getCapitalized(skill.toString() + ".SkillName")))) {
|
if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString() + ".SkillName")))) {
|
||||||
return skill.toString();
|
return skill.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -304,7 +305,7 @@ public class SkillTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String localizeSkillName(SkillType skill) {
|
public static String localizeSkillName(SkillType skill) {
|
||||||
return Misc.getCapitalized(LocaleLoader.getString(Misc.getCapitalized(skill.toString()) + ".SkillName"));
|
return StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".SkillName"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class SpoutTools {
|
public class SpoutTools {
|
||||||
@ -147,8 +147,8 @@ public class SpoutTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String skillTypeString = skillType.toString();
|
String skillTypeString = skillType.toString();
|
||||||
String standardFileName = Misc.getCapitalized(skillTypeString)+".png";
|
String standardFileName = StringUtils.getCapitalized(skillTypeString)+".png";
|
||||||
String retroFileName = Misc.getCapitalized(skillTypeString)+"_r.png";
|
String retroFileName = StringUtils.getCapitalized(skillTypeString)+"_r.png";
|
||||||
|
|
||||||
writeFile(standardFileName, hudStandardDirectory);
|
writeFile(standardFileName, hudStandardDirectory);
|
||||||
writeFile(retroFileName, hudRetroDirectory);
|
writeFile(retroFileName, hudRetroDirectory);
|
||||||
@ -210,8 +210,8 @@ public class SpoutTools {
|
|||||||
|
|
||||||
String skillTypeString = skillType.toString();
|
String skillTypeString = skillType.toString();
|
||||||
|
|
||||||
files.add(new File(hudStandardDirectory + Misc.getCapitalized(skillTypeString) + ".png"));
|
files.add(new File(hudStandardDirectory + StringUtils.getCapitalized(skillTypeString) + ".png"));
|
||||||
files.add(new File(hudRetroDirectory + Misc.getCapitalized(skillTypeString) + "_r.png"));
|
files.add(new File(hudRetroDirectory + StringUtils.getCapitalized(skillTypeString) + "_r.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blank icons
|
// Blank icons
|
||||||
|
@ -6,8 +6,8 @@ import org.bukkit.command.CommandSender;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class XplockCommand extends SpoutCommand {
|
public class XplockCommand extends SpoutCommand {
|
||||||
@Override
|
@Override
|
||||||
@ -52,7 +52,7 @@ public class XplockCommand extends SpoutCommand {
|
|||||||
spoutHud.setXpBarLocked(true);
|
spoutHud.setXpBarLocked(true);
|
||||||
spoutHud.setSkillLock(skill);
|
spoutHud.setSkillLock(skill);
|
||||||
spoutHud.updateXpBar();
|
spoutHud.updateXpBar();
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", Misc.getCapitalized(skill.toString())));
|
sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", StringUtils.getCapitalized(skill.toString())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
|||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.spout.SpoutConfig;
|
import com.gmail.nossr50.spout.SpoutConfig;
|
||||||
import com.gmail.nossr50.spout.huds.HudType;
|
import com.gmail.nossr50.spout.huds.HudType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
|
||||||
public class XpBar {
|
public class XpBar {
|
||||||
private SpoutPlayer spoutPlayer;
|
private SpoutPlayer spoutPlayer;
|
||||||
@ -204,7 +204,7 @@ public class XpBar {
|
|||||||
* @param playerProfile The profile of the player whose XP bar should be updated
|
* @param playerProfile The profile of the player whose XP bar should be updated
|
||||||
*/
|
*/
|
||||||
private void updateXpBarStandard(SkillType skillType, PlayerProfile playerProfile) {
|
private void updateXpBarStandard(SkillType skillType, PlayerProfile playerProfile) {
|
||||||
xpIcon.setUrl(Misc.getCapitalized(skillType.toString()) + ".png");
|
xpIcon.setUrl(StringUtils.getCapitalized(skillType.toString()) + ".png");
|
||||||
|
|
||||||
((GenericTexture) xpBar).setUrl(getUrlBar(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.STANDARD)));
|
((GenericTexture) xpBar).setUrl(getUrlBar(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.STANDARD)));
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ public class XpBar {
|
|||||||
private void updateXpBarRetro(SkillType skillType, PlayerProfile playerProfile) {
|
private void updateXpBarRetro(SkillType skillType, PlayerProfile playerProfile) {
|
||||||
Color color = getRetroColor(skillType);
|
Color color = getRetroColor(skillType);
|
||||||
|
|
||||||
xpIcon.setUrl(Misc.getCapitalized(skillType.toString()) + "_r.png");
|
xpIcon.setUrl(StringUtils.getCapitalized(skillType.toString()) + "_r.png");
|
||||||
|
|
||||||
xpFill.setBottomColor(color);
|
xpFill.setBottomColor(color);
|
||||||
xpFill.setTopColor(color);
|
xpFill.setTopColor(color);
|
||||||
|
@ -100,87 +100,6 @@ public final class Misc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a capitalized version of the target string.
|
|
||||||
*
|
|
||||||
* @param target String to capitalize
|
|
||||||
* @return the capitalized string
|
|
||||||
*/
|
|
||||||
public static String getCapitalized(String target) {
|
|
||||||
String firstLetter = target.substring(0,1);
|
|
||||||
String remainder = target.substring(1);
|
|
||||||
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
|
|
||||||
|
|
||||||
return capitalized;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a nicely formatted string version of an item name from a given item ID.
|
|
||||||
*
|
|
||||||
* @param itemID The ID of the item to convert to string.
|
|
||||||
* @return the nicely formatting string
|
|
||||||
*/
|
|
||||||
public static String prettyItemString(int itemID) {
|
|
||||||
String baseString = Material.getMaterial(itemID).toString();
|
|
||||||
String[] substrings = baseString.split("_");
|
|
||||||
String prettyString = "";
|
|
||||||
int size = 1;
|
|
||||||
|
|
||||||
for (String s : substrings) {
|
|
||||||
prettyString = prettyString.concat(Misc.getCapitalized(s));
|
|
||||||
|
|
||||||
if (size < substrings.length) {
|
|
||||||
prettyString = prettyString.concat(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
size++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return prettyString;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the int represented by this string.
|
|
||||||
*
|
|
||||||
* @param string The string to parse
|
|
||||||
* @return the int represented by this string
|
|
||||||
*/
|
|
||||||
public static int getInt(String string) {
|
|
||||||
if (isInt(string)) {
|
|
||||||
return Integer.parseInt(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the long represented by this string.
|
|
||||||
*
|
|
||||||
* @param string The string to parse
|
|
||||||
* @return the long represented by this string
|
|
||||||
*/
|
|
||||||
public static long getLong(String string) {
|
|
||||||
if (isLong(string)) {
|
|
||||||
return Long.parseLong(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the long represented by this string.
|
|
||||||
*
|
|
||||||
* @param string The string to parse
|
|
||||||
* @return the long represented by this string
|
|
||||||
*/
|
|
||||||
public static double getDouble(String string) {
|
|
||||||
if (isDouble(string)) {
|
|
||||||
return Double.parseDouble(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if an entity is currently invincible.
|
* Checks to see if an entity is currently invincible.
|
||||||
*
|
*
|
||||||
@ -283,54 +202,6 @@ public final class Misc {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if a string represents an Integer
|
|
||||||
*
|
|
||||||
* @param string String to check
|
|
||||||
* @return true if the string is an Integer, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean isInt(String string) {
|
|
||||||
try {
|
|
||||||
Integer.parseInt(string);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (NumberFormatException nFE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if a string represents a Long
|
|
||||||
*
|
|
||||||
* @param string String to check
|
|
||||||
* @return true if the string is a Long, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean isLong(String string) {
|
|
||||||
try {
|
|
||||||
Long.parseLong(string);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (NumberFormatException nFE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if a string represents a Double
|
|
||||||
*
|
|
||||||
* @param string String to check
|
|
||||||
* @return true if the string is a Double, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean isDouble(String string) {
|
|
||||||
try {
|
|
||||||
Double.parseDouble(string);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (NumberFormatException nFE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drop items at a given location.
|
* Drop items at a given location.
|
||||||
*
|
*
|
||||||
|
124
src/main/java/com/gmail/nossr50/util/StringUtils.java
Normal file
124
src/main/java/com/gmail/nossr50/util/StringUtils.java
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
public class StringUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a capitalized version of the target string.
|
||||||
|
*
|
||||||
|
* @param target String to capitalize
|
||||||
|
* @return the capitalized string
|
||||||
|
*/
|
||||||
|
public static String getCapitalized(String target) {
|
||||||
|
String firstLetter = target.substring(0,1);
|
||||||
|
String remainder = target.substring(1);
|
||||||
|
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
|
||||||
|
|
||||||
|
return capitalized;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a nicely formatted string version of an item name from a given item ID.
|
||||||
|
*
|
||||||
|
* @param itemID The ID of the item to convert to string.
|
||||||
|
* @return the nicely formatting string
|
||||||
|
*/
|
||||||
|
public static String getPrettyItemString(int itemID) {
|
||||||
|
String baseString = Material.getMaterial(itemID).toString();
|
||||||
|
String[] substrings = baseString.split("_");
|
||||||
|
String prettyString = "";
|
||||||
|
int size = 1;
|
||||||
|
|
||||||
|
for (String s : substrings) {
|
||||||
|
prettyString = prettyString.concat(getCapitalized(s));
|
||||||
|
|
||||||
|
if (size < substrings.length) {
|
||||||
|
prettyString = prettyString.concat(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
size++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return prettyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the int represented by this string.
|
||||||
|
*
|
||||||
|
* @param string The string to parse
|
||||||
|
* @return the int represented by this string
|
||||||
|
*/
|
||||||
|
public static int getInt(String string) {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(string);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nFE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the long represented by this string.
|
||||||
|
*
|
||||||
|
* @param string The string to parse
|
||||||
|
* @return the long represented by this string
|
||||||
|
*/
|
||||||
|
public static long getLong(String string) {
|
||||||
|
try {
|
||||||
|
return Long.parseLong(string);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nFE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a string represents an Integer
|
||||||
|
*
|
||||||
|
* @param string String to check
|
||||||
|
* @return true if the string is an Integer, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean isInt(String string) {
|
||||||
|
try {
|
||||||
|
Integer.parseInt(string);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nFE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a string represents a Long
|
||||||
|
*
|
||||||
|
* @param string String to check
|
||||||
|
* @return true if the string is a Long, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean isLong(String string) {
|
||||||
|
try {
|
||||||
|
Long.parseLong(string);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nFE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a string represents a Double
|
||||||
|
*
|
||||||
|
* @param string String to check
|
||||||
|
* @return true if the string is a Double, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean isDouble(String string) {
|
||||||
|
try {
|
||||||
|
Double.parseDouble(string);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nFE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user