Implement new error handler and bug reporting system
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package de.anura.core;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.API.Money;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -56,8 +56,8 @@ public class FlowerPots {
|
||||
}
|
||||
this.foundCache.put(P, list);
|
||||
this.foundTimestamp.put(P, listTimes);
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error refreshCache(FlowerPots)");
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,31 +88,31 @@ public class FlowerPots {
|
||||
}
|
||||
|
||||
public void playerFoundPot(Player P, Integer pot) {
|
||||
if (!foundPot(P, pot)) {
|
||||
Integer time = getPotWaitTime(pot);
|
||||
boolean alreadyFound = foundCache.get(P).containsKey(pot);
|
||||
int type = 0;
|
||||
if (time == -1) {
|
||||
foundCache.get(P).put(pot, false);
|
||||
} else {
|
||||
type = 1;
|
||||
foundCache.get(P).put(pot, true);
|
||||
foundTimestamp.get(P).put(pot, (int) (System.currentTimeMillis() / 1000));
|
||||
}
|
||||
String sql;
|
||||
if (alreadyFound) {
|
||||
sql = "UPDATE coreFoundPots SET timestamp = '" + (System.currentTimeMillis() / 1000) + "', type = 1 WHERE player = (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "') AND id = '" + pot + "'";
|
||||
} else {
|
||||
sql = "INSERT INTO coreFoundPots(id, player, timestamp, type) VALUES('" + pot + "', (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "'),'" + (int) (System.currentTimeMillis() / 1000) + "'," + type + ")";
|
||||
}
|
||||
AnuraCore.getSql().queryUpdate(sql);
|
||||
Location loc = AnuraCore.getInstance().flowerPots.get(pot);
|
||||
for (int i = 0; i < 20; i++) {
|
||||
loc.getWorld().playEffect(loc, Effect.FIREWORKS_SPARK, 4);
|
||||
}
|
||||
P.playSound(loc, Sound.LEVEL_UP, 1, (float) 1.5);
|
||||
ResultSet rs = AnuraCore.getSql().querySelect("SELECT url, name, money FROM corePots WHERE id = '" + pot + "'");
|
||||
try {
|
||||
try {
|
||||
if (!foundPot(P, pot)) {
|
||||
Integer time = getPotWaitTime(pot);
|
||||
boolean alreadyFound = foundCache.get(P).containsKey(pot);
|
||||
int type = 0;
|
||||
if (time == -1) {
|
||||
foundCache.get(P).put(pot, false);
|
||||
} else {
|
||||
type = 1;
|
||||
foundCache.get(P).put(pot, true);
|
||||
foundTimestamp.get(P).put(pot, (int) (System.currentTimeMillis() / 1000));
|
||||
}
|
||||
String sql;
|
||||
if (alreadyFound) {
|
||||
sql = "UPDATE coreFoundPots SET timestamp = '" + (System.currentTimeMillis() / 1000) + "', type = 1 WHERE player = (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "') AND id = '" + pot + "'";
|
||||
} else {
|
||||
sql = "INSERT INTO coreFoundPots(id, player, timestamp, type) VALUES('" + pot + "', (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "'),'" + (int) (System.currentTimeMillis() / 1000) + "'," + type + ")";
|
||||
}
|
||||
AnuraCore.getSql().queryUpdate(sql);
|
||||
Location loc = AnuraCore.getInstance().flowerPots.get(pot);
|
||||
for (int i = 0; i < 20; i++) {
|
||||
loc.getWorld().playEffect(loc, Effect.FIREWORKS_SPARK, 4);
|
||||
}
|
||||
P.playSound(loc, Sound.LEVEL_UP, 1, (float) 1.5);
|
||||
ResultSet rs = AnuraCore.getSql().querySelect("SELECT url, name, money FROM corePots WHERE id = '" + pot + "'");
|
||||
rs.first();
|
||||
Money.payMoney(P, rs.getInt("money"));
|
||||
P.sendMessage(ChatColor.RED + "---------- " + ChatColor.YELLOW + "Achievement" + ChatColor.RED + " ----------");
|
||||
@@ -120,30 +120,30 @@ public class FlowerPots {
|
||||
P.sendMessage("" + ChatColor.GOLD + ChatColor.UNDERLINE + rs.getString("url"));
|
||||
P.sendMessage("");
|
||||
P.sendMessage(ChatColor.RED + "---------- " + ChatColor.YELLOW + "Achievement" + ChatColor.RED + " ----------");
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error playerFoundPot(FlowerPot)");
|
||||
}
|
||||
} else if (getPotWaitTime(pot) != -1 && foundCache.containsKey(P) && foundCache.get(P).containsKey(pot) && foundTimestamp.containsKey(P) && foundTimestamp.get(P).containsKey(pot)) {
|
||||
int current = (int) (System.currentTimeMillis() / 1000);
|
||||
int found = foundTimestamp.get(P).get(pot);
|
||||
int waitTime = getPotWaitTime(pot);
|
||||
int toWait = (found + waitTime) - current;
|
||||
if (toWait <= 0) {
|
||||
return;
|
||||
}
|
||||
String text = ChatColor.RED + Core.getl("ach_wait_1", P);
|
||||
if (toWait < 60) {
|
||||
text += " " + ChatColor.GREEN + toWait + " " + ChatColor.RED + Core.getl("ach_wait_seconds", P);
|
||||
} else if (toWait < 60 * 60) {
|
||||
text += " " + ChatColor.GREEN + Math.round(toWait / 60) + " " + ChatColor.RED + Core.getl("ach_wait_minutes", P);
|
||||
} else if (toWait < 60 * 60 * 24) {
|
||||
text += " " + ChatColor.GREEN + Math.round(toWait / 60 / 60) + " " + ChatColor.RED + Core.getl("ach_wait_hours", P);
|
||||
} else {
|
||||
text += " " + ChatColor.GREEN + Math.round(toWait / 60 / 60 / 24) + " " + ChatColor.RED + Core.getl("ach_wait_days", P);
|
||||
}
|
||||
text += " " + Core.getl("ach_wait_2", P);
|
||||
} else if (getPotWaitTime(pot) != -1 && foundCache.containsKey(P) && foundCache.get(P).containsKey(pot) && foundTimestamp.containsKey(P) && foundTimestamp.get(P).containsKey(pot)) {
|
||||
int current = (int) (System.currentTimeMillis() / 1000);
|
||||
int found = foundTimestamp.get(P).get(pot);
|
||||
int waitTime = getPotWaitTime(pot);
|
||||
int toWait = (found + waitTime) - current;
|
||||
if (toWait <= 0) {
|
||||
return;
|
||||
}
|
||||
String text = ChatColor.RED + Core.getl("ach_wait_1", P);
|
||||
if (toWait < 60) {
|
||||
text += " " + ChatColor.GREEN + toWait + " " + ChatColor.RED + Core.getl("ach_wait_seconds", P);
|
||||
} else if (toWait < 60 * 60) {
|
||||
text += " " + ChatColor.GREEN + Math.round(toWait / 60) + " " + ChatColor.RED + Core.getl("ach_wait_minutes", P);
|
||||
} else if (toWait < 60 * 60 * 24) {
|
||||
text += " " + ChatColor.GREEN + Math.round(toWait / 60 / 60) + " " + ChatColor.RED + Core.getl("ach_wait_hours", P);
|
||||
} else {
|
||||
text += " " + ChatColor.GREEN + Math.round(toWait / 60 / 60 / 24) + " " + ChatColor.RED + Core.getl("ach_wait_days", P);
|
||||
}
|
||||
text += " " + Core.getl("ach_wait_2", P);
|
||||
|
||||
P.sendMessage(text);
|
||||
P.sendMessage(text);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user