mmoedit now works on offline players

This commit is contained in:
nossr50 2012-03-06 13:46:04 -08:00
parent d401a69560
commit b6a1188bc7
2 changed files with 46 additions and 18 deletions

View File

@ -10,6 +10,7 @@ Key:
Version 2.0.00-dev Version 2.0.00-dev
+ Added Ocelots to Taming XP tables + Added Ocelots to Taming XP tables
+ Added ability to summon Ocelots with Call of the Wild + Added ability to summon Ocelots with Call of the Wild
+ Added offline user functionality to mmoedit
= Fixed ClassCastException from Taming preventDamage checks = Fixed ClassCastException from Taming preventDamage checks
= Fixed issue with Blast Mining not seeing TNT for detonation due to snow = Fixed issue with Blast Mining not seeing TNT for detonation due to snow
! Changed Call of the Wild to activate on left-click rather than right-click ! Changed Call of the Wild to activate on left-click rather than right-click

View File

@ -24,7 +24,8 @@ public class MmoeditCommand implements CommandExecutor {
@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; Player player = null;
if (sender instanceof Player) { if (sender instanceof Player)
{
player = (Player) sender; player = (Player) sender;
} }
@ -33,46 +34,72 @@ public class MmoeditCommand implements CommandExecutor {
return true; return true;
} }
if (!(sender instanceof Player)) { PlayerProfile PPt = Users.getOfflineProfile(args[0]);
if (args.length < 2) {
if (!(sender instanceof Player))
{
if (args.length < 2)
{
System.out.println("Usage is /mmoedit playername skillname newvalue"); System.out.println("Usage is /mmoedit playername skillname newvalue");
return true; return true;
} else if (args.length == 3) { } else if (args.length == 3)
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) { {
if(!PPt.isLoaded())
{
sender.sendMessage("Player does not exist in the database!");
return true;
}
if (m.isInt(args[2]) && Skills.isSkill(args[1]))
{
int newvalue = Integer.valueOf(args[2]); int newvalue = Integer.valueOf(args[2]);
Users.getProfile(plugin.getServer().getPlayer(args[0])).modifyskill(Skills.getSkillType(args[1]), newvalue); Users.getOfflineProfile(args[0]).modifyskill(Skills.getSkillType(args[1]), newvalue);
System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + "."); System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + ".");
} }
} else { } else
{
System.out.println("Usage is /mmoedit playername skillname newvalue"); System.out.println("Usage is /mmoedit playername skillname newvalue");
} }
return true; return true;
} }
PlayerProfile PP = Users.getProfile(player); if (!mcPermissions.getInstance().mmoedit(player))
{
if (!mcPermissions.getInstance().mmoedit(player)) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true; return true;
} }
if (args.length < 2) {
if (args.length < 2)
{
player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue"); player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue");
return true; return true;
} }
if (args.length == 3) { if (args.length == 3)
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) { {
if(!PPt.isLoaded())
{
sender.sendMessage("Player does not exist in the database!");
return true;
}
if (m.isInt(args[2]) && Skills.isSkill(args[1]))
{
int newvalue = Integer.valueOf(args[2]); int newvalue = Integer.valueOf(args[2]);
Users.getProfile(plugin.getServer().getPlayer(args[0])).modifyskill(Skills.getSkillType(args[1]), newvalue); Users.getOfflineProfile(args[0]).modifyskill(Skills.getSkillType(args[1]), newvalue);
player.sendMessage(ChatColor.RED + args[1] + " has been modified."); player.sendMessage(ChatColor.RED + args[1] + " has been modified for "+args[0]);
} }
} else if (args.length == 2) { } else if (args.length == 2)
if (m.isInt(args[1]) && Skills.isSkill(args[0])) { {
if (m.isInt(args[1]) && Skills.isSkill(args[0]))
{
PlayerProfile PP = Users.getProfile(player);
int newvalue = Integer.valueOf(args[1]); int newvalue = Integer.valueOf(args[1]);
PP.modifyskill(Skills.getSkillType(args[0]), newvalue); PP.modifyskill(Skills.getSkillType(args[0]), newvalue);
player.sendMessage(ChatColor.RED + args[0] + " has been modified."); player.sendMessage(ChatColor.RED + args[0] + " has been modified.");
} }
} else { } else
{
player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue"); player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue");
} }