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,34 +21,37 @@ public class Errors {
|
|||||||
exc.printStackTrace();
|
exc.printStackTrace();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
Bukkit.getScheduler().runTaskAsynchronously(Core.getMainClass(), () -> {
|
||||||
String message = exc.getLocalizedMessage();
|
try {
|
||||||
String name = exc.getClass().toString();
|
String message = exc.getLocalizedMessage();
|
||||||
String server = Core.getMainClass() == null ? "~not available~" : Core.getMainClass().getConfig().getString("server-name");
|
String name = exc.getClass().toString();
|
||||||
String errorSql = "INSERT INTO coreErrors (server, exception, msg, info, timestamp) VALUES('" + server + "', '" + name + "', '" + Core.getMySql().escapeString(message) + "', '" + info + "', '" + System.currentTimeMillis() / 1000 + "')";
|
String server = Core.getMainClass() == null ? "~not available~" : Core.getMainClass().getConfig().getString("server-name");
|
||||||
Core.getMySql().queryUpdate(errorSql);
|
String errorSql = "INSERT INTO coreErrors (server, exception, msg, info, timestamp) VALUES('" + server + "', '" + name + "', '" + Core.getMySql().escapeString(message) + "', '" + info + "', '" + System.currentTimeMillis() / 1000 + "')";
|
||||||
ResultSet rs = Core.getMySql().querySelect("SELECT id FROM coreErrors ORDER BY id DESC LIMIT 1");
|
Core.getMySql().queryUpdate(errorSql);
|
||||||
rs.first();
|
ResultSet rs = Core.getMySql().querySelect("SELECT id FROM coreErrors ORDER BY id DESC LIMIT 1");
|
||||||
int id = rs.getInt("id");
|
rs.first();
|
||||||
String elemSql = "INSERT INTO coreErrorStack(errorId, className, fileName, methodName, lineNumber, nativeMethod) VALUES";
|
int id = rs.getInt("id");
|
||||||
boolean first = true;
|
String elemSql = "INSERT INTO coreErrorStack(errorId, className, fileName, methodName, lineNumber, nativeMethod) VALUES";
|
||||||
for(StackTraceElement elem : exc.getStackTrace()) {
|
boolean first = true;
|
||||||
if (!first) {
|
for (StackTraceElement elem : exc.getStackTrace()) {
|
||||||
elemSql += ",";
|
if (!first) {
|
||||||
} else {
|
elemSql += ",";
|
||||||
first = false;
|
} else {
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
elemSql += "('" + id + "', '" + elem.getClassName() + "', '" + elem.getFileName() + "', '" + elem.getMethodName() + "', '" + elem.getLineNumber() + "', " + elem.isNativeMethod() + ")";
|
||||||
}
|
}
|
||||||
elemSql += "('" + id + "', '" + elem.getClassName() + "', '" + elem.getFileName() + "', '" + elem.getMethodName() + "', '" + elem.getLineNumber() + "', " + elem.isNativeMethod() + ")";
|
Core.getMySql().queryUpdate(elemSql);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
System.err.println("FATAL ERROR: Error handler generated an exception!! (" + ex.getLocalizedMessage() + ")");
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
Core.getMySql().queryUpdate(elemSql);
|
});
|
||||||
} catch (Throwable ex) {
|
|
||||||
System.err.println("FATAL ERROR: Error handler generated an exception!! (" + ex.getLocalizedMessage() + ")");
|
|
||||||
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,62 +104,63 @@ 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) {
|
||||||
String server = in.readUTF();
|
case "PlayerCount":
|
||||||
int playercount = in.readInt();
|
String server = in.readUTF();
|
||||||
String sqlQ = "SELECT X,Y,Z,world FROM coreWarpSigns WHERE server = '" + Core.getMainClass().getConfig().getString("server-name") + "' AND type = 'server' AND value = '" + server + "'";
|
int playercount = in.readInt();
|
||||||
ResultSet rs = Core.getMySql().querySelect(sqlQ);
|
String sqlQ = "SELECT X,Y,Z,world FROM coreWarpSigns WHERE server = '" + Core.getMainClass().getConfig().getString("server-name") + "' AND type = 'server' AND value = '" + server + "'";
|
||||||
rs.last();
|
ResultSet rs = Core.getMySql().querySelect(sqlQ);
|
||||||
if (rs.getRow() == 0) {
|
rs.last();
|
||||||
return;
|
if (rs.getRow() == 0) {
|
||||||
}
|
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"));
|
||||||
BlockState bs = null;
|
BlockState bs = null;
|
||||||
if (w == null) {
|
if (w == null) {
|
||||||
remove = true;
|
|
||||||
} else {
|
|
||||||
Block b = w.getBlockAt(rs.getInt("X"), rs.getInt("Y"), rs.getInt("Z"));
|
|
||||||
if (b == null || !(b.getState() instanceof Sign)) {
|
|
||||||
remove = true;
|
remove = true;
|
||||||
} else {
|
} else {
|
||||||
bs = b.getState();
|
Block b = w.getBlockAt(rs.getInt("X"), rs.getInt("Y"), rs.getInt("Z"));
|
||||||
|
if (b == null || !(b.getState() instanceof Sign)) {
|
||||||
|
remove = true;
|
||||||
|
} else {
|
||||||
|
bs = b.getState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (remove) {
|
||||||
if (remove) {
|
String anotherSQL = "DELETE FROM coreWarpSigns WHERE server = '" + Core.getMainClass().getConfig().getString("server-name") + "' AND type = 'server' AND value = '" + server + "'";
|
||||||
String anotherSQL = "DELETE FROM coreWarpSigns WHERE server = '" + Core.getMainClass().getConfig().getString("server-name") + "' AND type = 'server' AND value = '" + server + "'";
|
Core.getMySql().queryUpdate(anotherSQL);
|
||||||
Core.getMySql().queryUpdate(anotherSQL);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (bs == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (bs instanceof Sign) {
|
|
||||||
Sign s = (Sign) bs;
|
|
||||||
if (s.getLine(3).equalsIgnoreCase(ChatColor.RED + "Offline")) {
|
|
||||||
s.setLine(1, ChatColor.RED + "--" + ChatColor.DARK_GRAY + "/" + ChatColor.RED + "--");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String maxplayers = s.getLine(1).substring(s.getLine(1).length() - 2);
|
if (bs == null) {
|
||||||
Boolean hasPlace = true;
|
continue;
|
||||||
if (maxplayers.equals("--")) {
|
|
||||||
hasPlace = true;
|
|
||||||
} else if (Integer.parseInt(maxplayers) == playercount) {
|
|
||||||
hasPlace = false;
|
|
||||||
}
|
}
|
||||||
if (hasPlace) {
|
if (bs instanceof Sign) {
|
||||||
s.setLine(1, ChatColor.GREEN + String.valueOf(playercount) + ChatColor.DARK_GRAY + "/" + ChatColor.GREEN + maxplayers);
|
Sign s = (Sign) bs;
|
||||||
} else {
|
if (s.getLine(3).equalsIgnoreCase(ChatColor.RED + "Offline")) {
|
||||||
s.setLine(1, ChatColor.RED + String.valueOf(playercount) + ChatColor.DARK_GRAY + "/" + ChatColor.GREEN + maxplayers);
|
s.setLine(1, ChatColor.RED + "--" + ChatColor.DARK_GRAY + "/" + ChatColor.RED + "--");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String maxplayers = s.getLine(1).substring(s.getLine(1).length() - 2);
|
||||||
|
Boolean hasPlace = true;
|
||||||
|
if (maxplayers.equals("--")) {
|
||||||
|
hasPlace = true;
|
||||||
|
} else if (Integer.parseInt(maxplayers) == playercount) {
|
||||||
|
hasPlace = false;
|
||||||
|
}
|
||||||
|
if (hasPlace) {
|
||||||
|
s.setLine(1, ChatColor.GREEN + String.valueOf(playercount) + ChatColor.DARK_GRAY + "/" + ChatColor.GREEN + maxplayers);
|
||||||
|
} else {
|
||||||
|
s.setLine(1, ChatColor.RED + String.valueOf(playercount) + ChatColor.DARK_GRAY + "/" + ChatColor.GREEN + maxplayers);
|
||||||
|
}
|
||||||
|
s.update();
|
||||||
}
|
}
|
||||||
s.update();
|
} break;
|
||||||
}
|
case "updatePermissions":
|
||||||
}
|
AnuraCore.perms.reload();
|
||||||
} else if (subchannel.equals("updatePermissions")) {
|
AnuraCore.perms.updateAllPlayers();
|
||||||
AnuraCore.perms.reload();
|
break;
|
||||||
AnuraCore.perms.updateAllPlayers();
|
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Errors.reportException(e);
|
Errors.reportException(e);
|
||||||
|
|||||||
@@ -180,7 +180,12 @@ public class TeamCommands implements CommandExecutor {
|
|||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Float.parseFloat(args[0]) >= 10 || Float.parseFloat(args[0]) < 0) {
|
try {
|
||||||
|
if (Float.parseFloat(args[0]) >= 10 || Float.parseFloat(args[0]) < 0) {
|
||||||
|
Core.statusMsg(P, "flyspeed_wrong_number", false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
Core.statusMsg(P, "flyspeed_wrong_number", false);
|
Core.statusMsg(P, "flyspeed_wrong_number", false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user