Implement new error handler and bug reporting system
This commit is contained in:
@@ -2,7 +2,6 @@ package de.anura.core.API;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -27,6 +26,9 @@ public class Core {
|
||||
* @return The working MySQL Object
|
||||
*/
|
||||
public static MySQL getMySql() {
|
||||
if (AnuraCore.getSql() == null) {
|
||||
return null;
|
||||
}
|
||||
if (!AnuraCore.getSql().isValid) {
|
||||
return null;
|
||||
}
|
||||
@@ -111,22 +113,24 @@ public class Core {
|
||||
* @return Returns the short language name of the player (like de or en)
|
||||
*/
|
||||
public static String getPlayerLang(CommandSender P) {
|
||||
try {
|
||||
if (!(P instanceof Player)) {
|
||||
return "en";
|
||||
}
|
||||
Player p = (Player) P;
|
||||
if (!Core.cachedPlayerLanguage.containsKey(p)) {
|
||||
ResultSet rs = AnuraCore.sql.querySelect("SELECT lang FROM players WHERE uuid = '" + p.getUniqueId().toString() + "'");
|
||||
try {
|
||||
|
||||
rs.first();
|
||||
Core.cachedPlayerLanguage.put(p, rs.getString("lang"));
|
||||
return rs.getString("lang");
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLException in getPlayerLang of API: " + ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
} else {
|
||||
return Core.cachedPlayerLanguage.get(p);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
return "en";
|
||||
}
|
||||
|
||||
@@ -187,6 +191,7 @@ public class Core {
|
||||
}
|
||||
|
||||
public static void endSitting(Player P) {
|
||||
try {
|
||||
if (getMainClass().sittingPlayer.containsKey(P)) {
|
||||
MaterialData md = getMainClass().sittingBlocks.get(P).getState().getData();
|
||||
if (md instanceof Stairs) {
|
||||
@@ -205,6 +210,9 @@ public class Core {
|
||||
getMainClass().sittingBlocks.remove(P);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInteger(String s) {
|
||||
|
||||
58
src/de/anura/core/API/Errors.java
Normal file
58
src/de/anura/core/API/Errors.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package de.anura.core.API;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Errors {
|
||||
|
||||
public static void reportException(Throwable exc, String info) {
|
||||
if (Core.getMySql() == null) {
|
||||
System.err.println("FATAL ERROR: Error handler fired before init of mysql connection!!");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String message = exc.getLocalizedMessage();
|
||||
String name = exc.getClass().toString();
|
||||
String server = Core.getMainClass() == null ? "~not available~" : Core.getMainClass().getConfig().getString("server-name");
|
||||
String errorSql = "INSERT INTO coreErrors (server, exception, msg, info, timestamp) VALUES('" + server + "', '" + name + "', '" + message + "', '" + info + "', '" + System.currentTimeMillis() / 1000 + "')";
|
||||
Core.getMySql().queryUpdate(errorSql);
|
||||
ResultSet rs = Core.getMySql().querySelect("SELECT id FROM coreErrors ORDER BY id DESC LIMIT 1");
|
||||
rs.first();
|
||||
int id = rs.getInt("id");
|
||||
String elemSql = "INSERT INTO coreErrorStack(errorId, className, fileName, methodName, lineNumber, nativeMethod) VALUES";
|
||||
boolean first = true;
|
||||
for(StackTraceElement elem : exc.getStackTrace()) {
|
||||
if (!first) {
|
||||
elemSql += ",";
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public static void reportException(Throwable exc) {
|
||||
reportException(exc, "");
|
||||
}
|
||||
|
||||
public static void bugReport(Player P, String msg, Entry<String, Object>... data) {
|
||||
UUID uuid = P.getUniqueId();
|
||||
String dataText = "";
|
||||
for(Entry<String, Object> date : data) {
|
||||
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() + "'), '" + msg + "', '" + dataText + "', '" + System.currentTimeMillis() / 1000 + "')");
|
||||
}
|
||||
|
||||
public static Entry<String, Object> make(String key, Object value) {
|
||||
return new AbstractMap.SimpleEntry<>(key, value);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package de.anura.core.API;
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -193,16 +192,13 @@ public class Inventories implements Listener {
|
||||
}
|
||||
|
||||
public static void executeAction(Player P, Action action, Object data) {
|
||||
if (action == Action.SERVER) {
|
||||
try {
|
||||
if (action == Action.SERVER) {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF((String) data);
|
||||
P.sendPluginMessage(AnuraCore.getInstance(), "BungeeCord", b.toByteArray());
|
||||
} catch (IOException ex) {
|
||||
System.err.println("IOException whilst trying to connect to " + data);
|
||||
}
|
||||
} else if (action == Action.MESSAGE) {
|
||||
Core.statusMsg(P, (String) data, true);
|
||||
} else if (action == Action.OPEN_INV) {
|
||||
@@ -221,6 +217,9 @@ public class Inventories implements Listener {
|
||||
}
|
||||
Core.statusMsg(P, "lang_changed", true);
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addInvItems(Player P) {
|
||||
@@ -235,6 +234,7 @@ public class Inventories implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInvClick(InventoryClickEvent event) {
|
||||
try {
|
||||
if (checkInteracts.containsKey((Player) event.getWhoClicked()) && !checkInteracts.get((Player) event.getWhoClicked())) {
|
||||
return;
|
||||
}
|
||||
@@ -264,10 +264,14 @@ public class Inventories implements Listener {
|
||||
player.setItemOnCursor(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
try {
|
||||
if (checkInteracts.containsKey((Player) event.getPlayer()) && !checkInteracts.get((Player) event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
@@ -287,6 +291,9 @@ public class Inventories implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGH)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package de.anura.core.API;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Statistic;
|
||||
@@ -14,6 +13,7 @@ public final class Level {
|
||||
private static final HashMap<Player, Integer> ffLevel = new HashMap<>();
|
||||
|
||||
public Level() {
|
||||
try {
|
||||
for (Player P : Bukkit.getOnlinePlayers()) {
|
||||
Core.getMainClass().joinTime.put(P, (int) (System.currentTimeMillis() / 1000));
|
||||
Core.getMainClass().aimTheWaterWins.put(P, 0);
|
||||
@@ -27,6 +27,9 @@ public final class Level {
|
||||
}
|
||||
|
||||
}, 20 * 60, 20 * 60);
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveStuffAll() {
|
||||
@@ -61,8 +64,8 @@ public final class Level {
|
||||
anuraLevel.put(P, (int) rs.getDouble("level"));
|
||||
smashLevel.put(P, rs.getInt("smashLevel"));
|
||||
ffLevel.put(P, rs.getInt("ffLevel"));
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Error whilst loading player level");
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,16 +76,16 @@ public final class Level {
|
||||
}
|
||||
|
||||
public void update(Player P) {
|
||||
try {
|
||||
if (!anuraLevel.containsKey(P)) {
|
||||
return;
|
||||
}
|
||||
saveStuff(P);
|
||||
try {
|
||||
String whereClause = " = (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "')";
|
||||
ResultSet stats = Core.getMySql().querySelect("SELECT * FROM coreStats WHERE player" + whereClause);
|
||||
ResultSet features = Core.getMySql().querySelect("SELECT count(*) as features FROM coreFeatures WHERE playerId" + whereClause);
|
||||
ResultSet pots = Core.getMySql().querySelect("SELECT count(*) as pots FROM coreFoundPots WHERE player" + whereClause);
|
||||
ResultSet stages = Core.getMySql().querySelect("SELECT count(*) as stages FROM jumpUsers WHERE userId" + whereClause);
|
||||
ResultSet stages = Core.getMySql().querySelect("SELECT count(*) as stages FROM jumpUsers WHERE playerId" + whereClause);
|
||||
ResultSet smashClasses = Core.getMySql().querySelect("SELECT count(*) as classes FROM smashClasses WHERE playerId" + whereClause);
|
||||
stats.first();
|
||||
features.first();
|
||||
@@ -105,8 +108,8 @@ public final class Level {
|
||||
anuraLevel.put(P, (int) level);
|
||||
smashLevel.put(P, (int) sLevel);
|
||||
Core.getMySql().queryUpdate("UPDATE coreStats SET level = '" + level + "', smashLevel = '" + sLevel + "' WHERE player" + whereClause);
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("SQLException whilst updating player level (" + ex.getLocalizedMessage() + ")");
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package de.anura.core.API;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
@@ -27,13 +26,13 @@ public class Money {
|
||||
}
|
||||
|
||||
public static boolean loadMoney(OfflinePlayer P) {
|
||||
ResultSet rs = Core.getMySql().querySelect("SELECT money FROM coreStats WHERE player = (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "')");
|
||||
try {
|
||||
ResultSet rs = Core.getMySql().querySelect("SELECT money FROM coreStats WHERE player = (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "')");
|
||||
rs.first();
|
||||
playerMoney.put(P, rs.getInt("money"));
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Could not load money for player " + P.getName());
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ public class MySQL {
|
||||
cfg.options().copyDefaults(true);
|
||||
try {
|
||||
cfg.save(file);
|
||||
} catch (IOException e) {
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
this.host = cfg.getString(dbLoc + "host");
|
||||
this.port = cfg.getInt(dbLoc + "port");
|
||||
@@ -65,9 +66,10 @@ public class MySQL {
|
||||
Connection connLoc = DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.db, this.username, this.pw);
|
||||
this.conn = connLoc;
|
||||
return true;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
return false;
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasConnection() {
|
||||
@@ -79,9 +81,10 @@ public class MySQL {
|
||||
validConn = false;
|
||||
}
|
||||
return validConn;
|
||||
} catch (SQLException e) {
|
||||
return false;
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Boolean reconnect() {
|
||||
@@ -128,8 +131,8 @@ public class MySQL {
|
||||
try {
|
||||
st = connLoc.prepareStatement(query);
|
||||
st.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Failed to send Update '" + query + "'! (" + e.getLocalizedMessage() + ")");
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
this.closeRessources(null, st);
|
||||
}
|
||||
@@ -147,8 +150,8 @@ public class MySQL {
|
||||
} else {
|
||||
return returns;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Unknown error whilst trying to build Prepared Statement!");
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
queryRedo(query, "select");
|
||||
}
|
||||
return null;
|
||||
@@ -161,28 +164,23 @@ public class MySQL {
|
||||
ResultSet rs;
|
||||
try {
|
||||
rs = st.executeQuery();
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Failed to send 'SELECT'-Query!(" + st.toString() + ") Will try to reconnect to database just in case... you know...");
|
||||
System.err.println("Caused by: " + e.getMessage());
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
return null;
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
private void closeRessources(ResultSet rs, PreparedStatement st) {
|
||||
if (rs != null) {
|
||||
try {
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (st != null) {
|
||||
try {
|
||||
st.close();
|
||||
} catch (SQLException e) {
|
||||
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +189,8 @@ public class MySQL {
|
||||
if (this.conn != null) {
|
||||
this.conn.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
} finally {
|
||||
this.conn = null;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package de.anura.core;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.API.Level;
|
||||
import de.anura.core.API.Money;
|
||||
import de.anura.core.API.MySQL;
|
||||
import de.anura.core.API.Tools;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -50,6 +50,7 @@ public class AnuraCore extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
AnuraCore.sql = new MySQL(this);
|
||||
AnuraCore.instance = this;
|
||||
if (AnuraCore.sql.isValid) {
|
||||
@@ -74,10 +75,14 @@ public class AnuraCore extends JavaPlugin {
|
||||
} else {
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
try {
|
||||
if (!AnuraCore.sql.isValid) {
|
||||
return;
|
||||
}
|
||||
@@ -86,17 +91,17 @@ public class AnuraCore extends JavaPlugin {
|
||||
}
|
||||
File configFile = new File("plugins/Core/", "config.yml");
|
||||
File dbFile = new File("plugins/Core", "database.yml");
|
||||
try {
|
||||
AnuraCore.sql.config.save(dbFile);
|
||||
this.getConfig().save(configFile);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
sql.queryUpdate("DELETE FROM coreServers WHERE name = '" + this.getConfig().getString("server-name") + "'");
|
||||
features.reset();
|
||||
level.update();
|
||||
for (Player P : this.sittingPlayer.keySet()) {
|
||||
Core.endSitting(P);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static AnuraCore getInstance() {
|
||||
|
||||
@@ -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.Inventories;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
@@ -56,10 +56,10 @@ public class Features implements Listener {
|
||||
public static ArrayList<UUID> wantFlight = new ArrayList<>();
|
||||
|
||||
public void updateFeatures(Player P) {
|
||||
try {
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ResultSet rs = Core.getMySql().querySelect("SELECT featureId FROM coreFeatures WHERE playerId = (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "')");
|
||||
resetPlayerFeatures(P);
|
||||
playerFeatures.put(P, new ArrayList<Feature>());
|
||||
@@ -75,8 +75,8 @@ public class Features implements Listener {
|
||||
featureEnabled.get(P).put(Feature.getById(rs.getInt("featureId")), true);
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Could not update player features because of a sql exception: " + ex.getLocalizedMessage());
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ public class Features implements Listener {
|
||||
}
|
||||
|
||||
public void disableFeature(Player P, Feature f) {
|
||||
try {
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
@@ -118,9 +119,13 @@ public class Features implements Listener {
|
||||
featureEnabled.get(P).put(f, false);
|
||||
Core.statusMsg(P, "boat_off", true);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableFeature(Player P, Feature f) {
|
||||
try {
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
@@ -141,6 +146,9 @@ public class Features implements Listener {
|
||||
featureEnabled.get(P).put(f, true);
|
||||
Core.statusMsg(P, "boat_on", true);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasFeature(Player P, Feature f) {
|
||||
@@ -198,6 +206,7 @@ public class Features implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
try {
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
@@ -215,10 +224,14 @@ public class Features implements Listener {
|
||||
b.setPassenger(P);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onToggleFlight(PlayerToggleFlightEvent event) {
|
||||
try {
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
@@ -237,17 +250,25 @@ public class Features implements Listener {
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBoatDestory(VehicleDestroyEvent event) {
|
||||
try {
|
||||
if (event.getVehicle().getType().equals(EntityType.BOAT) && AnuraCore.getInstance().getConfig().getBoolean("is-main-lobby")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onExit(VehicleExitEvent event) {
|
||||
try {
|
||||
if (event.getVehicle().getType().equals(EntityType.BOAT) && AnuraCore.getInstance().getConfig().getBoolean("is-main-lobby")) {
|
||||
event.getVehicle().remove();
|
||||
Player p = (Player) event.getExited();
|
||||
@@ -256,5 +277,8 @@ public class Features implements Listener {
|
||||
p.setFlying(true);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,6 +88,7 @@ public class FlowerPots {
|
||||
}
|
||||
|
||||
public void playerFoundPot(Player P, Integer pot) {
|
||||
try {
|
||||
if (!foundPot(P, pot)) {
|
||||
Integer time = getPotWaitTime(pot);
|
||||
boolean alreadyFound = foundCache.get(P).containsKey(pot);
|
||||
@@ -112,7 +113,6 @@ public class FlowerPots {
|
||||
}
|
||||
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 {
|
||||
rs.first();
|
||||
Money.payMoney(P, rs.getInt("money"));
|
||||
P.sendMessage(ChatColor.RED + "---------- " + ChatColor.YELLOW + "Achievement" + ChatColor.RED + " ----------");
|
||||
@@ -120,9 +120,6 @@ 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);
|
||||
@@ -145,5 +142,8 @@ public class FlowerPots {
|
||||
|
||||
P.sendMessage(text);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.anura.core;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -13,8 +13,8 @@ public class LanguageSupport {
|
||||
|
||||
public LanguageSupport(AnuraCore plugin) {
|
||||
this.plugin = plugin;
|
||||
ResultSet al = AnuraCore.sql.querySelect("SELECT name, short_name FROM coreAvailableLanguages");
|
||||
try {
|
||||
ResultSet al = AnuraCore.sql.querySelect("SELECT name, short_name FROM coreAvailableLanguages");
|
||||
if (!al.next()) {
|
||||
return;
|
||||
}
|
||||
@@ -31,8 +31,8 @@ public class LanguageSupport {
|
||||
languageValues.get(lang).put(lv.getString("id"), lv.getString(lang));
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Language data could not be loaded: " + ex.getLocalizedMessage());
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.anura.core;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -81,6 +81,7 @@ public final class Permissions implements Listener {
|
||||
}
|
||||
|
||||
public void updatePlayer(Player P) {
|
||||
try {
|
||||
PermissionAttachment pa = this.permAttachments.get(P);
|
||||
for (String p : pa.getPermissions().keySet()) {
|
||||
pa.unsetPermission(p);
|
||||
@@ -118,6 +119,9 @@ public final class Permissions implements Listener {
|
||||
String name = prefixes + P.getName() + suffixes;
|
||||
P.setDisplayName(name);
|
||||
P.setPlayerListName(listColor + P.getName());
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<String> getParentPerms(Integer group, ArrayList<Integer> assigned) {
|
||||
@@ -138,6 +142,7 @@ public final class Permissions implements Listener {
|
||||
}
|
||||
|
||||
public String reload() {
|
||||
try {
|
||||
ResultSet groupsRs = AnuraCore.sql.querySelect("SELECT prefix, suffix, parent, name, id, listColor FROM permGroups");
|
||||
ResultSet permsRs = AnuraCore.sql.querySelect("SELECT `group`, name FROM permPerms");
|
||||
ResultSet userRs = AnuraCore.sql.querySelect("SELECT playerUUID, `group` FROM permPlayerGroups");
|
||||
@@ -149,7 +154,6 @@ public final class Permissions implements Listener {
|
||||
this.groupSuffix.clear();
|
||||
HashMap<Integer, Integer> groupIds = new HashMap<>();
|
||||
this.groupAutoIncrement = 0;
|
||||
try {
|
||||
groupsRs.last();
|
||||
if (groupsRs.getRow() != 0) {
|
||||
groupsRs.beforeFirst();
|
||||
@@ -198,8 +202,8 @@ public final class Permissions implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Was not able to load permissions. Sorry. (" + ex.getLocalizedMessage() + ")");
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
return ChatColor.GREEN + "Permissions reloaded!";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.anura.core;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
@@ -10,6 +11,7 @@ import org.bukkit.World;
|
||||
public class RealTime {
|
||||
|
||||
public static void setup() {
|
||||
try {
|
||||
if (Core.getMainClass().getConfig().getBoolean("realtime-day")) {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
world.setGameRuleValue("doDaylightCycle", "false");
|
||||
@@ -24,6 +26,9 @@ public class RealTime {
|
||||
}
|
||||
}, 0, (20 * 60 * 10));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static Integer[] getSystemTime() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.anura.core;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.API.Inventories;
|
||||
import de.anura.core.API.Level;
|
||||
import de.anura.core.API.Tools;
|
||||
@@ -31,7 +32,6 @@ import de.anura.core.events.PlayerTeleport;
|
||||
import de.anura.core.events.SignChange;
|
||||
import de.anura.core.events.WeatherChange;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@@ -53,7 +53,7 @@ public class Setup {
|
||||
Core.getMainClass().getConfig().addDefault("no-hunger", false);
|
||||
Core.getMainClass().getConfig().addDefault("no-rain", false);
|
||||
Core.getMainClass().getConfig().addDefault("enable-leaves-decay", true);
|
||||
Core.getMainClass().getConfig().addDefault("server-name", "lobby");
|
||||
Core.getMainClass().getConfig().addDefault("server-name", "none");
|
||||
Core.getMainClass().getConfig().addDefault("allow-stairs-sit", false);
|
||||
Core.getMainClass().getConfig().addDefault("disable-mushroom-spread", false);
|
||||
Core.getMainClass().getConfig().addDefault("on-join-to-spawn", false);
|
||||
@@ -88,6 +88,7 @@ public class Setup {
|
||||
}
|
||||
|
||||
public static void setupClasses() {
|
||||
try {
|
||||
Core.getMainClass().lang = new LanguageSupport(Core.getMainClass());
|
||||
new Inventories(Core.getMainClass());
|
||||
setupInventories();
|
||||
@@ -98,7 +99,6 @@ public class Setup {
|
||||
Core.getMainClass().level = new Level();
|
||||
RealTime.setup();
|
||||
ResultSet rs = sql.querySelect("SELECT id, X, Y, Z, world, type, waitTime FROM corePots");
|
||||
try {
|
||||
while (rs.next()) {
|
||||
World w = Bukkit.getWorld(rs.getString("world"));
|
||||
if (w == null) {
|
||||
@@ -111,14 +111,15 @@ public class Setup {
|
||||
}
|
||||
l.getBlock().setType(Material.BROWN_MUSHROOM);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Error whilst trying to setup flower pots");
|
||||
}
|
||||
Core.getMainClass().features = new Features();
|
||||
Core.getMainClass().features.updateFeaturesAll();
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setupTasks() {
|
||||
try {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Core.getMainClass(), new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -143,7 +144,6 @@ public class Setup {
|
||||
|
||||
}, 5, 5);
|
||||
ResultSet rs = sql.querySelect("SELECT world, X, Y, Z FROM coreStairs WHERE server = '" + Core.getMainClass().getConfig().getString("server-name") + "'");
|
||||
try {
|
||||
while (rs.next()) {
|
||||
World w = Bukkit.getWorld(rs.getString("world"));
|
||||
if (w == null) {
|
||||
@@ -154,9 +154,6 @@ public class Setup {
|
||||
Core.getMainClass().sittableBlocks.add(l.getBlock());
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Error whilst trying to setup stairs");
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Core.getMainClass(), new Runnable() {
|
||||
|
||||
@@ -178,6 +175,9 @@ public class Setup {
|
||||
AnuraCore.getInstance().signs.updateServerSigns();
|
||||
}
|
||||
}, 20 * 5, 20 * 5);
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setupCommands() {
|
||||
@@ -218,6 +218,7 @@ public class Setup {
|
||||
}
|
||||
|
||||
private static void setupInventories() {
|
||||
try {
|
||||
Inventories.registerInventory("GAMEMODES", "select_gamemode_inv", ChatColor.DARK_BLUE);
|
||||
Inventories.putIntoInventory("GAMEMODES", 0, Inventories.buildItems(Material.RED_ROSE, "inv_lobby_tps", ChatColor.DARK_GREEN));
|
||||
Inventories.putIntoInventory("GAMEMODES", 2, Inventories.buildItems(Material.CARROT_STICK, "inv_lobby_minigames", ChatColor.BLUE));
|
||||
@@ -282,5 +283,8 @@ public class Setup {
|
||||
Inventories.registerItemAction("CHARGE", Inventories.Action.OPEN_INV, "FEATURES");
|
||||
Inventories.registerItemAction("DOOR", Inventories.Action.COMMAND, "spawn");
|
||||
Inventories.registerItemAction("EYE", Inventories.Action.SERVER, "lobby");
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.anura.core;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import static de.anura.core.AnuraCore.sql;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -21,11 +22,11 @@ import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
public class Signs implements PluginMessageListener {
|
||||
|
||||
public void updateServerSigns() {
|
||||
try {
|
||||
if (Bukkit.getOnlinePlayers().length == 0) {
|
||||
return;
|
||||
}
|
||||
ResultSet rs = sql.querySelect("SELECT DISTINCT value FROM coreWarpSigns WHERE type = 'server' AND server = '" + Core.getMainClass().getConfig().getString("server-name") + "'");
|
||||
try {
|
||||
rs.last();
|
||||
if (rs.getRow() == 0) {
|
||||
return;
|
||||
@@ -92,21 +93,19 @@ public class Signs implements PluginMessageListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException | IOException ex) {
|
||||
System.err.println("Exception in updateServerSigns()(Core): " + ex.getLocalizedMessage());
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
try {
|
||||
if (!channel.equals("BungeeCord")) {
|
||||
return;
|
||||
}
|
||||
|
||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
||||
|
||||
try {
|
||||
String subchannel = in.readUTF();
|
||||
if (subchannel.equals("PlayerCount")) {
|
||||
String server = in.readUTF();
|
||||
@@ -165,8 +164,8 @@ public class Signs implements PluginMessageListener {
|
||||
Core.getMainClass().perms.reload();
|
||||
Core.getMainClass().perms.updateAllPlayers();
|
||||
}
|
||||
} catch (IOException | SQLException ex) {
|
||||
System.err.println("Exception in updateServerSigns()(Core): " + ex.getLocalizedMessage());
|
||||
} catch (Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.anura.core.commands;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import de.anura.core.LanguageSupport;
|
||||
import java.io.File;
|
||||
@@ -17,6 +18,7 @@ public class AdminCommands implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
try {
|
||||
Player P = null;
|
||||
if (sender instanceof Player) {
|
||||
P = (Player) sender;
|
||||
@@ -78,6 +80,9 @@ public class AdminCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.anura.core.commands;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
@@ -14,6 +15,7 @@ public class OtherCommands implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
try {
|
||||
Player P = null;
|
||||
if (sender instanceof Player) {
|
||||
P = (Player) sender;
|
||||
@@ -52,7 +54,9 @@ public class OtherCommands implements CommandExecutor {
|
||||
Core.getMainClass().aimTheWaterWins.put(player, Core.getMainClass().aimTheWaterWins.get(player) + 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package de.anura.core.commands;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.API.Money;
|
||||
import static de.anura.core.AnuraCore.sql;
|
||||
import de.anura.core.Features;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@@ -22,6 +22,7 @@ public class PlayerCommands implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
|
||||
try {
|
||||
Player P = null;
|
||||
if (sender instanceof Player) {
|
||||
P = (Player) sender;
|
||||
@@ -187,7 +188,6 @@ public class PlayerCommands implements CommandExecutor {
|
||||
Core.statusMsg(P, "spawn_tp_done", true);
|
||||
return true;
|
||||
} else if (cmd.getName().equalsIgnoreCase("warp")) {
|
||||
try {
|
||||
if (args.length == 0 || args.length > 2) {
|
||||
Core.statusMsg(P, "wrong_args_count", false);
|
||||
return false;
|
||||
@@ -240,9 +240,6 @@ public class PlayerCommands implements CommandExecutor {
|
||||
P.teleport(loc);
|
||||
Core.statusMsg(P, "warp_tp_done", true);
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error: " + ex.getLocalizedMessage());
|
||||
}
|
||||
} else if (cmd.getName().equalsIgnoreCase("money")) {
|
||||
if (args.length == 0) {
|
||||
if (P == null) {
|
||||
@@ -311,6 +308,9 @@ public class PlayerCommands implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.anura.core.commands;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import static de.anura.core.AnuraCore.sql;
|
||||
import de.anura.core.Features;
|
||||
@@ -12,7 +13,6 @@ import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -33,6 +33,7 @@ public class TeamCommands implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
try {
|
||||
Player P = null;
|
||||
if (sender instanceof Player) {
|
||||
P = (Player) sender;
|
||||
@@ -135,17 +136,12 @@ public class TeamCommands implements CommandExecutor {
|
||||
}
|
||||
Core.getMySql().queryUpdate("INSERT INTO corePots(X,Y,Z,world,url,name,money,type) VALUES('" + l.getBlockX() + "','" + l.getBlockY() + "','" + l.getBlockZ() + "','" + l.getWorld().getName() + "','http://mc-anura.de','" + args[0] + "','1','0')");
|
||||
ResultSet rs = Core.getMySql().querySelect("SELECT id FROM corePots WHERE X = '" + l.getBlockX() + "' AND Y = '" + l.getBlockY() + "' AND Z = '" + l.getBlockZ() + "' AND world = '" + l.getWorld().getName() + "'");
|
||||
try {
|
||||
rs.first();
|
||||
Core.getMainClass().flowerPots.put(rs.getInt("id"), new Location(l.getWorld(), l.getBlockX(), l.getBlockY(), l.getBlockZ()));
|
||||
l.getBlock().setType(Material.BROWN_MUSHROOM);
|
||||
Core.getMainClass().pots.refreshPot(rs.getInt("id"));
|
||||
Core.statusMsg(sender, "set_arch_ok", true);
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error onCommand. Setpot");
|
||||
|
||||
}
|
||||
} else if (cmd.getName().equalsIgnoreCase("renderMap")) {
|
||||
if (!sender.hasPermission("core.commands.addmap")) {
|
||||
Core.statusMsg(sender, "no_perms", false);
|
||||
@@ -256,7 +252,6 @@ public class TeamCommands implements CommandExecutor {
|
||||
Core.getTools().sendStatusMsg(P, Core.getl("flyspeed_set_1", P) + " " + args[0] + Core.getl("flyspeed_set_2", P), true);
|
||||
return true;
|
||||
} else if (cmd.getName().equalsIgnoreCase("setwarp")) {
|
||||
try {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
@@ -291,9 +286,6 @@ public class TeamCommands implements CommandExecutor {
|
||||
sql.queryUpdate("INSERT INTO coreWarps(`name`, server, world, X, Y, Z, userWarp) VALUES('" + name + "', '" + server + "', '" + world + "', '" + X + "', '" + Y + "', '" + Z + "', '" + userWarp + "')");
|
||||
Core.statusMsg(P, "warp_set", true);
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error: " + ex.getLocalizedMessage());
|
||||
}
|
||||
} else if (cmd.getName().equalsIgnoreCase("remwarp")) {
|
||||
if (args.length != 1) {
|
||||
Core.statusMsg(P, "wrong_args_count", false);
|
||||
@@ -305,7 +297,6 @@ public class TeamCommands implements CommandExecutor {
|
||||
}
|
||||
String map = args[0];
|
||||
ResultSet rs = sql.querySelect("SELECT name FROM coreWarps WHERE name = '" + map + "'");
|
||||
try {
|
||||
rs.last();
|
||||
if (rs.getRow() == 0) {
|
||||
Core.statusMsg(P, "warp_not_exist", false);
|
||||
@@ -314,10 +305,6 @@ public class TeamCommands implements CommandExecutor {
|
||||
sql.queryUpdate("DELETE FROM coreWarps WHERE name = '" + map + "'");
|
||||
Core.statusMsg(P, "warp_rem_done", true);
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error: " + ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
} else if (cmd.getName().equalsIgnoreCase("toggleBoatFlight")) {
|
||||
if (P != null && P.hasPermission("core.boat.toggleflight")) {
|
||||
if (Features.wantFlight.contains(P.getUniqueId())) {
|
||||
@@ -333,6 +320,9 @@ public class TeamCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -18,6 +19,7 @@ public class BlockBreak implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
try {
|
||||
if (plugin.getConfig().getBoolean("no-change-blocks")) {
|
||||
if (!event.getPlayer().hasPermission("core.rules.blocks.break")) {
|
||||
event.setCancelled(true);
|
||||
@@ -48,6 +50,9 @@ public class BlockBreak implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -17,6 +18,7 @@ public class BlockPlace implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
try {
|
||||
if (plugin.getConfig().getBoolean("no-change-blocks")) {
|
||||
if (!event.getPlayer().hasPermission("core.rules.blocks.place")) {
|
||||
event.setCancelled(true);
|
||||
@@ -36,6 +38,9 @@ public class BlockPlace implements Listener {
|
||||
|
||||
}, 3);
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -15,9 +16,13 @@ public class BlockSpread implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onBlockSpread(BlockSpreadEvent event) {
|
||||
try {
|
||||
if (event.getNewState().getType().equals(Material.BROWN_MUSHROOM) && plugin.getConfig().getBoolean("disable-mushroom-spread")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -16,6 +17,7 @@ public class CmdPreprocess implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
try {
|
||||
if (event.getMessage().startsWith("/?")) {
|
||||
if (!event.getPlayer().hasPermission("core.commands.help")) {
|
||||
event.setCancelled(true);
|
||||
@@ -25,6 +27,9 @@ public class CmdPreprocess implements Listener {
|
||||
event.setCancelled(true);
|
||||
Core.statusMsg(event.getPlayer(), "no_command_red_mg", ChatColor.YELLOW);
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -15,6 +16,7 @@ public class DropItem implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
try {
|
||||
if (AnuraCore.getInstance().getConfig().getBoolean("is-main-lobby") && !event.getPlayer().hasPermission("core.inventory.interact")) {
|
||||
event.setCancelled(true);
|
||||
final Player P = event.getPlayer();
|
||||
@@ -25,5 +27,8 @@ public class DropItem implements Listener {
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -15,9 +16,13 @@ public class EntityDamage implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
try {
|
||||
if (event.getEntity() instanceof Player && plugin.getConfig().getBoolean("no-damage")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -16,6 +17,7 @@ public class EntityDamageByE implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamageByE(EntityDamageByEntityEvent event) {
|
||||
try {
|
||||
if (event.getEntity() instanceof ItemFrame && plugin.getConfig().getBoolean("no-change-blocks")) {
|
||||
if (event.getDamager() instanceof Player) {
|
||||
if (!((Player) event.getDamager()).hasPermission("core.rules.blocks.break")) {
|
||||
@@ -23,6 +25,9 @@ public class EntityDamageByE implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -15,12 +16,16 @@ public class FoodChange implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onFoodLChange(FoodLevelChangeEvent event) {
|
||||
try {
|
||||
if (plugin.getConfig().getBoolean("no-hunger")) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
((Player) event.getEntity()).setFoodLevel(20);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -15,6 +16,7 @@ public class HangingEBreak implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onHangingBreakByE(HangingBreakByEntityEvent event) {
|
||||
try {
|
||||
Player P;
|
||||
if (event.getRemover() instanceof Player) {
|
||||
P = (Player) event.getRemover();
|
||||
@@ -26,6 +28,9 @@ public class HangingEBreak implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -20,6 +21,7 @@ public class InvClick implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInvClick(InventoryClickEvent event) {
|
||||
try {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (!player.hasPermission("core.inventory.interact") && plugin.getConfig().getBoolean("is-main-lobby")) {
|
||||
event.setCancelled(true);
|
||||
@@ -32,5 +34,8 @@ public class InvClick implements Listener {
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -15,6 +16,7 @@ public class LeavesDecay implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onLeavesDecay(LeavesDecayEvent event) {
|
||||
try {
|
||||
if (!plugin.getConfig().getBoolean("enable-leaves-decay")) {
|
||||
Block b = event.getBlock();
|
||||
byte data = b.getData();
|
||||
@@ -24,6 +26,9 @@ public class LeavesDecay implements Listener {
|
||||
b.setData(data);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.util.IllegalFormatException;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -15,9 +17,13 @@ public class PlayerChat implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
try {
|
||||
if (event.isAsynchronous()) {
|
||||
event.setFormat(event.getPlayer().getDisplayName() + ChatColor.GRAY + ":" + ChatColor.WHITE + " " + event.getMessage());
|
||||
}
|
||||
} catch(IllegalFormatException | NullPointerException e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -29,6 +28,7 @@ public class PlayerInteract implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
try {
|
||||
final Block block = event.getClickedBlock();
|
||||
if (plugin.selectableJumper.containsKey(event.getPlayer())) {
|
||||
if (event.getPlayer().hasPermission("core.commands.setjumper")) {
|
||||
@@ -65,7 +65,6 @@ public class PlayerInteract implements Listener {
|
||||
String world = loc.getWorld().getName();
|
||||
String server = plugin.getConfig().getString("server-name");
|
||||
ResultSet rs = AnuraCore.sql.querySelect("SELECT type, value FROM coreWarpSigns WHERE X = '" + X + "' AND Y = '" + Y + "' AND Z = '" + Z + "' AND world = '" + world + "' AND server = '" + server + "'");
|
||||
try {
|
||||
rs.last();
|
||||
if (rs.getRow() != 0) {
|
||||
rs.first();
|
||||
@@ -92,12 +91,6 @@ public class PlayerInteract implements Listener {
|
||||
P.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLException in playerInteract: " + ex.getLocalizedMessage());
|
||||
} catch (IOException ex) {
|
||||
System.out.println("IOException in playerInteract: " + ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
} else if (block.getState().getData() instanceof Stairs) {
|
||||
if (plugin.stairMode.contains(event.getPlayer()) && event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
@@ -173,6 +166,9 @@ public class PlayerInteract implements Listener {
|
||||
event.setCancelled(cancelled);
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Chicken;
|
||||
@@ -18,6 +19,7 @@ public class PlayerInteractE implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractE(PlayerInteractEntityEvent event) {
|
||||
try {
|
||||
if (event.getRightClicked().getType().equals(EntityType.ITEM_FRAME) && plugin.getConfig().getBoolean("no-change-blocks")) {
|
||||
if (!event.getPlayer().hasPermission("core.rules.blocks.interact")) {
|
||||
event.setCancelled(true);
|
||||
@@ -44,6 +46,9 @@ public class PlayerInteractE implements Listener {
|
||||
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -19,9 +20,9 @@ public class PlayerJoin implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
try {
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
ResultSet rs;
|
||||
try {
|
||||
rs = AnuraCore.getSql().querySelect("SELECT name FROM players WHERE uuid LIKE '" + uuid.toString() + "'");
|
||||
if (rs == null) {
|
||||
event.getPlayer().kickPlayer("Please try again");
|
||||
@@ -32,8 +33,6 @@ public class PlayerJoin implements Listener {
|
||||
if (rs.getRow() != 1) {
|
||||
AnuraCore.getSql().queryUpdate("INSERT INTO players(`uuid`,`game`,`waiting`,`gameName`) VALUES('" + uuid.toString() + "','none','none','')");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
event.setJoinMessage(null);
|
||||
event.getPlayer().getInventory().clear();
|
||||
plugin.pots.refreshCache(event.getPlayer());
|
||||
@@ -46,6 +45,9 @@ public class PlayerJoin implements Listener {
|
||||
if (plugin.getConfig().getBoolean("on-join-to-spawn")) {
|
||||
event.getPlayer().teleport(event.getPlayer().getWorld().getSpawnLocation());
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
@@ -18,9 +18,9 @@ public class PlayerKick implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
try {
|
||||
AnuraCore.getInstance().disableCommandsAdventure.remove(event.getPlayer());
|
||||
if (!plugin.getConfig().getBoolean("is-main-lobby")) {
|
||||
try {
|
||||
Core.endSitting(event.getPlayer());
|
||||
event.setCancelled(true);
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
@@ -28,11 +28,11 @@ public class PlayerKick implements Listener {
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF("lobby");
|
||||
event.getPlayer().sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
|
||||
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
event.setLeaveMessage(null);
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import de.anura.core.ParticleEffect;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -26,6 +26,7 @@ public class PlayerMove implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
try {
|
||||
Player p = event.getPlayer();
|
||||
Block block = event.getTo().clone().getBlock();
|
||||
Block under = block.getLocation().subtract(0, 1, 0).getBlock();
|
||||
@@ -36,7 +37,6 @@ public class PlayerMove implements Listener {
|
||||
if (block.getType().equals(Material.CARPET) && under.getType().equals(Material.SIGN_POST)) {
|
||||
p.setWalkSpeed(0.6F);
|
||||
} else if (block.getType().equals(Material.CARPET) && under.getType().equals(Material.ENDER_CHEST)) {
|
||||
try {
|
||||
double X = under.getLocation().getX();
|
||||
double Y = under.getLocation().getY();
|
||||
double Z = under.getLocation().getZ();
|
||||
@@ -49,12 +49,8 @@ public class PlayerMove implements Listener {
|
||||
ParticleEffect.FIREWORKS_SPARK.display(p.getLocation(), (float) 0.1, (float) 0.1, (float) 0.1, (float) 0.3, 10);
|
||||
}
|
||||
p.setWalkSpeed(0.2F);
|
||||
} catch (SQLException ex) {
|
||||
System.err.println(ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
} else if (block.getType().equals(Material.CARPET) && under.getType().equals(Material.RAILS)) {
|
||||
try {
|
||||
double X = under.getLocation().getX();
|
||||
double Y = under.getLocation().getY();
|
||||
double Z = under.getLocation().getZ();
|
||||
@@ -69,9 +65,6 @@ public class PlayerMove implements Listener {
|
||||
p.playSound(p.getLocation(), Sound.EXPLODE, 1, 1);
|
||||
}
|
||||
p.setWalkSpeed(0.2F);
|
||||
} catch (SQLException ex) {
|
||||
System.err.println(ex.getLocalizedMessage());
|
||||
}
|
||||
} else {
|
||||
p.setWalkSpeed(0.2F);
|
||||
}
|
||||
@@ -101,6 +94,8 @@ public class PlayerMove implements Listener {
|
||||
if (!plugin.lastLoc.containsKey(p) || !plugin.lastLoc.get(p).getWorld().equals(p.getLocation().getWorld()) || plugin.lastLoc.get(p).distance(p.getLocation()) > 1) {
|
||||
plugin.pots.refreshPlayer(p);
|
||||
}
|
||||
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.API.Money;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.entity.Boat;
|
||||
@@ -17,6 +18,7 @@ public class PlayerQuit implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
try {
|
||||
if(event.getPlayer().getVehicle() != null){
|
||||
if(event.getPlayer().getVehicle().getType().equals(EntityType.BOAT)){
|
||||
Boat b = (Boat) event.getPlayer().getVehicle();
|
||||
@@ -28,5 +30,8 @@ public class PlayerQuit implements Listener {
|
||||
AnuraCore.getInstance().disableCommandsAdventure.remove(event.getPlayer());
|
||||
Money.saveMoney(event.getPlayer());
|
||||
Core.getLevel().update(event.getPlayer());
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public class PlayerTeleport implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
|
||||
if (plugin.sittingPlayer.containsKey(event.getPlayer()) && !event.getCause().equals(TeleportCause.PLUGIN)) {
|
||||
if (event.getPlayer().isSneaking()) {
|
||||
Player P = event.getPlayer();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map.Entry;
|
||||
@@ -22,7 +22,7 @@ public class SignChange implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
|
||||
try {
|
||||
if (event.getLine(0).equalsIgnoreCase("[Warp]")) {
|
||||
if (!event.getPlayer().hasPermission("core.signs.warp")) {
|
||||
event.setLine(0, ChatColor.STRIKETHROUGH + "[Warp]");
|
||||
@@ -33,7 +33,6 @@ public class SignChange implements Listener {
|
||||
}
|
||||
if (event.getLine(1).equalsIgnoreCase("warp")) {
|
||||
ResultSet rs = AnuraCore.sql.querySelect("SELECT name FROM coreWarps WHERE name = '" + event.getLine(2) + "'");
|
||||
try {
|
||||
rs.last();
|
||||
if (rs.getRow() == 0) {
|
||||
event.setLine(0, ChatColor.STRIKETHROUGH + "[Warp]");
|
||||
@@ -54,9 +53,6 @@ public class SignChange implements Listener {
|
||||
event.setLine(3, ChatColor.BLUE + event.getLine(3));
|
||||
Core.statusMsg(event.getPlayer(), "warpsign_created", true);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error: " + ex.getLocalizedMessage());
|
||||
}
|
||||
} else if (event.getLine(1).equalsIgnoreCase("spawn")) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
int X = loc.getBlockX();
|
||||
@@ -113,6 +109,9 @@ public class SignChange implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Errors;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -14,9 +15,12 @@ public class WeatherChange implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onWeatherChange(WeatherChangeEvent event) {
|
||||
try {
|
||||
if (event.toWeatherState() && plugin.getConfig().getBoolean("no-rain")) {
|
||||
event.setCancelled(true);
|
||||
System.out.println("Stopped rain!");
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
Errors.reportException(e);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
|
||||
Reference in New Issue
Block a user