Skip to content

Commit

Permalink
3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BenceX100 committed Oct 12, 2024
1 parent 33160ed commit 04919e3
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.artillexstudios</groupId>
<artifactId>AxInventoryRestore</artifactId>
<version>3.2.5</version>
<version>3.3.0</version>
<packaging>jar</packaging>

<name>AxInventoryRestore</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public void view(Player sender, String player) {
AxInventoryRestore.getThreadedQueue().submit(() -> {
final UUID uuid = AxInventoryRestore.getDB().getUUID(player);
if (uuid == null) {
MESSAGEUTILS.sendLang(sender, "errors.unknown-player");
MESSAGEUTILS.sendLang(sender, "errors.unknown-player", Map.of("%number%", "1"));
return;
}

final Integer userId = AxInventoryRestore.getDB().getUserId(uuid);
if (userId == null) {
MESSAGEUTILS.sendLang(sender, "errors.unknown-player");
MESSAGEUTILS.sendLang(sender, "errors.unknown-player", Map.of("%number%", "2"));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Converter2(Base base) {
}

public boolean convertUsers() {
if (!SQLUtils.tableExist(base.getConnection(), "axinventoryrestore_uuids")) return true;
if (!SQLUtils.tableExists(base.getConnection(), "axinventoryrestore_uuids")) return true;

Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("&#FF6600[AxInventoryRestore] Converting users..."));

Expand Down Expand Up @@ -73,7 +73,7 @@ public boolean convertUsers() {
}

public boolean convertBackups() {
if (!SQLUtils.tableExist(base.getConnection(), "axinventoryrestore_data")) return true;
if (!SQLUtils.tableExists(base.getConnection(), "axinventoryrestore_data")) return true;

Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("&#FF6600[AxInventoryRestore] Converting backups... This might take a while!"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public interface Database {

ItemStack[] getItemsFromBackup(int backupId);

// Null reason is any reason
// null reason = any reason
int getSaves(UUID uuid, @Nullable String reason);

// Null reason is any reason
// null reason = any reason
void removeLastSaves(UUID uuid, @Nullable String reason, int amount);

void fetchRestoreRequests(@NotNull UUID uuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void setup() {
log.error("An unexpected error occurred while creating axir_backups table!", exception);
}

final String CREATE_TABLE2 = "CREATE TABLE IF NOT EXISTS axir_reasons ( id INT(128) NOT NULL AUTO_INCREMENT, reason VARCHAR(1024) NOT NULL, PRIMARY KEY (id), UNIQUE (reason));";
final String CREATE_TABLE2 = "CREATE TABLE IF NOT EXISTS axir_reasons ( id INT(128) NOT NULL AUTO_INCREMENT, reason VARCHAR(255) NOT NULL, PRIMARY KEY (id), UNIQUE (reason));";

try (Connection conn = getConnection(); PreparedStatement stmt = conn.prepareStatement(CREATE_TABLE2)) {
stmt.executeUpdate();
Expand Down Expand Up @@ -110,7 +110,7 @@ public void setup() {
}

try {
if (SQLUtils.tableExist(getConnection(), "axinventoryrestore_data")) {
if (SQLUtils.tableExists(getConnection(), "axinventoryrestore_data")) {
new Converter2(this);
}
} catch (Exception exception) {
Expand Down Expand Up @@ -469,7 +469,6 @@ public void join(@NotNull Player player) {
}
}

@Nullable
@Override
public UUID getUUID(@NotNull String name) {
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(name);
Expand All @@ -485,8 +484,6 @@ public UUID getUUID(@NotNull String name) {
} catch (SQLException exception) {
log.error("An unexpected error occurred while getting the uuid of {}!", name, exception);
}

return null;
}

return offlinePlayer.getUniqueId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void openMainGui() {
reasons.addAll(backup.getDeathsPerTypes().keySet());

if ((CONFIG.getBoolean("enable-all-category") && reasons.size() == 1) || reasons.isEmpty()) {
MESSAGEUTILS.sendLang(viewer, "errors.unknown-player");
MESSAGEUTILS.sendLang(viewer, "errors.unknown-player", Map.of("%number%", "3"));
Scheduler.get().runAt(viewer.getLocation(), t -> viewer.closeInventory());
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class SQLUtils {

public static boolean tableExist(Connection connection, String table) {
public static boolean tableExists(Connection connection, String table) {
try {
final DatabaseMetaData dmb = connection.getMetaData();
final ResultSet tables = dmb.getTables(null, null, table.toUpperCase(), null);
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ help:
errors:
no-permission: "&#FF3333You don't have permission to run this command!"
player-offline: "&#FF3333The player must be online to restore their inventory!"
unknown-player: "&#FF3333This player has 0 backups saved!"
unknown-player: "&#FF3333This player has no backups saved! &#DDDDDD(error: %number%)"
not-player: "&#FF3333You must be a player to execute this command!"

restored-shulker:
Expand Down Expand Up @@ -86,7 +86,6 @@ guis:
- " "
- "&#00CCFF&l(!) &#00CCFFClick here to export items!"


gui-items:
close:
material: BARRIER
Expand Down

0 comments on commit 04919e3

Please sign in to comment.