2011-03-30 04:03:21 +00:00
|
|
|
package com.earth2me.essentials;
|
|
|
|
|
2011-11-21 01:55:26 +00:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
2013-04-29 18:29:42 +00:00
|
|
|
|
2013-07-13 15:14:39 +00:00
|
|
|
import net.ess3.api.InvalidWorldException;
|
2012-03-23 10:13:03 +00:00
|
|
|
import com.google.common.io.Files;
|
2011-11-18 17:42:26 +00:00
|
|
|
import java.io.*;
|
2013-05-05 09:41:19 +00:00
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.MathContext;
|
2012-03-23 10:13:03 +00:00
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
import java.nio.CharBuffer;
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
import java.nio.charset.CharsetDecoder;
|
|
|
|
import java.nio.charset.CoderResult;
|
2012-09-08 13:55:37 +00:00
|
|
|
import java.util.*;
|
2013-04-22 22:47:45 +00:00
|
|
|
import java.util.concurrent.ExecutionException;
|
2013-04-22 21:31:11 +00:00
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
import java.util.concurrent.Executors;
|
2013-04-22 22:47:45 +00:00
|
|
|
import java.util.concurrent.Future;
|
2013-04-22 21:31:11 +00:00
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
2011-03-30 04:03:21 +00:00
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
2012-09-08 13:55:37 +00:00
|
|
|
import org.bukkit.*;
|
2012-09-08 15:03:54 +00:00
|
|
|
import org.bukkit.OfflinePlayer;
|
2012-02-21 16:33:46 +00:00
|
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
|
|
import org.bukkit.configuration.InvalidConfigurationException;
|
|
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
2011-11-27 05:00:58 +00:00
|
|
|
import org.bukkit.enchantments.Enchantment;
|
2011-04-07 02:21:10 +00:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
2012-09-07 16:33:28 +00:00
|
|
|
import org.bukkit.util.Vector;
|
2011-03-30 04:03:21 +00:00
|
|
|
|
|
|
|
|
2012-02-21 16:33:46 +00:00
|
|
|
public class EssentialsConf extends YamlConfiguration
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
2011-08-27 13:30:30 +00:00
|
|
|
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
2013-04-22 21:31:11 +00:00
|
|
|
private final File configFile;
|
|
|
|
private String templateName = null;
|
|
|
|
private Class<?> resourceClass = EssentialsConf.class;
|
2012-03-23 10:13:03 +00:00
|
|
|
private static final Charset UTF8 = Charset.forName("UTF-8");
|
2013-04-22 21:31:11 +00:00
|
|
|
private static final ExecutorService EXECUTOR_SERVICE = Executors.newSingleThreadExecutor();
|
|
|
|
private final AtomicInteger pendingDiskWrites = new AtomicInteger(0);
|
2011-03-30 04:03:21 +00:00
|
|
|
|
2011-08-27 13:30:30 +00:00
|
|
|
public EssentialsConf(final File configFile)
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
2012-02-21 16:33:46 +00:00
|
|
|
super();
|
2013-04-22 21:31:11 +00:00
|
|
|
this.configFile = configFile.getAbsoluteFile();
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2012-08-06 13:57:35 +00:00
|
|
|
private final byte[] bytebuffer = new byte[1024];
|
2011-03-30 04:03:21 +00:00
|
|
|
|
2012-04-11 19:51:34 +00:00
|
|
|
public synchronized void load()
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
2013-04-22 21:31:11 +00:00
|
|
|
if (pendingDiskWrites.get() != 0)
|
|
|
|
{
|
|
|
|
LOGGER.log(Level.INFO, "File " + configFile + " not read, because it's not yet written to disk.");
|
|
|
|
return;
|
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
if (!configFile.getParentFile().exists())
|
|
|
|
{
|
2011-06-01 10:40:12 +00:00
|
|
|
if (!configFile.getParentFile().mkdirs())
|
|
|
|
{
|
2011-11-21 01:55:26 +00:00
|
|
|
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
|
2011-06-01 10:40:12 +00:00
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-27 13:30:30 +00:00
|
|
|
// This will delete files where the first character is 0. In most cases they are broken.
|
|
|
|
if (configFile.exists() && configFile.length() != 0)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
final InputStream input = new FileInputStream(configFile);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (input.read() == 0)
|
|
|
|
{
|
|
|
|
input.close();
|
|
|
|
configFile.delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
|
|
|
LOGGER.log(Level.SEVERE, null, ex);
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
input.close();
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
|
|
|
LOGGER.log(Level.SEVERE, null, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (FileNotFoundException ex)
|
|
|
|
{
|
|
|
|
LOGGER.log(Level.SEVERE, null, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-30 04:03:21 +00:00
|
|
|
if (!configFile.exists())
|
|
|
|
{
|
|
|
|
if (templateName != null)
|
|
|
|
{
|
2011-11-21 01:55:26 +00:00
|
|
|
LOGGER.log(Level.INFO, _("creatingConfigFromTemplate", configFile.toString()));
|
2011-03-30 04:03:21 +00:00
|
|
|
createFromTemplate();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-13 23:58:57 +00:00
|
|
|
return;
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-27 13:30:30 +00:00
|
|
|
|
2012-02-21 16:33:46 +00:00
|
|
|
|
2011-08-27 13:30:30 +00:00
|
|
|
try
|
|
|
|
{
|
2012-03-23 10:13:03 +00:00
|
|
|
final FileInputStream inputStream = new FileInputStream(configFile);
|
|
|
|
try
|
|
|
|
{
|
2013-05-02 23:26:51 +00:00
|
|
|
long startSize = configFile.length();
|
|
|
|
if (startSize > Integer.MAX_VALUE) {
|
|
|
|
throw new InvalidConfigurationException("File too big");
|
|
|
|
}
|
|
|
|
ByteBuffer buffer = ByteBuffer.allocate((int)startSize);
|
2012-08-06 13:57:35 +00:00
|
|
|
int length;
|
|
|
|
while ((length = inputStream.read(bytebuffer)) != -1)
|
2012-08-05 17:41:06 +00:00
|
|
|
{
|
2013-05-02 23:26:51 +00:00
|
|
|
if (length > buffer.remaining()) {
|
|
|
|
ByteBuffer resize = ByteBuffer.allocate(buffer.capacity()+length-buffer.remaining());
|
|
|
|
int resizePosition = buffer.position();
|
|
|
|
buffer.rewind();
|
|
|
|
resize.put(buffer);
|
|
|
|
resize.position(resizePosition);
|
|
|
|
buffer = resize;
|
|
|
|
}
|
2012-08-06 13:57:35 +00:00
|
|
|
buffer.put(bytebuffer, 0, length);
|
2012-08-05 17:41:06 +00:00
|
|
|
}
|
2012-03-23 10:13:03 +00:00
|
|
|
buffer.rewind();
|
2013-05-02 23:26:51 +00:00
|
|
|
final CharBuffer data = CharBuffer.allocate(buffer.capacity());
|
2012-03-23 10:13:03 +00:00
|
|
|
CharsetDecoder decoder = UTF8.newDecoder();
|
|
|
|
CoderResult result = decoder.decode(buffer, data, true);
|
|
|
|
if (result.isError())
|
|
|
|
{
|
|
|
|
buffer.rewind();
|
|
|
|
data.clear();
|
2012-03-23 13:30:00 +00:00
|
|
|
LOGGER.log(Level.INFO, "File " + configFile.getAbsolutePath().toString() + " is not utf-8 encoded, trying " + Charset.defaultCharset().displayName());
|
2012-03-23 10:13:03 +00:00
|
|
|
decoder = Charset.defaultCharset().newDecoder();
|
|
|
|
result = decoder.decode(buffer, data, true);
|
|
|
|
if (result.isError())
|
|
|
|
{
|
|
|
|
throw new InvalidConfigurationException("Invalid Characters in file " + configFile.getAbsolutePath().toString());
|
2012-03-23 13:22:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-23 10:13:03 +00:00
|
|
|
decoder.flush(data);
|
|
|
|
}
|
2012-03-23 13:22:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-23 10:13:03 +00:00
|
|
|
decoder.flush(data);
|
|
|
|
}
|
2012-03-23 13:22:10 +00:00
|
|
|
final int end = data.position();
|
2012-03-23 10:13:03 +00:00
|
|
|
data.rewind();
|
2012-03-23 13:22:10 +00:00
|
|
|
super.loadFromString(data.subSequence(0, end).toString());
|
2012-03-23 10:13:03 +00:00
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
inputStream.close();
|
|
|
|
}
|
2011-08-22 23:28:01 +00:00
|
|
|
}
|
2012-02-21 16:33:46 +00:00
|
|
|
catch (IOException ex)
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
{
|
2012-03-23 10:13:03 +00:00
|
|
|
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
2012-02-21 16:33:46 +00:00
|
|
|
}
|
|
|
|
catch (InvalidConfigurationException ex)
|
|
|
|
{
|
|
|
|
File broken = new File(configFile.getAbsolutePath() + ".broken." + System.currentTimeMillis());
|
|
|
|
configFile.renameTo(broken);
|
|
|
|
LOGGER.log(Level.SEVERE, "The file " + configFile.toString() + " is broken, it has been renamed to " + broken.toString(), ex.getCause());
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void createFromTemplate()
|
|
|
|
{
|
2011-06-01 10:40:12 +00:00
|
|
|
InputStream istr = null;
|
2011-03-30 04:03:21 +00:00
|
|
|
OutputStream ostr = null;
|
|
|
|
try
|
|
|
|
{
|
2011-06-01 10:40:12 +00:00
|
|
|
istr = resourceClass.getResourceAsStream(templateName);
|
2011-03-30 04:03:21 +00:00
|
|
|
if (istr == null)
|
|
|
|
{
|
2011-11-21 01:55:26 +00:00
|
|
|
LOGGER.log(Level.SEVERE, _("couldNotFindTemplate", templateName));
|
2011-03-30 04:03:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ostr = new FileOutputStream(configFile);
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
int length = 0;
|
|
|
|
length = istr.read(buffer);
|
|
|
|
while (length > 0)
|
|
|
|
{
|
|
|
|
ostr.write(buffer, 0, length);
|
|
|
|
length = istr.read(buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
2011-11-21 01:55:26 +00:00
|
|
|
LOGGER.log(Level.SEVERE, _("failedToWriteConfig", configFile.toString()), ex);
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
2011-06-01 10:40:12 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if (istr != null)
|
|
|
|
{
|
|
|
|
istr.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
|
|
|
Logger.getLogger(EssentialsConf.class.getName()).log(Level.SEVERE, null, ex);
|
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
try
|
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
if (ostr != null)
|
|
|
|
{
|
2011-03-30 12:56:34 +00:00
|
|
|
ostr.close();
|
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
2011-11-21 01:55:26 +00:00
|
|
|
LOGGER.log(Level.SEVERE, _("failedToCloseConfig", configFile.toString()), ex);
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-27 13:30:30 +00:00
|
|
|
public void setTemplateName(final String templateName)
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
|
|
|
this.templateName = templateName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public File getFile()
|
|
|
|
{
|
|
|
|
return configFile;
|
|
|
|
}
|
|
|
|
|
2011-08-27 13:30:30 +00:00
|
|
|
public void setTemplateName(final String templateName, final Class<?> resClass)
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
{
|
2011-03-30 04:03:21 +00:00
|
|
|
this.templateName = templateName;
|
|
|
|
this.resourceClass = resClass;
|
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
|
2013-01-12 19:30:06 +00:00
|
|
|
public void save()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
save(configFile);
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
|
|
|
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void saveWithError() throws IOException
|
|
|
|
{
|
|
|
|
save(configFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized void save(final File file) throws IOException
|
2013-04-22 22:47:45 +00:00
|
|
|
{
|
|
|
|
delayedSave(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized void forceSave()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Future<?> future = delayedSave(configFile);
|
|
|
|
if (future != null)
|
|
|
|
{
|
|
|
|
future.get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (InterruptedException ex)
|
|
|
|
{
|
|
|
|
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
|
|
|
}
|
|
|
|
catch (ExecutionException ex)
|
|
|
|
{
|
|
|
|
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private Future<?> delayedSave(final File file)
|
2013-01-12 19:30:06 +00:00
|
|
|
{
|
2013-04-22 21:31:11 +00:00
|
|
|
//long startTime = System.nanoTime();
|
2013-01-12 19:30:06 +00:00
|
|
|
if (file == null)
|
|
|
|
{
|
|
|
|
throw new IllegalArgumentException("File cannot be null");
|
|
|
|
}
|
|
|
|
|
|
|
|
final String data = saveToString();
|
|
|
|
|
|
|
|
if (data.length() == 0)
|
|
|
|
{
|
2013-04-22 22:47:45 +00:00
|
|
|
return null;
|
2013-01-12 19:30:06 +00:00
|
|
|
}
|
|
|
|
|
2013-04-22 21:31:11 +00:00
|
|
|
pendingDiskWrites.incrementAndGet();
|
|
|
|
|
2013-04-22 22:47:45 +00:00
|
|
|
Future<?> future = EXECUTOR_SERVICE.submit(new WriteRunner(configFile, data, pendingDiskWrites));
|
2013-04-22 21:31:11 +00:00
|
|
|
|
|
|
|
//LOGGER.log(Level.INFO, configFile + " prepared for writing in " + (System.nanoTime() - startTime) + " nsec.");
|
2013-05-02 22:12:40 +00:00
|
|
|
|
2013-04-22 22:47:45 +00:00
|
|
|
return future;
|
2013-04-22 21:31:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static class WriteRunner implements Runnable
|
|
|
|
{
|
|
|
|
private final File configFile;
|
|
|
|
private final String data;
|
|
|
|
private final AtomicInteger pendingDiskWrites;
|
|
|
|
|
|
|
|
private WriteRunner(final File configFile, final String data, final AtomicInteger pendingDiskWrites)
|
2013-01-12 19:30:06 +00:00
|
|
|
{
|
2013-04-22 21:31:11 +00:00
|
|
|
this.configFile = configFile;
|
|
|
|
this.data = data;
|
|
|
|
this.pendingDiskWrites = pendingDiskWrites;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
//long startTime = System.nanoTime();
|
|
|
|
synchronized (configFile)
|
2013-01-12 19:30:06 +00:00
|
|
|
{
|
2013-04-22 21:31:11 +00:00
|
|
|
if (pendingDiskWrites.get() > 1)
|
2013-01-12 19:30:06 +00:00
|
|
|
{
|
2013-04-22 21:31:11 +00:00
|
|
|
// Writes can be skipped, because they are stored in a queue (in the executor).
|
|
|
|
// Only the last is actually written.
|
|
|
|
pendingDiskWrites.decrementAndGet();
|
|
|
|
//LOGGER.log(Level.INFO, configFile + " skipped writing in " + (System.nanoTime() - startTime) + " nsec.");
|
|
|
|
return;
|
2013-01-12 19:30:06 +00:00
|
|
|
}
|
2013-04-22 21:31:11 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Files.createParentDirs(configFile);
|
2013-01-12 19:30:06 +00:00
|
|
|
|
2013-04-22 21:31:11 +00:00
|
|
|
if (!configFile.exists())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
|
|
|
|
if (!configFile.createNewFile())
|
|
|
|
{
|
|
|
|
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (IOException ex)
|
|
|
|
{
|
|
|
|
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-01-12 19:30:06 +00:00
|
|
|
|
2013-05-02 22:12:40 +00:00
|
|
|
final FileOutputStream fos = new FileOutputStream(configFile);
|
2013-04-22 21:31:11 +00:00
|
|
|
try
|
|
|
|
{
|
2013-05-02 22:12:40 +00:00
|
|
|
final OutputStreamWriter writer = new OutputStreamWriter(fos, UTF8);
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
writer.write(data);
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
writer.close();
|
|
|
|
}
|
2013-04-22 21:31:11 +00:00
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
2013-05-02 22:12:40 +00:00
|
|
|
fos.close();
|
2013-04-22 21:31:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
LOGGER.log(Level.SEVERE, e.getMessage(), e);
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
//LOGGER.log(Level.INFO, configFile + " written to disk in " + (System.nanoTime() - startTime) + " nsec.");
|
|
|
|
pendingDiskWrites.decrementAndGet();
|
|
|
|
}
|
|
|
|
}
|
2013-01-12 19:30:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-27 13:30:30 +00:00
|
|
|
public boolean hasProperty(final String path)
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
{
|
2012-02-21 16:33:46 +00:00
|
|
|
return isSet(path);
|
2011-04-07 02:21:10 +00:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
|
2013-04-29 18:29:42 +00:00
|
|
|
public Location getLocation(final String path, final Server server) throws InvalidWorldException
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
{
|
2011-08-27 13:30:30 +00:00
|
|
|
final String worldName = getString((path == null ? "" : path + ".") + "world");
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
if (worldName == null || worldName.isEmpty())
|
|
|
|
{
|
2011-04-07 02:21:10 +00:00
|
|
|
return null;
|
|
|
|
}
|
2011-08-27 13:30:30 +00:00
|
|
|
final World world = server.getWorld(worldName);
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
if (world == null)
|
|
|
|
{
|
2013-04-29 18:29:42 +00:00
|
|
|
throw new InvalidWorldException(worldName);
|
2011-04-07 02:21:10 +00:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
return new Location(world,
|
2011-08-27 13:30:30 +00:00
|
|
|
getDouble((path == null ? "" : path + ".") + "x", 0),
|
|
|
|
getDouble((path == null ? "" : path + ".") + "y", 0),
|
|
|
|
getDouble((path == null ? "" : path + ".") + "z", 0),
|
|
|
|
(float)getDouble((path == null ? "" : path + ".") + "yaw", 0),
|
|
|
|
(float)getDouble((path == null ? "" : path + ".") + "pitch", 0));
|
2011-04-07 02:21:10 +00:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
|
2011-08-27 13:30:30 +00:00
|
|
|
public void setProperty(final String path, final Location loc)
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
{
|
2012-02-21 16:33:46 +00:00
|
|
|
set((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
|
|
|
|
set((path == null ? "" : path + ".") + "x", loc.getX());
|
|
|
|
set((path == null ? "" : path + ".") + "y", loc.getY());
|
|
|
|
set((path == null ? "" : path + ".") + "z", loc.getZ());
|
|
|
|
set((path == null ? "" : path + ".") + "yaw", loc.getYaw());
|
|
|
|
set((path == null ? "" : path + ".") + "pitch", loc.getPitch());
|
2011-04-07 02:21:10 +00:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
|
2012-02-21 16:33:46 +00:00
|
|
|
@Override
|
2011-08-27 13:30:30 +00:00
|
|
|
public ItemStack getItemStack(final String path)
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
{
|
2011-11-27 05:00:58 +00:00
|
|
|
final ItemStack stack = new ItemStack(
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
Material.valueOf(getString(path + ".type", "AIR")),
|
|
|
|
getInt(path + ".amount", 1),
|
2011-11-27 05:00:58 +00:00
|
|
|
(short)getInt(path + ".damage", 0));
|
2012-02-21 16:33:46 +00:00
|
|
|
final ConfigurationSection enchants = getConfigurationSection(path + ".enchant");
|
2011-11-28 23:30:06 +00:00
|
|
|
if (enchants != null)
|
2011-11-27 05:00:58 +00:00
|
|
|
{
|
2012-02-21 16:33:46 +00:00
|
|
|
for (String enchant : enchants.getKeys(false))
|
2011-11-28 23:30:06 +00:00
|
|
|
{
|
|
|
|
final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
|
|
|
|
if (enchantment == null)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
final int level = getInt(path + ".enchant." + enchant, enchantment.getStartLevel());
|
|
|
|
stack.addUnsafeEnchantment(enchantment, level);
|
2011-11-27 05:00:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return stack;
|
|
|
|
/*
|
2011-11-28 23:30:06 +00:00
|
|
|
* ,
|
|
|
|
* (byte)getInt(path + ".data", 0)
|
|
|
|
*/
|
2011-04-07 02:21:10 +00:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
|
2011-08-27 13:30:30 +00:00
|
|
|
public void setProperty(final String path, final ItemStack stack)
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
{
|
2011-08-27 13:30:30 +00:00
|
|
|
final Map<String, Object> map = new HashMap<String, Object>();
|
2011-04-07 02:21:10 +00:00
|
|
|
map.put("type", stack.getType().toString());
|
|
|
|
map.put("amount", stack.getAmount());
|
|
|
|
map.put("damage", stack.getDurability());
|
2011-11-27 05:00:58 +00:00
|
|
|
Map<Enchantment, Integer> enchantments = stack.getEnchantments();
|
|
|
|
if (!enchantments.isEmpty())
|
|
|
|
{
|
|
|
|
Map<String, Integer> enchant = new HashMap<String, Integer>();
|
|
|
|
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet())
|
|
|
|
{
|
2011-11-27 05:23:07 +00:00
|
|
|
enchant.put(entry.getKey().getName().toLowerCase(Locale.ENGLISH), entry.getValue());
|
2011-11-27 05:00:58 +00:00
|
|
|
}
|
|
|
|
map.put("enchant", enchant);
|
|
|
|
}
|
2011-04-16 14:39:31 +00:00
|
|
|
// getData().getData() is broken
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
//map.put("data", stack.getDurability());
|
2012-02-21 16:33:46 +00:00
|
|
|
set(path, map);
|
2011-04-07 02:21:10 +00:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
|
2013-01-12 19:30:06 +00:00
|
|
|
public void setProperty(String path, List object)
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
{
|
2013-01-12 19:30:06 +00:00
|
|
|
set(path, new ArrayList(object));
|
2011-04-07 02:21:10 +00:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
|
2013-01-12 19:30:06 +00:00
|
|
|
public void setProperty(String path, Map object)
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
{
|
2013-01-12 19:30:06 +00:00
|
|
|
set(path, new LinkedHashMap(object));
|
2012-03-23 10:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Object getProperty(String path)
|
|
|
|
{
|
2012-02-21 16:33:46 +00:00
|
|
|
return get(path);
|
|
|
|
}
|
2013-05-05 09:41:19 +00:00
|
|
|
|
|
|
|
public void setProperty(final String path, final BigDecimal bigDecimal)
|
|
|
|
{
|
|
|
|
set(path, bigDecimal.toString());
|
|
|
|
}
|
2012-03-23 10:13:03 +00:00
|
|
|
|
|
|
|
public void setProperty(String path, Object object)
|
|
|
|
{
|
2012-02-21 16:33:46 +00:00
|
|
|
set(path, object);
|
|
|
|
}
|
2012-03-23 10:13:03 +00:00
|
|
|
|
|
|
|
public void removeProperty(String path)
|
|
|
|
{
|
2012-02-21 16:33:46 +00:00
|
|
|
set(path, null);
|
|
|
|
}
|
2012-09-07 16:33:28 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized Object get(String path)
|
|
|
|
{
|
|
|
|
return super.get(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized Object get(String path, Object def)
|
|
|
|
{
|
|
|
|
return super.get(path, def);
|
|
|
|
}
|
2013-05-05 09:41:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
public synchronized BigDecimal getBigDecimal(final String path, final BigDecimal def)
|
|
|
|
{
|
|
|
|
final String input = super.getString(path);
|
|
|
|
return toBigDecimal(input, def);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static BigDecimal toBigDecimal(final String input, final BigDecimal def)
|
|
|
|
{
|
|
|
|
if (input == null || input.isEmpty())
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return new BigDecimal(input, MathContext.DECIMAL128);
|
|
|
|
}
|
2013-05-05 09:55:39 +00:00
|
|
|
catch (NumberFormatException e)
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
2013-05-05 09:41:19 +00:00
|
|
|
catch (ArithmeticException e)
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-07 16:33:28 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean getBoolean(String path)
|
|
|
|
{
|
|
|
|
return super.getBoolean(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean getBoolean(String path, boolean def)
|
|
|
|
{
|
|
|
|
return super.getBoolean(path, def);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized List<Boolean> getBooleanList(String path)
|
|
|
|
{
|
|
|
|
return super.getBooleanList(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized List<Byte> getByteList(String path)
|
|
|
|
{
|
|
|
|
return super.getByteList(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized List<Character> getCharacterList(String path)
|
|
|
|
{
|
|
|
|
return super.getCharacterList(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized ConfigurationSection getConfigurationSection(String path)
|
|
|
|
{
|
|
|
|
return super.getConfigurationSection(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized double getDouble(String path)
|
|
|
|
{
|
|
|
|
return super.getDouble(path);
|
|
|
|
}
|
|
|
|
|
2013-01-12 19:30:06 +00:00
|
|
|
@Override
|
|
|
|
public synchronized double getDouble(final String path, final double def)
|
|
|
|
{
|
|
|
|
return super.getDouble(path, def);
|
|
|
|
}
|
|
|
|
|
2012-09-07 16:33:28 +00:00
|
|
|
@Override
|
|
|
|
public synchronized List<Double> getDoubleList(String path)
|
|
|
|
{
|
|
|
|
return super.getDoubleList(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized List<Float> getFloatList(String path)
|
|
|
|
{
|
|
|
|
return super.getFloatList(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized int getInt(String path)
|
|
|
|
{
|
|
|
|
return super.getInt(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized int getInt(String path, int def)
|
|
|
|
{
|
|
|
|
return super.getInt(path, def);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized List<Integer> getIntegerList(String path)
|
|
|
|
{
|
|
|
|
return super.getIntegerList(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized ItemStack getItemStack(String path, ItemStack def)
|
|
|
|
{
|
|
|
|
return super.getItemStack(path, def);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized Set<String> getKeys(boolean deep)
|
|
|
|
{
|
|
|
|
return super.getKeys(deep);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized List<?> getList(String path)
|
|
|
|
{
|
|
|
|
return super.getList(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized List<?> getList(String path, List<?> def)
|
|
|
|
{
|
|
|
|
return super.getList(path, def);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized long getLong(String path)
|
|
|
|
{
|
|
|
|
return super.getLong(path);
|
|
|
|
}
|
|
|
|
|
2013-01-12 19:30:06 +00:00
|
|
|
@Override
|
|
|
|
public synchronized long getLong(final String path, final long def)
|
|
|
|
{
|
|
|
|
return super.getLong(path, def);
|
|
|
|
}
|
|
|
|
|
2012-09-07 16:33:28 +00:00
|
|
|
@Override
|
|
|
|
public synchronized List<Long> getLongList(String path)
|
|
|
|
{
|
|
|
|
return super.getLongList(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized Map<String, Object> getMap()
|
|
|
|
{
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized List<Map<?, ?>> getMapList(String path)
|
|
|
|
{
|
|
|
|
return super.getMapList(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized OfflinePlayer getOfflinePlayer(String path)
|
|
|
|
{
|
|
|
|
return super.getOfflinePlayer(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized OfflinePlayer getOfflinePlayer(String path, OfflinePlayer def)
|
|
|
|
{
|
|
|
|
return super.getOfflinePlayer(path, def);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized List<Short> getShortList(String path)
|
|
|
|
{
|
|
|
|
return super.getShortList(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized String getString(String path)
|
|
|
|
{
|
|
|
|
return super.getString(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized String getString(String path, String def)
|
|
|
|
{
|
|
|
|
return super.getString(path, def);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized List<String> getStringList(String path)
|
|
|
|
{
|
|
|
|
return super.getStringList(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized Map<String, Object> getValues(boolean deep)
|
|
|
|
{
|
|
|
|
return super.getValues(deep);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized Vector getVector(String path)
|
|
|
|
{
|
|
|
|
return super.getVector(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized Vector getVector(String path, Vector def)
|
|
|
|
{
|
|
|
|
return super.getVector(path, def);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean isBoolean(String path)
|
|
|
|
{
|
|
|
|
return super.isBoolean(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean isConfigurationSection(String path)
|
|
|
|
{
|
|
|
|
return super.isConfigurationSection(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean isDouble(String path)
|
|
|
|
{
|
|
|
|
return super.isDouble(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean isInt(String path)
|
|
|
|
{
|
|
|
|
return super.isInt(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean isItemStack(String path)
|
|
|
|
{
|
|
|
|
return super.isItemStack(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean isList(String path)
|
|
|
|
{
|
|
|
|
return super.isList(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean isLong(String path)
|
|
|
|
{
|
|
|
|
return super.isLong(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean isOfflinePlayer(String path)
|
|
|
|
{
|
|
|
|
return super.isOfflinePlayer(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean isSet(String path)
|
|
|
|
{
|
|
|
|
return super.isSet(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean isString(String path)
|
|
|
|
{
|
|
|
|
return super.isString(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean isVector(String path)
|
|
|
|
{
|
|
|
|
return super.isVector(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized void set(String path, Object value)
|
|
|
|
{
|
|
|
|
super.set(path, value);
|
|
|
|
}
|
2013-05-02 22:12:40 +00:00
|
|
|
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|