diff --git a/.classpath b/.classpath index 24cf603..06906ad 100644 --- a/.classpath +++ b/.classpath @@ -4,7 +4,7 @@ - + diff --git a/src/lishid/openinv/commands/OpenInvPluginCommand.java b/src/lishid/openinv/commands/OpenInvPluginCommand.java index ac787dc..0c7abed 100644 --- a/src/lishid/openinv/commands/OpenInvPluginCommand.java +++ b/src/lishid/openinv/commands/OpenInvPluginCommand.java @@ -1,5 +1,6 @@ package lishid.openinv.commands; +import java.io.File; import java.util.HashMap; import lishid.openinv.PermissionRelay; @@ -10,6 +11,7 @@ import net.minecraft.server.EntityPlayer; import net.minecraft.server.ItemInWorldManager; import net.minecraft.server.MinecraftServer; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -79,25 +81,39 @@ public class OpenInvPluginCommand implements CommandExecutor { //Offline inv here... try{ //See if the player has data files - if(!this.plugin.getServer().getOfflinePlayer(name).hasPlayedBefore()) + + // Find the player folder + File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players"); + + // Find player name + for (File playerfile : playerfolder.listFiles()) + { + String filename = playerfile.getName(); + String playername = filename.substring(0, filename.length() - 4); + + if(playername.trim().equalsIgnoreCase(name)) + { + //Create an entity to load the player data + MinecraftServer server = ((CraftServer)this.plugin.getServer()).getServer(); + EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new ItemInWorldManager(server.getWorldServer(0))); + target = (entity == null) ? null : (Player) entity.getBukkitEntity(); + if(target != null) + { + Offline = true; + target.loadData(); + } + else + { + sender.sendMessage(ChatColor.RED + "Player not found!"); + return true; + } + } + } + if(!Offline) { sender.sendMessage(ChatColor.RED + "Player not found!"); return true; } - //Create an entity to load the player data - MinecraftServer server = ((CraftServer)this.plugin.getServer()).getServer(); - EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), name, new ItemInWorldManager(server.getWorldServer(0))); - target = (entity == null) ? null : (Player) entity.getBukkitEntity(); - if(target != null) - { - Offline = true; - target.loadData(); - } - else - { - sender.sendMessage(ChatColor.RED + "Player not found!"); - return false; - } } catch(Exception e) { diff --git a/src/lishid/openinv/utils/Metrics.java b/src/lishid/openinv/utils/Metrics.java index de16832..800bb37 100644 --- a/src/lishid/openinv/utils/Metrics.java +++ b/src/lishid/openinv/utils/Metrics.java @@ -1,5 +1,4 @@ package lishid.openinv.utils; - /* * Copyright 2011 Tyler Blair. All rights reserved. * @@ -72,6 +71,12 @@ public class Metrics { */ public abstract int getValue(); + /** + * Called after the website graphs have been updated + */ + public void reset() { + } + @Override public int hashCode() { return getColumnName().hashCode() + getValue(); @@ -92,7 +97,7 @@ public class Metrics { /** * The metrics revision number */ - private final static int REVISION = 3; + private final static int REVISION = 4; /** * The base url of the metrics domain @@ -242,6 +247,15 @@ public class Metrics { if (response.startsWith("ERR")){ throw new IOException(response); //Throw the exception + } else { + // Is this the first update this hour? + if (response.contains("OK This is your first update this hour")) { + if (plotters != null) { + for (Plotter plotter : plotters) { + plotter.reset(); + } + } + } } //if (response.startsWith("OK")) - We should get "OK" followed by an optional description if everything goes right } diff --git a/src/plugin.yml b/src/plugin.yml index 195b742..f9334fc 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: OpenInv main: lishid.openinv.OpenInv -version: 1.7.3 +version: 1.7.4 author: lishid website: http://forums.bukkit.org/threads/15379/ description: >