forked from MagicBane/Server
Refactor of animations
This commit is contained in:
@@ -26,34 +26,6 @@ public class dbItemBaseHandler extends dbHandlerBase {
|
||||
|
||||
}
|
||||
|
||||
public void LOAD_ANIMATIONS(ItemBase itemBase) {
|
||||
|
||||
ArrayList<Integer> tempList = new ArrayList<>();
|
||||
ArrayList<Integer> tempListOff = new ArrayList<>();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_itembase_animations` WHERE `itemBaseUUID` = ?")) {
|
||||
|
||||
preparedStatement.setInt(1, itemBase.getUUID());
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
int animation = rs.getInt("animation");
|
||||
boolean rightHand = rs.getBoolean("rightHand");
|
||||
|
||||
if (rightHand)
|
||||
tempList.add(animation);
|
||||
else
|
||||
tempListOff.add(animation);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
itemBase.setAnimations(tempList);
|
||||
itemBase.setOffHandAnimations(tempListOff);
|
||||
}
|
||||
|
||||
public void LOAD_ALL_ITEMBASES() {
|
||||
|
||||
ItemBase itemBase;
|
||||
|
||||
@@ -982,66 +982,66 @@ public enum CombatManager {
|
||||
if (wb == null)
|
||||
return 75;
|
||||
|
||||
ItemTemplate template = ItemTemplate.itemTemplates.get(wb.getUUID());
|
||||
|
||||
if (mainHand) {
|
||||
if (wb.getAnimations().size() > 0) {
|
||||
if (template.weapon_attack_anim_right.size() > 0) {
|
||||
|
||||
int animation;
|
||||
|
||||
int random = ThreadLocalRandom.current().nextInt(wb.getAnimations().size());
|
||||
int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_right.size());
|
||||
|
||||
try {
|
||||
animation = wb.getAnimations().get(random);
|
||||
animation = template.weapon_attack_anim_right.get(random)[0];
|
||||
return animation;
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
return wb.getAnimations().get(0);
|
||||
return template.weapon_attack_anim_right.get(0)[0];
|
||||
}
|
||||
|
||||
} else if (wb.getOffHandAnimations().size() > 0) {
|
||||
} else if (template.weapon_attack_anim_left.size() > 0) {
|
||||
|
||||
int animation;
|
||||
int random = ThreadLocalRandom.current().nextInt(wb.getOffHandAnimations().size());
|
||||
int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_left.size());
|
||||
|
||||
try {
|
||||
animation = wb.getOffHandAnimations().get(random);
|
||||
animation = template.weapon_attack_anim_left.get(random)[0];
|
||||
return animation;
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
return wb.getOffHandAnimations().get(0);
|
||||
return template.weapon_attack_anim_right.get(0)[0];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (wb.getOffHandAnimations().size() > 0) {
|
||||
if (template.weapon_attack_anim_left.size() > 0) {
|
||||
int animation;
|
||||
int random = ThreadLocalRandom.current().nextInt(wb.getOffHandAnimations().size());
|
||||
int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_left.size());
|
||||
|
||||
try {
|
||||
animation = wb.getOffHandAnimations().get(random);
|
||||
animation = template.weapon_attack_anim_left.get(random)[0];
|
||||
return animation;
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
return wb.getOffHandAnimations().get(0);
|
||||
return template.weapon_attack_anim_right.get(0)[0];
|
||||
|
||||
}
|
||||
} else if (wb.getAnimations().size() > 0) {
|
||||
} else if (template.weapon_attack_anim_left.size() > 0) {
|
||||
|
||||
int animation;
|
||||
int random = ThreadLocalRandom.current().nextInt(wb.getAnimations().size());
|
||||
int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_left.size());
|
||||
|
||||
try {
|
||||
animation = wb.getAnimations().get(random);
|
||||
animation = template.weapon_attack_anim_left.get(random)[0];
|
||||
return animation;
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
return wb.getAnimations().get(0);
|
||||
return template.weapon_attack_anim_right.get(0)[0];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ItemTemplate template = ItemTemplate.itemTemplates.get(wb.getUUID());
|
||||
|
||||
String required = template.item_skill_used;
|
||||
String mastery = wb.getMastery();
|
||||
|
||||
|
||||
@@ -42,8 +42,6 @@ public class ItemBase {
|
||||
private final engine.Enum.SourceType damageType;
|
||||
private boolean isConsumable;
|
||||
private final boolean isStrBased;
|
||||
private ArrayList<Integer> animations = new ArrayList<>();
|
||||
private ArrayList<Integer> offHandAnimations = new ArrayList<>();
|
||||
|
||||
public ItemBase(ResultSet rs) throws SQLException {
|
||||
|
||||
@@ -84,12 +82,6 @@ public class ItemBase {
|
||||
this.isConsumable = true;
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
DbManager.ItemBaseQueries.LOAD_ANIMATIONS(this);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
}
|
||||
initializeHashes();
|
||||
|
||||
}
|
||||
@@ -204,7 +196,6 @@ public class ItemBase {
|
||||
public short getMinDamage() {
|
||||
return minDamage;
|
||||
}
|
||||
|
||||
public Enum.SourceType getDamageType() {
|
||||
return damageType;
|
||||
}
|
||||
@@ -213,20 +204,4 @@ public class ItemBase {
|
||||
return percentRequired;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getAnimations() {
|
||||
return animations;
|
||||
}
|
||||
|
||||
public void setAnimations(ArrayList<Integer> animations) {
|
||||
this.animations = animations;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getOffHandAnimations() {
|
||||
return offHandAnimations;
|
||||
}
|
||||
|
||||
public void setOffHandAnimations(ArrayList<Integer> offHandAnimations) {
|
||||
this.offHandAnimations = offHandAnimations;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user