Some bug fixes
This commit is contained in:
@@ -126,7 +126,7 @@ public class Core {
|
|||||||
Player p = (Player) P;
|
Player p = (Player) P;
|
||||||
if (!Core.cachedPlayerLanguage.containsKey(p)) {
|
if (!Core.cachedPlayerLanguage.containsKey(p)) {
|
||||||
ResultSet rs = Core.getMySql().querySelect("SELECT lang FROM players WHERE uuid = '" + p.getUniqueId().toString() + "'");
|
ResultSet rs = Core.getMySql().querySelect("SELECT lang FROM players WHERE uuid = '" + p.getUniqueId().toString() + "'");
|
||||||
if (!rs.next()) {
|
if (rs == null || !rs.next()) {
|
||||||
//This is a weird bug
|
//This is a weird bug
|
||||||
Core.cachedPlayerLanguage.put(p, "de");
|
Core.cachedPlayerLanguage.put(p, "de");
|
||||||
return "de";
|
return "de";
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ import java.sql.ResultSet;
|
|||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Errors {
|
public class Errors {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports an exception to the database
|
* Reports an exception to the database
|
||||||
|
*
|
||||||
* @param exc A Throwable to get the error data from
|
* @param exc A Throwable to get the error data from
|
||||||
* @param info Some additional info
|
* @param info Some additional info
|
||||||
*/
|
*/
|
||||||
@@ -19,6 +21,7 @@ public class Errors {
|
|||||||
exc.printStackTrace();
|
exc.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(Core.getMainClass(), () -> {
|
||||||
try {
|
try {
|
||||||
String message = exc.getLocalizedMessage();
|
String message = exc.getLocalizedMessage();
|
||||||
String name = exc.getClass().toString();
|
String name = exc.getClass().toString();
|
||||||
@@ -30,7 +33,7 @@ public class Errors {
|
|||||||
int id = rs.getInt("id");
|
int id = rs.getInt("id");
|
||||||
String elemSql = "INSERT INTO coreErrorStack(errorId, className, fileName, methodName, lineNumber, nativeMethod) VALUES";
|
String elemSql = "INSERT INTO coreErrorStack(errorId, className, fileName, methodName, lineNumber, nativeMethod) VALUES";
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for(StackTraceElement elem : exc.getStackTrace()) {
|
for (StackTraceElement elem : exc.getStackTrace()) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
elemSql += ",";
|
elemSql += ",";
|
||||||
} else {
|
} else {
|
||||||
@@ -43,10 +46,12 @@ public class Errors {
|
|||||||
System.err.println("FATAL ERROR: Error handler generated an exception!! (" + ex.getLocalizedMessage() + ")");
|
System.err.println("FATAL ERROR: Error handler generated an exception!! (" + ex.getLocalizedMessage() + ")");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports an exception to the database
|
* Reports an exception to the database
|
||||||
|
*
|
||||||
* @param exc A Throwable to get the error from
|
* @param exc A Throwable to get the error from
|
||||||
*/
|
*/
|
||||||
public static void reportException(Throwable exc) {
|
public static void reportException(Throwable exc) {
|
||||||
@@ -55,14 +60,16 @@ public class Errors {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to report a bug
|
* Method to report a bug
|
||||||
|
*
|
||||||
* @param P The reporter
|
* @param P The reporter
|
||||||
* @param msg A message from the reporter
|
* @param msg A message from the reporter
|
||||||
* @param data An array of error entries generated by {@link make(String, Object)}
|
* @param data An array of error entries generated by
|
||||||
|
* {@link make(String, Object)}
|
||||||
*/
|
*/
|
||||||
public static void bugReport(Player P, String msg, Entry<String, Object>... data) {
|
public static void bugReport(Player P, String msg, Entry<String, Object>... data) {
|
||||||
UUID uuid = P.getUniqueId();
|
UUID uuid = P.getUniqueId();
|
||||||
String dataText = "";
|
String dataText = "";
|
||||||
for(Entry<String, Object> date : data) {
|
for (Entry<String, Object> date : data) {
|
||||||
dataText += date.getKey() + ":" + date.getValue().toString() + ";";
|
dataText += date.getKey() + ":" + date.getValue().toString() + ";";
|
||||||
}
|
}
|
||||||
Core.getMySql().queryUpdate("INSERT INTO serverBugs(player, msg, data, timestamp) VALUES ((SELECT id FROM players WHERE uuid = '" + uuid.toString() + "'), '" + Core.getMySql().escapeString(msg) + "', '" + dataText + "', '" + System.currentTimeMillis() / 1000 + "')");
|
Core.getMySql().queryUpdate("INSERT INTO serverBugs(player, msg, data, timestamp) VALUES ((SELECT id FROM players WHERE uuid = '" + uuid.toString() + "'), '" + Core.getMySql().escapeString(msg) + "', '" + dataText + "', '" + System.currentTimeMillis() / 1000 + "')");
|
||||||
@@ -70,6 +77,7 @@ public class Errors {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates an error entry
|
* Generates an error entry
|
||||||
|
*
|
||||||
* @param key The key for this object
|
* @param key The key for this object
|
||||||
* @param value Any object to use as value
|
* @param value Any object to use as value
|
||||||
* @return The error entry to give to
|
* @return The error entry to give to
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ public class Setup {
|
|||||||
Data.sittingPlayer.put(p, a);
|
Data.sittingPlayer.put(p, a);
|
||||||
}
|
}
|
||||||
}, 600, 600);
|
}, 600, 600);
|
||||||
Bukkit.getScheduler().runTaskTimerAsynchronously(Core.getMainClass(), AnuraCore.signs::updateServerSigns, 20 * 5, 20 * 5);
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(Core.getMainClass(), AnuraCore.signs::updateServerSigns, 20 * 5, 20 * 5);
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Core.getMainClass(), new VillagerTask(), 20, 20);
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(Core.getMainClass(), new VillagerTask(), 20, 20);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Errors.reportException(e);
|
Errors.reportException(e);
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ public class Signs implements PluginMessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ResultSet rs = Core.getMySql().querySelect("SELECT DISTINCT value FROM coreWarpSigns WHERE type = 'server' AND server = '" + Core.getMainClass().getConfig().getString("server-name") + "'");
|
ResultSet rs = Core.getMySql().querySelect("SELECT DISTINCT value FROM coreWarpSigns WHERE type = 'server' AND server = '" + Core.getMainClass().getConfig().getString("server-name") + "'");
|
||||||
rs.last();
|
if (rs == null || !rs.first()) {
|
||||||
if (rs.getRow() == 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rs.beforeFirst();
|
rs.beforeFirst();
|
||||||
@@ -105,7 +104,8 @@ public class Signs implements PluginMessageListener {
|
|||||||
|
|
||||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
||||||
String subchannel = in.readUTF();
|
String subchannel = in.readUTF();
|
||||||
if (subchannel.equals("PlayerCount")) {
|
switch (subchannel) {
|
||||||
|
case "PlayerCount":
|
||||||
String server = in.readUTF();
|
String server = in.readUTF();
|
||||||
int playercount = in.readInt();
|
int playercount = in.readInt();
|
||||||
String sqlQ = "SELECT X,Y,Z,world FROM coreWarpSigns WHERE server = '" + Core.getMainClass().getConfig().getString("server-name") + "' AND type = 'server' AND value = '" + server + "'";
|
String sqlQ = "SELECT X,Y,Z,world FROM coreWarpSigns WHERE server = '" + Core.getMainClass().getConfig().getString("server-name") + "' AND type = 'server' AND value = '" + server + "'";
|
||||||
@@ -113,8 +113,7 @@ public class Signs implements PluginMessageListener {
|
|||||||
rs.last();
|
rs.last();
|
||||||
if (rs.getRow() == 0) {
|
if (rs.getRow() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
} rs.beforeFirst();
|
||||||
rs.beforeFirst();
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
Boolean remove = false;
|
Boolean remove = false;
|
||||||
World w = Bukkit.getWorld(rs.getString("world"));
|
World w = Bukkit.getWorld(rs.getString("world"));
|
||||||
@@ -157,10 +156,11 @@ public class Signs implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
s.update();
|
s.update();
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
} else if (subchannel.equals("updatePermissions")) {
|
case "updatePermissions":
|
||||||
AnuraCore.perms.reload();
|
AnuraCore.perms.reload();
|
||||||
AnuraCore.perms.updateAllPlayers();
|
AnuraCore.perms.updateAllPlayers();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Errors.reportException(e);
|
Errors.reportException(e);
|
||||||
|
|||||||
@@ -180,10 +180,15 @@ public class TeamCommands implements CommandExecutor {
|
|||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
if (Float.parseFloat(args[0]) >= 10 || Float.parseFloat(args[0]) < 0) {
|
if (Float.parseFloat(args[0]) >= 10 || Float.parseFloat(args[0]) < 0) {
|
||||||
Core.statusMsg(P, "flyspeed_wrong_number", false);
|
Core.statusMsg(P, "flyspeed_wrong_number", false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
Core.statusMsg(P, "flyspeed_wrong_number", false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
P.setFlySpeed(Float.parseFloat(args[0]) / 10);
|
P.setFlySpeed(Float.parseFloat(args[0]) / 10);
|
||||||
Tools.sendStatusMsg(P, Core.getl("flyspeed_set_1", P) + " " + args[0] + Core.getl("flyspeed_set_2", P), true);
|
Tools.sendStatusMsg(P, Core.getl("flyspeed_set_1", P) + " " + args[0] + Core.getl("flyspeed_set_2", P), true);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user