mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-23 18:45:31 +01:00
Fixed enchantments -.-
This commit is contained in:
parent
60c291da03
commit
b0a04c42cc
51
com/Acrobot/Breeze/Database/EntityParser.java
Normal file
51
com/Acrobot/Breeze/Database/EntityParser.java
Normal 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;
|
||||
}
|
||||
}
|
@ -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');
|
||||
|
14
com/Acrobot/ChestShop/Commands/DatabaseCommand.java
Normal file
14
com/Acrobot/ChestShop/Commands/DatabaseCommand.java
Normal 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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user