Skip to content

Commit

Permalink
Ready for first release.
Browse files Browse the repository at this point in the history
  • Loading branch information
HmmmQuestionMark committed Mar 18, 2014
1 parent 11920a6 commit b685fec
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Demigods-Engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Demigods-Parent</artifactId>
<groupId>com.demigodsrpg</groupId>
<version>dev-y14m3d18r1</version>
<version>ea-14.3.18.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ public boolean saveDataToFile()
}

@Override
public final V valueFromData(Object... data)
public final V valueFromData(String ignored, ConfigurationSection conf)
{
if(data == null || data.length < 1 || !(data[0] instanceof ConfigurationSection)) return null;
return valueFromData((ConfigurationSection) data[0]);
return valueFromData(conf);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @param <V> Value type.
*/
@SuppressWarnings({ "unchecked", "SuspiciousMethodCalls" })
public abstract class TieredGenericYamlFile<K extends Comparable, V extends DataSerializable> extends YamlConvertible implements YamlFile
public abstract class TieredGenericYamlFile<K extends Comparable, V extends DataSerializable> extends YamlConvertible<K, V> implements YamlFile
{
/**
* Serialize the data for a specific key (from the loaded data).
Expand Down Expand Up @@ -66,7 +66,7 @@ public ConcurrentMap<K, V> getCurrentFileData()
{
try
{
map.put((K) keyFromString(stringId), valueFromData(keyFromString(stringId), data.getConfigurationSection(stringId)));
map.put(keyFromString(stringId), valueFromData(stringId, data.getConfigurationSection(stringId)));
}
catch(Exception ignored)
{}
Expand Down Expand Up @@ -108,22 +108,8 @@ public boolean apply(K key)
}

@Override
public final V valueFromData(Object... data)
public V valueFromData(String key, ConfigurationSection conf)
{
if(data == null || data.length < 3 || !isK(data[0]) || !(data[1] instanceof ConfigurationSection)) return null;
return valueFromData((K) data[0], (ConfigurationSection) data[1]);
}

private boolean isK(Object o)
{
// Check if the given object is indeed of type K.
try
{
K k = (K) o;
return o.equals(k);
}
catch(ClassCastException ignored)
{}
return false;
return valueFromData(keyFromString(key), conf);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.censoredsoftware.library.serializable.DataSerializable;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;

import java.util.Map;
Expand All @@ -28,7 +27,7 @@
* @param <V> Value type.
*/
@SuppressWarnings({ "unchecked", "SuspiciousMethodCalls" })
public abstract class TieredStringConvertableGenericYamlFile<K extends Comparable, V extends DataSerializable> extends YamlConvertible implements YamlFile
public abstract class TieredStringConvertableGenericYamlFile<K extends Comparable, V extends DataSerializable> extends YamlConvertible<K, V> implements YamlFile
{
/**
* Serialize the data for a specific key (from the loaded data).
Expand All @@ -45,15 +44,6 @@ public abstract class TieredStringConvertableGenericYamlFile<K extends Comparabl
*/
public abstract ConcurrentMap<K, V> getLoadedData();

/**
* Convert a single bit of the data (with a given string of the key) to the DataSerializable child class.
*
* @param stringKey The string of the key.
* @param conf A configuration section to be converted.
* @return The converted value.
*/
public abstract V valueFromData(String stringKey, ConfigurationSection conf);

@Override
public ConcurrentMap<K, V> getCurrentFileData()
{
Expand All @@ -66,10 +56,12 @@ public ConcurrentMap<K, V> getCurrentFileData()
{
try
{
map.put((K) keyFromString(stringId), valueFromData(keyFromString(stringId), data.getConfigurationSection(stringId)));
map.put(keyFromString(stringId), valueFromData(stringId, data.getConfigurationSection(stringId)));
}
catch(Exception ignored)
{}
{
ignored.printStackTrace();
}
}
return map;
}
Expand Down Expand Up @@ -106,11 +98,4 @@ public boolean apply(K key)
// Save the file!
return YamlFileUtil.saveFile(getDirectoryPath(), getFullFileName(), currentFile);
}

@Override
public final V valueFromData(Object... data)
{
if(data == null || data.length < 3 || !String.class.isInstance(data[0]) || !ConfigurationSection.class.isInstance(data[1])) return null;
return valueFromData((String) data[0], (ConfigurationSection) data[1]);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.censoredsoftware.library.serializable.yaml;

import org.bukkit.configuration.ConfigurationSection;

/**
* A yaml file that has convertible key-value types.
*
Expand All @@ -19,8 +21,9 @@ public abstract class YamlConvertible<K, V>
/**
* Convert to a value from a number of objects representing the data.
*
* @param data The provided data objects.
* @param stringKey The string key for the data.
* @param data The provided data object.
* @return The converted value.
*/
public abstract V valueFromData(Object... data);
public abstract V valueFromData(String stringKey, ConfigurationSection data);
}
2 changes: 1 addition & 1 deletion Demigods-Exclusive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Demigods-Parent</artifactId>
<groupId>com.demigodsrpg</groupId>
<version>dev-y14m3d18r1</version>
<version>ea-14.3.18.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion Demigods-Greek/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Demigods-Parent</artifactId>
<groupId>com.demigodsrpg</groupId>
<version>dev-y14m3d18r1</version>
<version>ea-14.3.18.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
17 changes: 17 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
This compiled jar additionally contains the following projects:

- org.mcstats.bukkit:metrics-lite
- SOURCE: https://github.com/Hidendra/Plugin-Metrics/tree/master/mods/bukkit/metrics-lite
- LICENSE (in source): https://github.com/Hidendra/Plugin-Metrics/blob/master/mods/bukkit/metrics-lite/src/main/java/org/mcstats/MetricsLite.java
- org.atteo:evo-inflector
- SOURCE: https://github.com/atteo/evo-inflector
- LICENSE: https://github.com/atteo/evo-inflector/blob/master/LICENSE
- org.jgrapht:jgrapht-core
- SOURCE: https://github.com/jgrapht/jgrapht/tree/master/jgrapht-core
- LICENSE: https://github.com/jgrapht/jgrapht/blob/master/license-EPL.txt
- org.jgrapht:jgrapht-ext
- SOURCE: https://github.com/jgrapht/jgrapht/tree/master/jgrapht-ext
- LICENSE: https://github.com/jgrapht/jgrapht/blob/master/license-EPL.txt
- com.mojang:AccountsClient
- SOURCE: https://github.com/Mojang/AccountsClient
- LICENSE: "This code is provided as a courtesy and feel free to build a client in another language to share with the community."
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.demigodsrpg</groupId>
<artifactId>Demigods-Parent</artifactId>
<packaging>pom</packaging>
<version>dev-y14m3d18r1</version>
<version>ea-14.3.18.1</version>
<modules>
<module>Demigods-Engine</module>
<module>Demigods-Greek</module>
Expand Down

0 comments on commit b685fec

Please sign in to comment.