Fixed enchantments -.-

This commit is contained in:
Acrobot 2012-10-28 23:53:26 +01:00
parent 60c291da03
commit b0a04c42cc
3 changed files with 70 additions and 2 deletions

View File

@ -0,0 +1,51 @@
package com.Acrobot.Breeze.Database;
import com.google.common.base.Joiner;
import javax.persistence.Entity;
import java.lang.annotation.AnnotationFormatError;
import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.List;
/**
* Parses an entity (class with database fields)
*
* @author Acrobot
*/
public class EntityParser {
private Class entity;
public EntityParser(Class table) {
if (!table.isAnnotationPresent(Entity.class) || !table.isAnnotationPresent(javax.persistence.Table.class)) {
throw new AnnotationFormatError("The class hasn't got Entity or Table annotation!");
}
entity = table;
}
/**
* Parses the class' fields to a standard SQL format
*
* @return SQLed class
*/
public String parseToString() {
List<String> fields = new LinkedList<String>();
for (Field field : entity.getDeclaredFields()) {
fields.add(convertToSQL(field));
}
return Joiner.on(',').join(fields);
}
/**
* Converts a field type to SQL type
*
* @param field Java's field
* @return SQL type
*/
public String convertToSQL(Field field) {
return null;
}
}

View File

@ -241,13 +241,16 @@ public class MaterialUtil {
* @return Enchantments found
*/
public static Map<org.bukkit.enchantments.Enchantment, Integer> getEnchantments(String base32) {
<<<<<<< HEAD
if (base32 == null || base32.isEmpty() || NumberUtil.isLong(base32)) {
=======
if (base32 == null || base32.isEmpty() || !NumberUtil.isEnchantment(base32)) {
>>>>>>> Fixed enchantments -.-
return new HashMap<org.bukkit.enchantments.Enchantment, Integer>();
}
Map<org.bukkit.enchantments.Enchantment, Integer> map = new HashMap<org.bukkit.enchantments.Enchantment, Integer>();
StringBuilder number = new StringBuilder(Long.toString(Long.parseLong(base32, 32)));
Map<org.bukkit.enchantments.Enchantment, Integer> map = new HashMap<org.bukkit.enchantments.Enchantment, Integer>();
while (number.length() % 3 != 0) {
number.insert(0, '0');

View File

@ -0,0 +1,14 @@
package com.Acrobot.ChestShop.Commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
/**
* @author Acrobot
*/
public class DatabaseCommand implements CommandExecutor {
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
return true;//TODO OOO
}
}