Skip to content

Commit

Permalink
Change first argument of containerTransactionsLookup to Location
Browse files Browse the repository at this point in the history
  • Loading branch information
takejohn committed Dec 31, 2023
1 parent a58d764 commit 1540fec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/coreprotect/CoreProtectAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ public List<String[]> blockLookup(Block block, int time) {
return null;
}

public List<String[]> containerTransactionsLookup(Block block, int time) {
public List<String[]> containerTransactionsLookup(Location location, int time) {
if (Config.getGlobal().API_ENABLED) {
return ContainerTransactionsAPI.performLookup(block, time);
return ContainerTransactionsAPI.performLookup(location, time);
}
return null;
}
Expand Down
27 changes: 14 additions & 13 deletions src/main/java/net/coreprotect/api/ContainerTransactionsAPI.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package net.coreprotect.api;

import net.coreprotect.CoreProtect;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.Database;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.utility.Util;
import org.bukkit.block.Block;

import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.ResultSet;
Expand All @@ -16,6 +9,14 @@
import java.util.List;
import java.util.logging.Level;

import org.bukkit.Location;

import net.coreprotect.CoreProtect;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.database.Database;
import net.coreprotect.database.statement.UserStatement;
import net.coreprotect.utility.Util;

public final class ContainerTransactionsAPI {

private static final int CONNECTION_WAIT_TIME = 1000;
Expand All @@ -24,19 +25,19 @@ private ContainerTransactionsAPI() {
throw new AssertionError();
}

public static List<String[]> performLookup(Block block, int offset) {
public static List<String[]> performLookup(Location location, int offset) {
List<String[]> result = new ArrayList<>();

if (block == null) {
if (location == null) {
return result;
}

try (Connection connection = Database.getConnection(false, CONNECTION_WAIT_TIME)) {
final int x = block.getX();
final int y = block.getY();
final int z = block.getZ();
final int x = (int) location.getX();
final int y = (int) location.getY();
final int z = (int) location.getZ();
final int now = (int) (System.currentTimeMillis() / 1000L);
final int worldId = Util.getWorldId(block.getWorld().getName());
final int worldId = Util.getWorldId(location.getWorld().getName());
final int timeFrom = offset > 0 ? now - offset : 0;

if (connection == null) {
Expand Down

0 comments on commit 1540fec

Please # to comment.