Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed Jul 13, 2023
1 parent df9b478 commit 1e007c9
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 25 deletions.
5 changes: 5 additions & 0 deletions src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,9 @@ public boolean isSign(Material material) {
return Tag.SIGNS.isTagged(material);
}

@Override
public boolean isChiseledBookshelf(Material material) {
return false;
}

}
2 changes: 2 additions & 0 deletions src/main/java/net/coreprotect/bukkit/BukkitInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,6 @@ public interface BukkitInterface {

public boolean isSign(Material material);

public boolean isChiseledBookshelf(Material material);

}
5 changes: 5 additions & 0 deletions src/main/java/net/coreprotect/bukkit/Bukkit_v1_20.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,9 @@ public boolean isSign(Material material) {
return Tag.ALL_SIGNS.isTagged(material);
}

@Override
public boolean isChiseledBookshelf(Material material) {
return material == Material.CHISELED_BOOKSHELF;
}

}
4 changes: 2 additions & 2 deletions src/main/java/net/coreprotect/database/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public static void createDatabaseTables(String prefix, boolean purge) {
index = ", INDEX(time), INDEX(user,time), INDEX(wid,x,z,time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "command(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int, user int, wid int, x int, y int (3), z int, message varchar(16000)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(wid,x,z,time), INDEX(user,time), INDEX(type,time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "container(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, user int, wid int, x int, y int, z int, type int, data int, amount int, slot tinyint, metadata blob, action tinyint, rolled_back tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "container(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, user int, wid int, x int, y int, z int, type int, data int, amount int, metadata blob, action tinyint, rolled_back tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(wid,x,z,time), INDEX(user,time), INDEX(type,time)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "item(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid), time int, user int, wid int, x int, y int, z int, type int, data blob, amount int, action tinyint, rolled_back tinyint" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "database_lock(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),status tinyint,time int) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
Expand Down Expand Up @@ -426,7 +426,7 @@ else if (type.equalsIgnoreCase("index")) {
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "command (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, message TEXT);");
}
if (!tableData.contains(prefix + "container")) {
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "container (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, type INTEGER, data INTEGER, amount INTEGER, slot INTEGER, metadata BLOB, action INTEGER, rolled_back INTEGER);");
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "container (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, type INTEGER, data INTEGER, amount INTEGER, metadata BLOB, action INTEGER, rolled_back INTEGER);");
}
if (!tableData.contains(prefix + "item")) {
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "item (time INTEGER, user INTEGER, wid INTEGER, x INTEGER, y INTEGER, z INTEGER, type INTEGER, data BLOB, amount INTEGER, action INTEGER, rolled_back INTEGER);");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/coreprotect/database/Rollback.java
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ else if (type != null && type.equals(Material.JUKEBOX)) {
modifiedArmor = addedItem ? setArmor : modifiedArmor;
}
if (!addedItem) {
if (type.name().equals("CHISELED_BOOKSHELF")) {
if (BukkitAdapter.ADAPTER.isChiseledBookshelf(type)) {
ItemStack[] inventoryContents = inventory.getStorageContents();
int i = 0;
for (ItemStack stack : inventoryContents) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand != null && Ta
}
}
}
else if (type.name().equals("CHISELED_BOOKSHELF")) {
else if (BukkitAdapter.ADAPTER.isChiseledBookshelf(type)) {
BlockState blockState = block.getState();
if (blockState instanceof BlockInventoryHolder) {
InventoryChangeListener.inventoryTransaction(player.getName(), blockState.getLocation(), null);
Expand Down
21 changes: 0 additions & 21 deletions src/main/java/net/coreprotect/patch/script/__2_22_0.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,6 @@ protected static boolean patch(Statement statement) {
Chat.console(Phrase.build(Phrase.PATCH_SKIP_UPDATE, ConfigHandler.prefix + "sign", Selector.FIRST, Selector.FIRST));
}
}

if (!Patch.continuePatch()) {
return false;
}

if (Config.getGlobal().MYSQL) {
try {
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "container ADD COLUMN slot TINYINT DEFAULT 0;");
}
catch (Exception e) {
Chat.console(Phrase.build(Phrase.PATCH_SKIP_UPDATE, ConfigHandler.prefix + "container", Selector.FIRST, Selector.FIRST));
}
}
else {
try {
statement.executeUpdate("ALTER TABLE " + ConfigHandler.prefix + "container ADD COLUMN slot INTEGER DEFAULT 0;");
}
catch (Exception e) {
Chat.console(Phrase.build(Phrase.PATCH_SKIP_UPDATE, ConfigHandler.prefix + "container", Selector.FIRST, Selector.FIRST));
}
}
}
catch (Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit 1e007c9

Please sign in to comment.