Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Poslovitch committed Dec 2, 2018
2 parents ae770b3 + 68ec5e4 commit 0ead1a1
Show file tree
Hide file tree
Showing 7 changed files with 335 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
<version>0.15.0</version>
<version>0.16.0-SNAPSHOT</version>

<name>BentoBox</name>
<description>BentoBox is an expandable Minecraft Spigot plugin for island-type games like ASkyBlock or AcidIsland.</description>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/world/bentobox/bentobox/database/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ public T loadObject(String uniqueId) {
try {
result = handler.loadObject(uniqueId);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| ClassNotFoundException | IntrospectionException | NoSuchMethodException | SecurityException e) {
| ClassNotFoundException | IntrospectionException | SecurityException e) {
logger.severe(() -> "Could not load object from database! " + e.getMessage());
} catch (NoSuchMethodException e) {
logger.severe(() -> "Could not load object from database! " + e.getMessage());
logger.severe(() -> "Did you forget the JavaBean no-arg default constructor?");
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,27 +491,38 @@ private Object deserialize(Object value, Class<?> clazz) {
return Long.valueOf((Integer) value);
}
if (value.getClass().equals(String.class)) {
return deserializeGenericTypes((String) value, clazz);
if (clazz.equals(Integer.class)) {
return Integer.valueOf((String) value);
}
if (clazz.equals(Long.class)) {
return Long.valueOf((String) value);
}
if (clazz.equals(Double.class)) {
return Double.valueOf((String) value);
}
if (clazz.equals(Float.class)) {
return Float.valueOf((String) value);
}
}
if (clazz.equals(UUID.class)) {
return UUID.fromString((String)value);
value = UUID.fromString((String)value);
}
// Bukkit Types
if (clazz.equals(Location.class)) {
// Get Location from String - may be null...
return Util.getLocationString(((String)value));
value = Util.getLocationString(((String)value));
}
if (clazz.equals(World.class)) {
// Get world by name - may be null...
return plugin.getServer().getWorld((String)value);
value = plugin.getServer().getWorld((String)value);
}
// Enums
if (Enum.class.isAssignableFrom(clazz)) {
//Custom enums are a child of the Enum class.
// Find out the value
Class<Enum> enumClass = (Class<Enum>)clazz;
try {
return Enum.valueOf(enumClass, (String)value);
value = Enum.valueOf(enumClass, ((String)value).toUpperCase());
} catch (Exception e) {
// This value does not exist - probably admin typed it wrongly
// Show what is available and pick one at random
Expand All @@ -520,28 +531,12 @@ private Object deserialize(Object value, Class<?> clazz) {
for (Field fields : enumClass.getFields()) {
plugin.logError(fields.getName());
}
value = null;
}
}
// Could not deserialize the value.
return value;
}

private Object deserializeGenericTypes(String value, Class<?> clazz) {
if (clazz.equals(Integer.class)) {
return Integer.valueOf(value);
}
if (clazz.equals(Long.class)) {
return Long.valueOf(value);
}
if (clazz.equals(Double.class)) {
return Double.valueOf(value);
}
if (clazz.equals(Float.class)) {
return Float.valueOf(value);
}
return null;
}

/* (non-Javadoc)
* @see world.bentobox.bentobox.database.AbstractDatabaseHandler#deleteObject(java.lang.Object)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class BreedingListener extends FlagListener {
Material.EGG,
Material.WHEAT,
Material.CARROT,
Material.WHEAT_SEEDS);
Material.WHEAT_SEEDS,
Material.SEAGRASS);


@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ private YamlConfiguration addonDescription(JarFile jar) throws InvalidAddonForma

private void loadAddon(File f) {
Addon addon;
// try loading the addon
try (JarFile jar = new JarFile(f); AddonClassLoader addonClassLoader = new AddonClassLoader(this, addonDescription(jar), f, this.getClass().getClassLoader())) {
try (JarFile jar = new JarFile(f)) {
// try loading the addon
// Get description in the addon.yml file
YamlConfiguration data = addonDescription(jar);
// Load the addon
AddonClassLoader addonClassLoader = new AddonClassLoader(this, data, f, this.getClass().getClassLoader());
// Get the addon itself
addon = addonClassLoader.getAddon();
// Initialize some settings
Expand Down
Loading

0 comments on commit 0ead1a1

Please sign in to comment.