Fixed Bugs

This commit is contained in:
Eric 2015-09-08 12:59:34 +02:00
parent cfa719ef37
commit 207b249019
7 changed files with 22 additions and 14 deletions

View File

@ -2,7 +2,7 @@
name: ShopChest name: ShopChest
main: de.epiceric.shopchest.ShopChest main: de.epiceric.shopchest.ShopChest
version: 1.5.3 version: 1.5.4
author: EpicEric author: EpicEric
website: https://www.spigotmc.org/resources/shopchest.11431/ website: https://www.spigotmc.org/resources/shopchest.11431/
depend: [Vault] depend: [Vault]

View File

@ -83,6 +83,7 @@ public class ShopChest extends JavaPlugin{
return perm != null; return perm != null;
} }
@Override @Override
public void onEnable() { public void onEnable() {
@ -107,6 +108,9 @@ public class ShopChest extends JavaPlugin{
logger.severe("Could not submit stats."); logger.severe("Could not submit stats.");
} }
reloadConfig();
saveDefaultConfig();
sqlite = new SQLite(this); sqlite = new SQLite(this);
sqlite.load(); sqlite.load();
@ -137,8 +141,7 @@ public class ShopChest extends JavaPlugin{
setupPermissions(); setupPermissions();
instance = this; instance = this;
reloadConfig();
saveDefaultConfig();
UpdateChecker uc = new UpdateChecker(this, getDescription().getWebsite()); UpdateChecker uc = new UpdateChecker(this, getDescription().getWebsite());
logger.info("Checking for Updates"); logger.info("Checking for Updates");
@ -206,7 +209,7 @@ public class ShopChest extends JavaPlugin{
int count = 0; int count = 0;
for (int id = 1; id < sqlite.getCount() + 1; id++) { for (int id = 1; id < sqlite.getHighestID() + 1; id++) {
try { try {
Shop shop = sqlite.getShop(id); Shop shop = sqlite.getShop(id);

View File

@ -36,7 +36,7 @@ public class Utils_R1 extends Utils {
int count = 0; int count = 0;
for (int id = 1; id < ShopChest.sqlite.getCount() + 1; id++) { for (int id = 1; id < ShopChest.sqlite.getHighestID() + 1; id++) {
try { try {
Shop shop = ShopChest.sqlite.getShop(id); Shop shop = ShopChest.sqlite.getShop(id);

View File

@ -37,7 +37,7 @@ public class Utils_R2 extends Utils {
int count = 0; int count = 0;
for (int id = 1; id < ShopChest.sqlite.getCount() + 1; id++) { for (int id = 1; id < ShopChest.sqlite.getHighestID() + 1; id++) {
try { try {
Shop shop = ShopChest.sqlite.getShop(id); Shop shop = ShopChest.sqlite.getShop(id);

View File

@ -36,7 +36,7 @@ public class Utils_R3 extends Utils {
int count = 0; int count = 0;
for (int id = 1; id < ShopChest.sqlite.getCount() + 1; id++) { for (int id = 1; id < ShopChest.sqlite.getHighestID() + 1; id++) {
try { try {
Shop shop = ShopChest.sqlite.getShop(id); Shop shop = ShopChest.sqlite.getShop(id);

View File

@ -101,6 +101,11 @@ public class Shop {
} }
} else { } else {
try {
throw new Exception("No Chest found at specified Location: " + b.getX() + "; " + b.getY() + "; " + b.getZ());
} catch (Exception e) {
e.printStackTrace();
}
return; return;
} }

View File

@ -54,25 +54,25 @@ public abstract class Database {
} }
public int getNextFreeID() { public int getNextFreeID() {
for (int i = 1; i < getCount() + 1; i++) { for (int i = 1; i < getHighestID() + 1; i++) {
if (getProduct(i) == null) { if (getProduct(i) == null) {
return i; return i;
} else { } else {
if (i == getCount()) { if (i == getHighestID()) {
return i + 1; return i + 1;
} }
} }
} }
return 0; return 1;
} }
public int getCount() { public int getHighestID() {
Connection conn = null; Connection conn = null;
PreparedStatement ps = null; PreparedStatement ps = null;
ResultSet rs = null; ResultSet rs = null;
int highestID = 0; int highestID = 1;
try { try {
conn = getSQLConnection(); conn = getSQLConnection();
ps = conn.prepareStatement("SELECT * FROM " + table + ";"); ps = conn.prepareStatement("SELECT * FROM " + table + ";");
@ -97,13 +97,13 @@ public abstract class Database {
plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionClose(), ex); plugin.getLogger().log(Level.SEVERE, Errors.sqlConnectionClose(), ex);
} }
} }
return -1; return 0;
} }
public int getShopID(Shop shop) { public int getShopID(Shop shop) {
for (int i = 1; i < getCount() + 1; i++) { for (int i = 1; i < getHighestID() + 1; i++) {
try { try {
Shop s = getShop(i); Shop s = getShop(i);