mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
cleanup code
Former-commit-id: 1e3d243199911de70f37aea1c9adccc5e941f118
This commit is contained in:
1 parent
cdab4160ab
commit
8ac23cee89
3 files changed
+24
-15
No files matched your search
@@ -5,6 +5,8 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
public class DatabaseHelper {
|
||||
public static void setup(Database db) throws SQLException {
|
||||
if (!db.hasTable("shops")) {
|
||||
@@ -92,5 +94,17 @@ public class DatabaseHelper {
|
||||
+ " AND world = \"" + worldName + "\""
|
||||
+ (db.getCore() instanceof MySQLCore ? " LIMIT 1" : ""));
|
||||
}
|
||||
public static void insertSchedule(String argUUID, String world, int x, int y, int z, long l) {
|
||||
String scheduleq = "INSERT INTO schedule (owner, world, x, y, z, timestamp) VALUES (?, ?, ?, ?, ?, ?)";
|
||||
QuickShop.instance.getDB().execute(scheduleq , argUUID, world, x, y, z, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public static void updateOwner2UUID(String ownerUUID, int x, int y, int z, String worldName) throws SQLException {
|
||||
QuickShop.instance.getDB().getConnection().createStatement()
|
||||
.executeUpdate("UPDATE shops SET owner = \"" + ownerUUID.toString()
|
||||
+ "\" WHERE x = " + x + " AND y = " + y + " AND z = " + z
|
||||
+ " AND world = \"" + worldName + "\" LIMIT 1");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -336,10 +336,7 @@ public class QuickShop extends JavaPlugin {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(owner);
|
||||
if (player.hasPlayedBefore()) {
|
||||
ownerUUID = player.getUniqueId();
|
||||
getDB().getConnection().createStatement()
|
||||
.executeUpdate("UPDATE shops SET owner = \"" + ownerUUID.toString()
|
||||
+ "\" WHERE x = " + x + " AND y = " + y + " AND z = " + z
|
||||
+ " AND world = \"" + worldName + "\" LIMIT 1");
|
||||
DatabaseHelper.updateOwner2UUID(ownerUUID.toString(), x, y, z, worldName);
|
||||
} else {
|
||||
// Invalid shop owner
|
||||
// getDB().getConnection().createStatement()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.maxgamer.quickshop.Watcher;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
@@ -15,6 +14,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Database.DatabaseHelper;
|
||||
import org.maxgamer.quickshop.Database.MySQLCore;
|
||||
import org.maxgamer.quickshop.Economy.Economy;
|
||||
import org.maxgamer.quickshop.Shop.ContainerShop;
|
||||
@@ -88,22 +88,20 @@ public class OngoineFeeWatcher_TODO {
|
||||
}
|
||||
}
|
||||
if(!online) {
|
||||
QuickShop.instance.getDB().getConnection().createStatement()
|
||||
.executeUpdate("DELETE FROM schedule WHERE x = " + X + " AND y = " + Y + " AND z = " + Z
|
||||
+ " AND world = \"" + World + "\""
|
||||
+ (QuickShop.instance.getDB().getCore() instanceof MySQLCore ? " LIMIT 1" : ""));
|
||||
String scheduleq = "INSERT INTO schedule (owner, world, x, y, z, timestamp) VALUES (?, ?, ?, ?, ?, ?)";
|
||||
QuickShop.instance.getDB().execute(scheduleq , argUUID, World, X, Y, Z, System.currentTimeMillis());
|
||||
// QuickShop.instance.getDB().getConnection().createStatement()
|
||||
// .executeUpdate("DELETE FROM schedule WHERE x = " + X + " AND y = " + Y + " AND z = " + Z
|
||||
// + " AND world = \"" + World + "\""
|
||||
// + (QuickShop.instance.getDB().getCore() instanceof MySQLCore ? " LIMIT 1" : ""));
|
||||
DatabaseHelper.removeShop(QuickShop.instance.getDB(), X, Y, Z, World);
|
||||
DatabaseHelper.insertSchedule(argUUID, World, X, Y, Z, System.currentTimeMillis());
|
||||
return;
|
||||
//Not online and turn on it from config, Return
|
||||
}
|
||||
double moneyRemining = eco.getBalance(uuid);
|
||||
if(moneyRemining<shops_price) {
|
||||
MsgUtil.send(uuid, MsgUtil.getMessage("no-enough-money-to-keep-shops"));
|
||||
//Start scanning player's all shops in database
|
||||
java.sql.Connection con = QuickShop.instance.getDB().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM shops");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
//Start scanning player's all shops in database
|
||||
ResultSet rs = DatabaseHelper.selectAllShops(QuickShop.instance.getDB());
|
||||
while (rs.next()) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
Reference in new issue
Block a user