mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-26 02:58:03 +01:00
Update /kit delay to use updated yaml code.
This commit is contained in:
parent
6fd82480a3
commit
0b8a6c45c6
@ -54,9 +54,9 @@ public class Kit
|
|||||||
final long earliestLong = earliestTime.getTimeInMillis();
|
final long earliestLong = earliestTime.getTimeInMillis();
|
||||||
|
|
||||||
// When was the last kit used?
|
// When was the last kit used?
|
||||||
final Long lastTime = user.getKitTimestamp(kitName);
|
final long lastTime = user.getKitTimestamp(kitName);
|
||||||
|
|
||||||
if (lastTime == null || lastTime < earliestLong)
|
if (lastTime < earliestLong)
|
||||||
{
|
{
|
||||||
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import static com.earth2me.essentials.I18n._;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.MemoryConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -777,27 +779,44 @@ public abstract class UserData extends PlayerExtension implements IConf
|
|||||||
{
|
{
|
||||||
return config.getBoolean("powertoolsenabled", true);
|
return config.getBoolean("powertoolsenabled", true);
|
||||||
}
|
}
|
||||||
private Map<String, Object> kitTimestamps;
|
private ConfigurationSection kitTimestamps;
|
||||||
|
|
||||||
private Map<String, Object> _getKitTimestamps()
|
private ConfigurationSection _getKitTimestamps()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (config.isConfigurationSection("timestamps.kits"))
|
if (config.isConfigurationSection("timestamps.kits"))
|
||||||
{
|
{
|
||||||
return config.getConfigurationSection("timestamps.kits").getValues(false);
|
final ConfigurationSection section = config.getConfigurationSection("timestamps.kits");
|
||||||
|
final ConfigurationSection newSection = new MemoryConfiguration();
|
||||||
|
for (String command : section.getKeys(false))
|
||||||
|
{
|
||||||
|
if (section.isLong(command))
|
||||||
|
{
|
||||||
|
newSection.set(command.toLowerCase(Locale.ENGLISH), section.getLong(command));
|
||||||
}
|
}
|
||||||
return new HashMap<String, Object>();
|
else if (section.isInt(command))
|
||||||
|
{
|
||||||
|
newSection.set(command.toLowerCase(Locale.ENGLISH), (long)section.getInt(command));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newSection;
|
||||||
|
}
|
||||||
|
return new MemoryConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getKitTimestamp(final String name)
|
public long getKitTimestamp(String name)
|
||||||
{
|
{
|
||||||
final Number num = (Number)kitTimestamps.get(name.toLowerCase(Locale.ENGLISH));
|
name = name.replace('.', '_').replace('/', '_');
|
||||||
return num == null ? null : num.longValue();
|
if (kitTimestamps != null)
|
||||||
|
{
|
||||||
|
return kitTimestamps.getLong(name, 0l);
|
||||||
|
}
|
||||||
|
return 0l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKitTimestamp(final String name, final long time)
|
public void setKitTimestamp(final String name, final long time)
|
||||||
{
|
{
|
||||||
kitTimestamps.put(name.toLowerCase(Locale.ENGLISH), time);
|
kitTimestamps.set(name.toLowerCase(Locale.ENGLISH), time);
|
||||||
config.setProperty("timestamps.kits", kitTimestamps);
|
config.setProperty("timestamps.kits", kitTimestamps);
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user