1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-16 11:37:30 +02:00

Formatting.

Signed-off-by: Paul Buonopane <techsoftadvanced@gmail.com>
This commit is contained in:
Paul Buonopane
2012-02-23 12:24:46 -05:00
parent 9b25a25e91
commit 53c9265800
5 changed files with 34 additions and 31 deletions

View File

@@ -1,4 +1,3 @@
package com.earth2me.essentials.storage;
import com.earth2me.essentials.api.IReload;
@@ -7,18 +6,17 @@ import java.io.File;
import java.util.Set;
interface IStorageObjectMap<I> extends IReload
{
boolean objectExists(final String name);
I getObject(final String name);
void removeObject(final String name) throws InvalidNameException;
Set<String> getAllKeys();
int getKeySize();
File getStorageFile(final String name) throws InvalidNameException;
}

View File

@@ -3,5 +3,5 @@ package com.earth2me.essentials.storage;
public interface IStorageReader
{
<T extends StorageObject> T load(final Class<? extends T> clazz) throws ObjectLoadException;
<T extends StorageObject> T load(final Class<? extends T> clazz) throws ObjectLoadException;
}

View File

@@ -38,7 +38,7 @@ public class Location
this.yaw = yaw;
this.pitch = pitch;
}
public Location(String worldname, double x, double y, double z)
{
this.worldname = worldname;
@@ -56,13 +56,16 @@ public class Location
if (loc == null)
{
World world = null;
if (worldUID != null) {
if (worldUID != null)
{
world = Bukkit.getWorld(worldUID);
}
if (world == null) {
if (world == null)
{
world = Bukkit.getWorld(worldname);
}
if (world == null) {
if (world == null)
{
throw new WorldNotLoadedException(worldname);
}
loc = new org.bukkit.Location(world, getX(), getY(), getZ(), getYaw(), getPitch());
@@ -100,12 +103,13 @@ public class Location
{
return pitch;
}
public static class WorldNotLoadedException extends Exception
{
public WorldNotLoadedException(String worldname)
{
super("World "+worldname+" is not loaded.");
super("World " + worldname + " is not loaded.");
}
}
}

View File

@@ -45,7 +45,8 @@ public class YamlStorageReader implements IStorageReader
try
{
T object = (T)yaml.load(reader);
if (object == null) {
if (object == null)
{
object = clazz.newInstance();
}
return object;

View File

@@ -23,12 +23,12 @@ public class YamlStorageWriter implements IStorageWriter
private transient static final Pattern NON_WORD_PATTERN = Pattern.compile("\\W");
private transient final PrintWriter writer;
private transient static final Yaml YAML = new Yaml();
public YamlStorageWriter(final PrintWriter writer)
{
this.writer = writer;
}
@Override
public void save(final StorageObject object)
{
@@ -45,7 +45,7 @@ public class YamlStorageWriter implements IStorageWriter
Logger.getLogger(YamlStorageWriter.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void writeToFile(final Object object, final int depth, final Class clazz) throws IllegalAccessException
{
for (Field field : clazz.getDeclaredFields())
@@ -54,7 +54,7 @@ public class YamlStorageWriter implements IStorageWriter
if (Modifier.isPrivate(modifier) && !Modifier.isTransient(modifier) && !Modifier.isStatic(modifier))
{
field.setAccessible(true);
final Object data = field.get(object);
if (writeKey(field, depth, data))
{
@@ -85,7 +85,7 @@ public class YamlStorageWriter implements IStorageWriter
}
}
}
private boolean writeKey(final Field field, final int depth, final Object data)
{
final boolean commentPresent = writeComment(field, depth);
@@ -109,7 +109,7 @@ public class YamlStorageWriter implements IStorageWriter
}
return false;
}
private boolean writeComment(final Field field, final int depth)
{
final boolean commentPresent = field.isAnnotationPresent(Comment.class);
@@ -131,7 +131,7 @@ public class YamlStorageWriter implements IStorageWriter
}
return commentPresent;
}
private void writeCollection(final Collection<Object> data, final int depth) throws IllegalAccessException
{
writer.println();
@@ -162,7 +162,7 @@ public class YamlStorageWriter implements IStorageWriter
}
writer.println();
}
private void writeMap(final Map<Object, Object> data, final int depth) throws IllegalArgumentException, IllegalAccessException
{
writer.println();
@@ -199,7 +199,7 @@ public class YamlStorageWriter implements IStorageWriter
}
}
}
private void writeIndention(final int depth)
{
for (int i = 0; i < depth; i++)
@@ -207,7 +207,7 @@ public class YamlStorageWriter implements IStorageWriter
writer.print(" ");
}
}
private void writeScalar(final Object data)
{
if (data instanceof String || data instanceof Boolean || data instanceof Number)
@@ -247,7 +247,7 @@ public class YamlStorageWriter implements IStorageWriter
throw new UnsupportedOperationException();
}
}
private void writeKey(final Object data)
{
if (data instanceof String || data instanceof Boolean || data instanceof Number)
@@ -285,12 +285,12 @@ public class YamlStorageWriter implements IStorageWriter
throw new UnsupportedOperationException();
}
}
private void writeMaterial(final Object data)
{
writer.print(data.toString().toLowerCase(Locale.ENGLISH));
}
private void writeMaterialData(final Object data)
{
final MaterialData matData = (MaterialData)data;
@@ -301,7 +301,7 @@ public class YamlStorageWriter implements IStorageWriter
writer.print(matData.getData());
}
}
private void writeItemStack(final Object data)
{
final ItemStack itemStack = (ItemStack)data;
@@ -314,7 +314,7 @@ public class YamlStorageWriter implements IStorageWriter
writeEnchantmentLevel(entry);
}
}
private void writeEnchantmentLevel(Object data)
{
final Entry<Enchantment, Integer> enchLevel = (Entry<Enchantment, Integer>)data;
@@ -322,7 +322,7 @@ public class YamlStorageWriter implements IStorageWriter
writer.print(':');
writer.print(enchLevel.getValue());
}
private void writeLocation(final Location entry, final int depth)
{
writer.println();