summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2013-05-03 00:12:40 +0200
committersnowleo <schneeleo@gmail.com>2013-05-03 00:12:40 +0200
commit555a300378613d35e4eaebf93da278782b3194cf (patch)
tree51df0ce643542e5efabe7e935e9ec2613684b17c
parentebc6b14284cf1bf58d908b65e137981f66040070 (diff)
downloadEssentials-555a300378613d35e4eaebf93da278782b3194cf.tar
Essentials-555a300378613d35e4eaebf93da278782b3194cf.tar.gz
Essentials-555a300378613d35e4eaebf93da278782b3194cf.tar.lz
Essentials-555a300378613d35e4eaebf93da278782b3194cf.tar.xz
Essentials-555a300378613d35e4eaebf93da278782b3194cf.zip
Fix cleanup to not hold Users in memory.
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsConf.java20
-rw-r--r--Essentials/src/com/earth2me/essentials/User.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/UserData.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java2
-rw-r--r--EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java2
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)