mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Making Inspect work on offline players
This commit is contained in:
parent
e0fa23359f
commit
88e40080fb
@ -56,6 +56,7 @@ Version 1.3.00-dev
|
||||
! Changed to use Bukkit's built-in ignoreCancelledEvents system
|
||||
! Changed chat logging for /p & /a
|
||||
! Changed Tree Feller to use per-use ArrayList
|
||||
- Removed /mcstats console functionality
|
||||
- Removed /whois command (replaced with /inspect which has similar functionality)
|
||||
- Removed Master/Apprentice chat notifications to reduce spam
|
||||
- Removed MySpawn system (You can still use Chimaera Wings) due to being outdated and unwanted
|
||||
|
@ -71,7 +71,7 @@ public class Users {
|
||||
public static void addUser(Player player)
|
||||
{
|
||||
if(!players.containsKey(player))
|
||||
players.put(player, new PlayerProfile(player));
|
||||
players.put(player, new PlayerProfile(player.getName()));
|
||||
}
|
||||
public static void clearUsers()
|
||||
{
|
||||
@ -111,11 +111,15 @@ public class Users {
|
||||
return players.get(player);
|
||||
else
|
||||
{
|
||||
players.put(player, new PlayerProfile(player));
|
||||
players.put(player, new PlayerProfile(player.getName()));
|
||||
return players.get(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static PlayerProfile getOfflineProfile(String playerName){
|
||||
return new PlayerProfile(playerName);
|
||||
}
|
||||
|
||||
public static Users getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Users();
|
||||
|
@ -40,7 +40,7 @@ public class InspectCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if split[1] is a player
|
||||
// if split[1] is an online player
|
||||
if (plugin.getServer().getPlayer(args[0]) != null)
|
||||
{
|
||||
Player target = plugin.getServer().getPlayer(args[0]);
|
||||
@ -86,7 +86,32 @@ public class InspectCommand implements CommandExecutor {
|
||||
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (m.getPowerLevel(target)));
|
||||
} else {
|
||||
sender.sendMessage("That is not a valid player!");
|
||||
if(sender instanceof Player && !player.isOp())
|
||||
{
|
||||
sender.sendMessage("That player is offline, inspecting offline players is limited to Ops!");
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile PPt = Users.getOfflineProfile(args[0]);
|
||||
sender.sendMessage(ChatColor.GREEN + "mcMMO Stats for Offline Player " + ChatColor.YELLOW + args[0]);
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "-=GATHERING SKILLS=-");
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ExcavationSkill"), PPt.getSkillLevel(SkillType.EXCAVATION), PPt.getSkillXpLevel(SkillType.EXCAVATION), PPt.getXpToLevel(SkillType.EXCAVATION)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.FishingSkill"), PPt.getSkillLevel(SkillType.FISHING), PPt.getSkillXpLevel(SkillType.FISHING), PPt.getXpToLevel(SkillType.FISHING)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.HerbalismSkill"), PPt.getSkillLevel(SkillType.HERBALISM), PPt.getSkillXpLevel(SkillType.HERBALISM), PPt.getXpToLevel(SkillType.HERBALISM)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.MiningSkill"), PPt.getSkillLevel(SkillType.MINING), PPt.getSkillXpLevel(SkillType.MINING), PPt.getXpToLevel(SkillType.MINING)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PPt.getSkillLevel(SkillType.WOODCUTTING), PPt.getSkillXpLevel(SkillType.WOODCUTTING), PPt.getXpToLevel(SkillType.WOODCUTTING)));
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "-=COMBAT SKILLS=-");
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AxesSkill"), PPt.getSkillLevel(SkillType.AXES), PPt.getSkillXpLevel(SkillType.AXES), PPt.getXpToLevel(SkillType.AXES)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ArcherySkill"), PPt.getSkillLevel(SkillType.ARCHERY), PPt.getSkillXpLevel(SkillType.ARCHERY), PPt.getXpToLevel(SkillType.ARCHERY)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.SwordsSkill"), PPt.getSkillLevel(SkillType.SWORDS), PPt.getSkillXpLevel(SkillType.SWORDS), PPt.getXpToLevel(SkillType.SWORDS)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.TamingSkill"), PPt.getSkillLevel(SkillType.TAMING), PPt.getSkillXpLevel(SkillType.TAMING), PPt.getXpToLevel(SkillType.TAMING)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.UnarmedSkill"), PPt.getSkillLevel(SkillType.UNARMED), PPt.getSkillXpLevel(SkillType.UNARMED), PPt.getXpToLevel(SkillType.UNARMED)));
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "-=MISC SKILLS=-");
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PPt.getSkillLevel(SkillType.ACROBATICS), PPt.getSkillXpLevel(SkillType.ACROBATICS), PPt.getXpToLevel(SkillType.ACROBATICS)));
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.RepairSkill"), PPt.getSkillLevel(SkillType.REPAIR), PPt.getSkillXpLevel(SkillType.REPAIR), PPt.getXpToLevel(SkillType.REPAIR)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
@ -16,11 +15,6 @@ import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
public class McstatsCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public McstatsCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
@ -69,7 +69,7 @@ public class PlayerProfile
|
||||
|
||||
String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
|
||||
|
||||
public PlayerProfile(Player player)
|
||||
public PlayerProfile(String name)
|
||||
{
|
||||
hud = LoadProperties.defaulthud;
|
||||
//Setup the HashMap for ability DATS
|
||||
@ -88,12 +88,12 @@ public class PlayerProfile
|
||||
}
|
||||
}
|
||||
|
||||
playerName = player.getName();
|
||||
playerName = name;
|
||||
if (LoadProperties.useMySQL)
|
||||
{
|
||||
if(!loadMySQL(player)) {
|
||||
addMySQLPlayer(player);
|
||||
loadMySQL(player);//This is probably not needed anymore, could just delete
|
||||
if(!loadMySQL()) {
|
||||
addMySQLPlayer();
|
||||
loadMySQL();//This is probably not needed anymore, could just delete
|
||||
}
|
||||
} else {
|
||||
if(!load()) { addPlayer(); }
|
||||
@ -109,10 +109,10 @@ public class PlayerProfile
|
||||
return userid;
|
||||
}
|
||||
|
||||
public boolean loadMySQL(Player p)
|
||||
public boolean loadMySQL()
|
||||
{
|
||||
Integer id = 0;
|
||||
id = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + p.getName() + "'");
|
||||
id = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
|
||||
if(id == 0)
|
||||
return false;
|
||||
this.userid = id;
|
||||
@ -189,10 +189,10 @@ public class PlayerProfile
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public void addMySQLPlayer(Player p) {
|
||||
public void addMySQLPlayer() {
|
||||
Integer id = 0;
|
||||
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"users (user, lastlogin) VALUES ('" + p.getName() + "'," + System.currentTimeMillis() / 1000 +")");
|
||||
id = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + p.getName() + "'");
|
||||
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
|
||||
id = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
|
||||
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"cooldowns (user_id) VALUES ("+id+")");
|
||||
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"skills (user_id) VALUES ("+id+")");
|
||||
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"experience (user_id) VALUES ("+id+")");
|
||||
|
@ -324,7 +324,7 @@ public class mcMMO extends JavaPlugin
|
||||
if(LoadProperties.addlevelsEnable) getCommand("addlevels").setExecutor(new AddlevelsCommand(this));
|
||||
if(LoadProperties.mmoeditEnable) getCommand("mmoedit").setExecutor(new MmoeditCommand(this));
|
||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
||||
if(LoadProperties.mcstatsEnable) getCommand("mcstats").setExecutor(new McstatsCommand(this));
|
||||
if(LoadProperties.mcstatsEnable) getCommand("mcstats").setExecutor(new McstatsCommand());
|
||||
if(LoadProperties.inspectEnable) getCommand("inspect").setExecutor(new InspectCommand(this));
|
||||
if(LoadProperties.xprateEnable) getCommand("xprate").setExecutor(new XprateCommand());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user