1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-20 05:21:21 +02:00

Merge branch 'refs/heads/master' into 3.0

Conflicts:
	.gitignore
	Essentials/src/com/earth2me/essentials/Essentials.java
	Essentials/src/com/earth2me/essentials/EssentialsTimer.java
	Essentials/src/com/earth2me/essentials/ISettings.java
	Essentials/src/com/earth2me/essentials/Jails.java
	Essentials/src/com/earth2me/essentials/OfflinePlayer.java
	Essentials/src/com/earth2me/essentials/Settings.java
	Essentials/src/com/earth2me/essentials/User.java
	Essentials/src/com/earth2me/essentials/UserData.java
	Essentials/src/com/earth2me/essentials/UserMap.java
	Essentials/src/com/earth2me/essentials/Util.java
	Essentials/src/com/earth2me/essentials/commands/Commandnear.java
	Essentials/src/com/earth2me/essentials/commands/Commandping.java
	Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
	Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
	Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java
	Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
	Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
	Essentials/src/messages_en.properties
	Essentials2Compat/src/com/earth2me/essentials/EssentialsConf.java
	Essentials2Compat/src/com/earth2me/essentials/EssentialsUpgrade.java
	EssentialsChat/src/plugin.yml
	EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
	EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
	EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
This commit is contained in:
snowleo
2012-02-21 18:34:53 +01:00
79 changed files with 1236 additions and 661 deletions

View File

@@ -3,7 +3,6 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
@@ -12,13 +11,15 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.config.Configuration;
@Deprecated
public class EssentialsConf extends Configuration
public class EssentialsConf extends YamlConfiguration
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient File configFile;
@@ -27,15 +28,10 @@ public class EssentialsConf extends Configuration
public EssentialsConf(final File configFile)
{
super(configFile);
super();
this.configFile = configFile;
if (this.root == null)
{
this.root = new HashMap<String, Object>();
}
}
@Override
public void load()
{
configFile = configFile.getAbsoluteFile();
@@ -106,19 +102,24 @@ public class EssentialsConf extends Configuration
}
}
try
{
super.load();
super.load(configFile);
}
catch (RuntimeException e)
catch (FileNotFoundException ex)
{
LOGGER.log(Level.SEVERE, "File broken: " + configFile.toString());
throw e;
LOGGER.log(Level.SEVERE, null, ex);
}
if (this.root == null)
catch (IOException ex)
{
this.root = new HashMap<String, Object>();
LOGGER.log(Level.SEVERE, null, ex);
}
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());
}
}
@@ -193,7 +194,7 @@ public class EssentialsConf extends Configuration
public boolean hasProperty(final String path)
{
return getProperty(path) != null;
return isSet(path);
}
public Location getLocation(final String path, final Server server) throws Exception
@@ -218,24 +219,25 @@ public class EssentialsConf extends Configuration
public void setProperty(final String path, final Location loc)
{
setProperty((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
setProperty((path == null ? "" : path + ".") + "x", loc.getX());
setProperty((path == null ? "" : path + ".") + "y", loc.getY());
setProperty((path == null ? "" : path + ".") + "z", loc.getZ());
setProperty((path == null ? "" : path + ".") + "yaw", loc.getYaw());
setProperty((path == null ? "" : path + ".") + "pitch", loc.getPitch());
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());
}
@Override
public ItemStack getItemStack(final String path)
{
final ItemStack stack = new ItemStack(
Material.valueOf(getString(path + ".type", "AIR")),
getInt(path + ".amount", 1),
(short)getInt(path + ".damage", 0));
final List<String> enchants = getKeys(path + ".enchant");
final ConfigurationSection enchants = getConfigurationSection(path + ".enchant");
if (enchants != null)
{
for (String enchant : enchants)
for (String enchant : enchants.getKeys(false))
{
final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
if (enchantment == null)
@@ -271,14 +273,14 @@ public class EssentialsConf extends Configuration
}
// getData().getData() is broken
//map.put("data", stack.getDurability());
setProperty(path, map);
set(path, map);
}
public long getLong(final String path, final long def)
{
try
{
final Number num = (Number)getProperty(path);
final Number num = (Number)get(path);
return num == null ? def : num.longValue();
}
catch (ClassCastException ex)
@@ -292,7 +294,7 @@ public class EssentialsConf extends Configuration
{
try
{
Number num = (Number)getProperty(path);
Number num = (Number)get(path);
return num == null ? def : num.doubleValue();
}
catch (ClassCastException ex)
@@ -300,4 +302,27 @@ public class EssentialsConf extends Configuration
return def;
}
}
public void save() {
try
{
save(configFile);
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
}
}
public Object getProperty(String path) {
return get(path);
}
public void setProperty(String path, Object object) {
set(path, object);
}
public void removeProperty(String path) {
set(path, null);
}
}

View File

@@ -96,7 +96,7 @@ public class EssentialsUpgrade
}
final EssentialsConf conf = new EssentialsConf(configFile);
conf.load();
List<String> lines = conf.getStringList(name, null);
List<String> lines = conf.getStringList(name);
if (lines != null && !lines.isEmpty())
{
if (!file.createNewFile())
@@ -329,7 +329,7 @@ public class EssentialsUpgrade
config.setProperty("homes.home", defloc);
}
List<String> worlds = config.getKeys("home.worlds");
Set<String> worlds = config.getConfigurationSection("home.worlds").getKeys(false);
Location loc;
String worldName;
@@ -384,6 +384,7 @@ public class EssentialsUpgrade
* ((Number)vals.get(4)).floatValue())); } } } } usersFile.renameTo(new File(usersFile.getAbsolutePath() + ".old"));
* }
*/
private void convertWarps()
{
final File warpsFolder = new File(ess.getDataFolder(), "warps");
@@ -610,7 +611,7 @@ public class EssentialsUpgrade
if (!config.hasProperty("spawns"))
{
final Spawns spawns = new Spawns();
List<String> keys = config.getKeys();
Set<String> keys = config.getKeys(false);
for (String group : keys)
{
Location loc = getFakeLocation(config, group);
@@ -657,7 +658,7 @@ public class EssentialsUpgrade
if (!config.hasProperty("jails"))
{
final com.earth2me.essentials.settings.Jails jails = new com.earth2me.essentials.settings.Jails();
List<String> keys = config.getKeys();
Set<String> keys = config.getKeys(false);
for (String jailName : keys)
{
Location loc = getFakeLocation(config, jailName);