mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-26 02:19:48 -05:00
Fixed Cleanup stupid bug
Former-commit-id: bc78220cbd95865f4a33925d057de5f9bf2c5e65
This commit is contained in:
1 parent
b06237b9d4
commit
145e01ddf5
16 files changed
+20
-38
No files matched your search
@@ -19,7 +19,6 @@
|
||||
|
||||
package org.maxgamer.quickshop;
|
||||
|
||||
import lombok.Cleanup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.util.Copied;
|
||||
@@ -55,7 +54,6 @@ public class Language {
|
||||
}
|
||||
|
||||
try {
|
||||
@Cleanup
|
||||
InputStream is = getFile(language, type);
|
||||
new Copied(targetFile).accept(is);
|
||||
is.close();
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package org.maxgamer.quickshop.command.subcommand;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Cleanup;
|
||||
import lombok.SneakyThrows;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@@ -63,7 +62,6 @@ public class SubCommand_Export implements CommandProcesser {
|
||||
.getShopLoader()
|
||||
.getOriginShopsInDatabase()
|
||||
.forEach((shop -> finalReport.append(shop).append("\n")));
|
||||
@Cleanup
|
||||
BufferedWriter outputStream = new BufferedWriter(new FileWriter(file, false));
|
||||
outputStream.write(finalReport.toString());
|
||||
outputStream.close();
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package org.maxgamer.quickshop.command.subcommand;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -63,7 +62,7 @@ public class SubCommand_Paste implements CommandProcesser {
|
||||
try {
|
||||
boolean createResult = file.createNewFile();
|
||||
Util.debugLog("Create paste file: " + file.getCanonicalPath() + " " + createResult);
|
||||
@Cleanup
|
||||
|
||||
FileWriter fwriter = new FileWriter(file);
|
||||
fwriter.write(pasteText);
|
||||
fwriter.flush();
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package org.maxgamer.quickshop.database;
|
||||
|
||||
import lombok.Cleanup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -87,8 +86,8 @@ public class Database {
|
||||
}
|
||||
String query = "SELECT * FROM " + table + " LIMIT 0,1";
|
||||
try {
|
||||
@Cleanup PreparedStatement ps = this.getConnection().prepareStatement(query);
|
||||
@Cleanup ResultSet rs = ps.executeQuery();
|
||||
PreparedStatement ps = this.getConnection().prepareStatement(query);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
if (rs.getString(column) != null) {
|
||||
return true;
|
||||
@@ -109,7 +108,7 @@ public class Database {
|
||||
*/
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
boolean hasTable(@NotNull String table) throws SQLException {
|
||||
@Cleanup ResultSet rs = getConnection().getMetaData().getTables(null, null, "%", null);
|
||||
ResultSet rs = getConnection().getMetaData().getTables(null, null, "%", null);
|
||||
while (rs.next()) {
|
||||
if (table.equalsIgnoreCase(rs.getString("TABLE_NAME"))) {
|
||||
rs.close();
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package org.maxgamer.quickshop.database;
|
||||
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -70,7 +69,7 @@ public class DatabaseHelper {
|
||||
*/
|
||||
|
||||
private void createShopsTable() throws SQLException {
|
||||
@Cleanup Statement st = db.getConnection().createStatement();
|
||||
Statement st = db.getConnection().createStatement();
|
||||
String createTable = "CREATE TABLE " + plugin
|
||||
.getDbPrefix() + "shops (owner VARCHAR(255) NOT NULL, price double(32, 2) NOT NULL, itemConfig TEXT CHARSET utf8 NOT NULL, x INTEGER(32) NOT NULL, y INTEGER(32) NOT NULL, z INTEGER(32) NOT NULL, world VARCHAR(32) NOT NULL, unlimited boolean, type boolean, PRIMARY KEY (x, y, z, world) );";
|
||||
st.execute(createTable);
|
||||
@@ -83,7 +82,7 @@ public class DatabaseHelper {
|
||||
* @throws SQLException If the connection is invalid
|
||||
*/
|
||||
private boolean createMessagesTable() throws SQLException {
|
||||
@Cleanup Statement st = db.getConnection().createStatement();
|
||||
Statement st = db.getConnection().createStatement();
|
||||
String createTable = "CREATE TABLE " + plugin.getDbPrefix()
|
||||
+ "messages (owner VARCHAR(255) NOT NULL, message TEXT(25) NOT NULL, time BIGINT(32) NOT NULL );";
|
||||
if (plugin.getDatabase().getCore() instanceof MySQLCore) {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package org.maxgamer.quickshop.database;
|
||||
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.plugin.IllegalPluginAccessException;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@@ -89,7 +88,6 @@ public class DatabaseManager {
|
||||
*/
|
||||
private synchronized void runTask() { // synchronized for QUICKSHOP-WX
|
||||
try {
|
||||
@Cleanup
|
||||
Connection connection = this.database.getConnection();
|
||||
//start our commit
|
||||
connection.setAutoCommit(false);
|
||||
@@ -129,6 +127,7 @@ public class DatabaseManager {
|
||||
+ tookTime
|
||||
+ "ms) to execute the task, it may cause the network connection with MySQL server or just MySQL server too slow, change to a better MySQL server or switch to a local SQLite database!");
|
||||
}
|
||||
connection.close();
|
||||
} catch (SQLException sqle) {
|
||||
plugin.getSentryErrorReporter().ignoreThrow();
|
||||
this.plugin
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package org.maxgamer.quickshop.database;
|
||||
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -84,7 +83,7 @@ public class MySQLCore implements DatabaseCore {
|
||||
@Override
|
||||
public void queue(@NotNull BufferStatement bs) {
|
||||
try {
|
||||
@Cleanup
|
||||
|
||||
Connection con = this.getConnection();
|
||||
while (con == null) {
|
||||
try {
|
||||
@@ -95,7 +94,7 @@ public class MySQLCore implements DatabaseCore {
|
||||
// Try again
|
||||
con = this.getConnection();
|
||||
}
|
||||
@Cleanup
|
||||
|
||||
PreparedStatement ps = bs.prepareStatement(con);
|
||||
ps.execute();
|
||||
ps.close();
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package org.maxgamer.quickshop.database;
|
||||
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -62,7 +61,7 @@ public class SQLiteCore implements DatabaseCore {
|
||||
}
|
||||
synchronized (dbFile) {
|
||||
try {
|
||||
@Cleanup
|
||||
|
||||
PreparedStatement ps = bs.prepareStatement(Objects.requireNonNull(getConnection()));
|
||||
ps.execute();
|
||||
ps.close();
|
||||
|
||||
+1
-2
@@ -19,7 +19,6 @@ package org.maxgamer.quickshop.nonquickshopstuff.com.sk89q.worldedit.util.net;
|
||||
*/
|
||||
|
||||
import com.google.common.io.Closer;
|
||||
import lombok.Cleanup;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
@@ -227,7 +226,7 @@ public final class HttpRequest implements Closeable {
|
||||
conn.connect();
|
||||
|
||||
if (body != null) {
|
||||
@Cleanup
|
||||
|
||||
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
|
||||
out.write(body);
|
||||
out.flush();
|
||||
|
||||
@@ -21,7 +21,6 @@ package org.maxgamer.quickshop.shop;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import lombok.Cleanup;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -87,7 +86,7 @@ public class ShopLoader {
|
||||
try {
|
||||
this.plugin.getLogger().info("Loading shops from the database...");
|
||||
Timer fetchTimer = new Timer(true);
|
||||
@Cleanup
|
||||
|
||||
ResultSet rs = plugin.getDatabaseHelper().selectAllShops();
|
||||
this.plugin
|
||||
.getLogger()
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package org.maxgamer.quickshop.util;
|
||||
|
||||
import lombok.Cleanup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
@@ -40,7 +39,6 @@ public class Copied implements Consumer<InputStream> {
|
||||
@Override
|
||||
public void accept(@NotNull InputStream inputStream) {
|
||||
try {
|
||||
@Cleanup
|
||||
OutputStream out = new FileOutputStream(file);
|
||||
final byte[] buf = new byte[1024];
|
||||
int len;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package org.maxgamer.quickshop.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.Cleanup;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
@@ -440,7 +439,7 @@ public class MsgUtil {
|
||||
public static void loadTransactionMessages() {
|
||||
player_messages.clear(); // Delete old messages
|
||||
try {
|
||||
@Cleanup
|
||||
|
||||
ResultSet rs = plugin.getDatabaseHelper().selectAllMessages();
|
||||
while (rs.next()) {
|
||||
String owner = rs.getString("owner");
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package org.maxgamer.quickshop.util;
|
||||
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.InvalidDescriptionException;
|
||||
@@ -87,7 +86,7 @@ public class Updater {
|
||||
throw new IOException("Failed read the URL, cause it is empty.");
|
||||
}
|
||||
QuickShop.getInstance().getLogger().info("Downloading from " + uurl);
|
||||
@Cleanup
|
||||
|
||||
InputStream is =
|
||||
HttpRequest.get(new URL(uurl))
|
||||
.header("User-Agent", "QuickShop-" + QuickShop.getFork() + " " + QuickShop.getVersion())
|
||||
@@ -144,7 +143,7 @@ public class Updater {
|
||||
if (quickshop == null) {
|
||||
throw new RuntimeException("Failed to get QuickShop Jar File.");
|
||||
}
|
||||
@Cleanup
|
||||
|
||||
OutputStream outputStream = new FileOutputStream(quickshop, false);
|
||||
outputStream.write(data);
|
||||
outputStream.flush();
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package org.maxgamer.quickshop.util;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import lombok.Cleanup;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.*;
|
||||
@@ -745,7 +744,7 @@ public class Util {
|
||||
@Nullable
|
||||
public static byte[] inputStream2ByteArray(@NotNull String filePath) {
|
||||
try {
|
||||
@Cleanup
|
||||
|
||||
InputStream in = new FileInputStream(filePath);
|
||||
byte[] data = toByteArray(in);
|
||||
in.close();
|
||||
@@ -1288,7 +1287,7 @@ public class Util {
|
||||
public static String readToString(@NotNull File file) {
|
||||
byte[] filecontent = new byte[(int) file.length()];
|
||||
try {
|
||||
@Cleanup
|
||||
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
in.read(filecontent);
|
||||
in.close();
|
||||
|
||||
@@ -360,7 +360,7 @@ public class Paste {
|
||||
.append("\n");
|
||||
finalReport.append("================================================\n");
|
||||
int totalDB = 0;
|
||||
@Cleanup
|
||||
|
||||
ResultSet resultSet = plugin.getDatabaseHelper().selectAllShops();
|
||||
while (resultSet.next()) {
|
||||
totalDB++;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package org.maxgamer.quickshop.util.paste;
|
||||
|
||||
import lombok.Cleanup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.util.Util;
|
||||
|
||||
@@ -52,7 +51,7 @@ public class UbuntuPaster implements PasteInterface {
|
||||
conn.setDoInput(true);
|
||||
conn.setConnectTimeout(50000);
|
||||
conn.setReadTimeout(100000);
|
||||
@Cleanup
|
||||
|
||||
PrintWriter out = new PrintWriter(conn.getOutputStream());
|
||||
// poster=aaaaaaa&syntax=text&expiration=&content=%21%40
|
||||
String builder =
|
||||
@@ -64,7 +63,7 @@ public class UbuntuPaster implements PasteInterface {
|
||||
+ URLEncoder.encode(text, "UTF-8");
|
||||
out.print(builder);
|
||||
out.flush(); // Drop
|
||||
@Cleanup
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
Util.debugLog("Request Completed: " + conn.getURL());
|
||||
String link = conn.getURL().toString();
|
||||
|
||||
Reference in new issue
Block a user