mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-07-03 04:21:37 +00:00
Clean up userdata saving, to prevent CMI
Also update config section code to use newer bukkit methods
This commit is contained in:
parent
298ab846c1
commit
ef1492a2a2
2 changed files with 92 additions and 98 deletions
|
@ -5,7 +5,6 @@ import java.io.File;
|
|||
import java.util.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.MemoryConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
@ -794,44 +793,44 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||
{
|
||||
return config.getBoolean("powertoolsenabled", true);
|
||||
}
|
||||
private ConfigurationSection kitTimestamps;
|
||||
|
||||
private ConfigurationSection _getKitTimestamps()
|
||||
private Map<String, Long> kitTimestamps;
|
||||
|
||||
private Map<String, Long> _getKitTimestamps()
|
||||
{
|
||||
|
||||
|
||||
if (config.isConfigurationSection("timestamps.kits"))
|
||||
{
|
||||
final ConfigurationSection section = config.getConfigurationSection("timestamps.kits");
|
||||
final ConfigurationSection newSection = new MemoryConfiguration();
|
||||
final Map<String, Long> timestamps = new HashMap<String, Long>();
|
||||
for (String command : section.getKeys(false))
|
||||
{
|
||||
if (section.isLong(command))
|
||||
{
|
||||
newSection.set(command.toLowerCase(Locale.ENGLISH), section.getLong(command));
|
||||
timestamps.put(command.toLowerCase(Locale.ENGLISH), section.getLong(command));
|
||||
}
|
||||
else if (section.isInt(command))
|
||||
{
|
||||
newSection.set(command.toLowerCase(Locale.ENGLISH), (long)section.getInt(command));
|
||||
timestamps.put(command.toLowerCase(Locale.ENGLISH), (long)section.getInt(command));
|
||||
}
|
||||
}
|
||||
return newSection;
|
||||
return timestamps;
|
||||
}
|
||||
return new MemoryConfiguration();
|
||||
return new HashMap<String, Long>();
|
||||
}
|
||||
|
||||
|
||||
public long getKitTimestamp(String name)
|
||||
{
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
if (kitTimestamps != null)
|
||||
if (kitTimestamps != null && kitTimestamps.containsKey(name))
|
||||
{
|
||||
return kitTimestamps.getLong(name, 0l);
|
||||
return kitTimestamps.get(name);
|
||||
}
|
||||
return 0l;
|
||||
}
|
||||
|
||||
public void setKitTimestamp(final String name, final long time)
|
||||
{
|
||||
kitTimestamps.set(name.toLowerCase(Locale.ENGLISH), time);
|
||||
kitTimestamps.put(name.toLowerCase(Locale.ENGLISH), time);
|
||||
config.setProperty("timestamps.kits", kitTimestamps);
|
||||
config.save();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue