diff options
author | snowleo <schneeleo@gmail.com> | 2013-05-03 00:12:40 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2013-05-03 00:12:40 +0200 |
commit | 0f4982f4787defa9afb070d2256035963c884784 (patch) | |
tree | cb8b842adff3b040838d2e8f049b6a1c4552137c | |
parent | b66beb47bbc25776c0534d289b0f137c2cc53572 (diff) | |
download | Essentials-0f4982f4787defa9afb070d2256035963c884784.tar Essentials-0f4982f4787defa9afb070d2256035963c884784.tar.gz Essentials-0f4982f4787defa9afb070d2256035963c884784.tar.lz Essentials-0f4982f4787defa9afb070d2256035963c884784.tar.xz Essentials-0f4982f4787defa9afb070d2256035963c884784.zip |
Fix cleanup to not hold Users in memory.
6 files changed, 22 insertions, 15 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials/src/com/earth2me/essentials/EssentialsConf.java index e454db75a..da2a4c6aa 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsConf.java @@ -297,7 +297,7 @@ public class EssentialsConf extends YamlConfiguration Future<?> future = EXECUTOR_SERVICE.submit(new WriteRunner(configFile, data, pendingDiskWrites)); //LOGGER.log(Level.INFO, configFile + " prepared for writing in " + (System.nanoTime() - startTime) + " nsec."); - + return future; } @@ -351,16 +351,23 @@ public class EssentialsConf extends YamlConfiguration } } - - final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(configFile), UTF8); - + final FileOutputStream fos = new FileOutputStream(configFile); try { - writer.write(data); + final OutputStreamWriter writer = new OutputStreamWriter(fos, UTF8); + + try + { + writer.write(data); + } + finally + { + writer.close(); + } } finally { - writer.close(); + fos.close(); } } catch (IOException e) @@ -753,4 +760,5 @@ public class EssentialsConf extends YamlConfiguration { super.set(path, value); } + } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index a771fae3f..ea66a63a0 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -19,7 +19,7 @@ import org.bukkit.potion.PotionEffectType; public class User extends UserData implements Comparable<User>, IReplyTo, IUser { private CommandSender replyTo = null; - private transient User teleportRequester; + private transient String teleportRequester; private transient boolean teleportRequestHere; private transient boolean vanished; private transient final Teleport teleport; @@ -263,11 +263,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser public void requestTeleport(final User player, final boolean here) { teleportRequestTime = System.currentTimeMillis(); - teleportRequester = player; + teleportRequester = player.getName(); teleportRequestHere = here; } - public User getTeleportRequest() + public String getTeleportRequest() { return teleportRequester; } diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 1769c0f03..40a2aa27c 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack; public abstract class UserData extends PlayerExtension implements IConf { protected final transient IEssentials ess; - private EssentialsConf config; + private final EssentialsConf config; private final File folder; protected UserData(Player base, IEssentials ess) @@ -31,8 +31,7 @@ public abstract class UserData extends PlayerExtension implements IConf public final void reset() { config.getFile().delete(); - config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml")); - reloadConfig(); + ess.getUserMap().removeUser(this.getName()); } @Override diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java index 7c950ae96..647b223f7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java @@ -19,7 +19,7 @@ public class Commandtpaccept extends EssentialsCommand public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - final User target = user.getTeleportRequest(); + final User target = ess.getUser(user.getTeleportRequest()); if (target == null || !target.isOnline()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java index 92bba1054..2f2e6c41c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java @@ -15,7 +15,7 @@ public class Commandtpdeny extends EssentialsCommand @Override public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - final User player = user.getTeleportRequest(); + final User player = ess.getUser(user.getTeleportRequest()); if (player == null) { throw new Exception(_("noPendingRequest")); diff --git a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java index 31324a841..1d37f585d 100644 --- a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java +++ b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java @@ -29,7 +29,7 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf private static final Logger logger = Logger.getLogger("Minecraft"); File databaseFile; File dataFolder; - EssentialsConf config; + final EssentialsConf config; private final transient IEssentials ess; public EssentialsGeoIPPlayerListener(File dataFolder, IEssentials ess) |