diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/events/AuctionAdminEvent.java b/src/main/java/ca/tweetzy/auctionhouse/api/events/AuctionAdminEvent.java new file mode 100644 index 0000000..1bd2faa --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/api/events/AuctionAdminEvent.java @@ -0,0 +1,37 @@ +package ca.tweetzy.auctionhouse.api.events; + +import ca.tweetzy.auctionhouse.auction.AuctionAdminLog; +import lombok.Getter; +import lombok.Setter; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +/** + * The current file has been created by Kiran Hart + * Date Created: January 17 2022 + * Time Created: 1:38 p.m. + * Usage of any code found within this class is prohibited unless given explicit permission otherwise + */ +@Getter +@Setter +public final class AuctionAdminEvent extends Event implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + + private final AuctionAdminLog auctionAdminLog; + + public AuctionAdminEvent(AuctionAdminLog auctionAdminLog) { + this.auctionAdminLog = auctionAdminLog; + } + + + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionAdminLog.java b/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionAdminLog.java new file mode 100644 index 0000000..2da6288 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/auction/AuctionAdminLog.java @@ -0,0 +1,28 @@ +package ca.tweetzy.auctionhouse.auction; + +import ca.tweetzy.auctionhouse.auction.enums.AdminAction; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.UUID; + +/** + * The current file has been created by Kiran Hart + * Date Created: January 17 2022 + * Time Created: 1:35 p.m. + * Usage of any code found within this class is prohibited unless given explicit permission otherwise + */ +@AllArgsConstructor +@Getter +public final class AuctionAdminLog { + + private final int id; + private final UUID admin; + private final String adminName; + private final UUID target; + private final String targetName; + private final String itemName; + private final UUID itemId; + private final AdminAction adminAction; + private final long time; +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/auction/enums/AdminAction.java b/src/main/java/ca/tweetzy/auctionhouse/auction/enums/AdminAction.java new file mode 100644 index 0000000..ad8833f --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/auction/enums/AdminAction.java @@ -0,0 +1,23 @@ +package ca.tweetzy.auctionhouse.auction.enums; + +import ca.tweetzy.auctionhouse.AuctionHouse; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * The current file has been created by Kiran Hart + * Date Created: January 17 2022 + * Time Created: 1:29 p.m. + * Usage of any code found within this class is prohibited unless given explicit permission otherwise + */ +@AllArgsConstructor +public enum AdminAction { + + RETURN_ITEM(AuctionHouse.getInstance().getLocale().getMessage("admin action.return").getMessage()), + CLAIM_ITEM(AuctionHouse.getInstance().getLocale().getMessage("admin action.claim").getMessage()), + DELETE_ITEM(AuctionHouse.getInstance().getLocale().getMessage("admin action.delete").getMessage()), + COPY_ITEM(AuctionHouse.getInstance().getLocale().getMessage("admin action.copy").getMessage()); + + @Getter + private final String translation; +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_11_AdminLogMigration.java b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_11_AdminLogMigration.java new file mode 100644 index 0000000..2424fc4 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_11_AdminLogMigration.java @@ -0,0 +1,43 @@ +package ca.tweetzy.auctionhouse.database.migrations; + +import ca.tweetzy.auctionhouse.AuctionHouse; +import ca.tweetzy.core.database.DataMigration; +import ca.tweetzy.core.database.MySQLConnector; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +/** + * The current file has been created by Kiran Hart + * Date Created: August 24 2021 + * Time Created: 4:04 p.m. + * Usage of any code found within this class is prohibited unless given explicit permission otherwise + */ +public final class _11_AdminLogMigration extends DataMigration { + + public _11_AdminLogMigration() { + super(11); + } + + @Override + public void migrate(Connection connection, String tablePrefix) throws SQLException { + try (Statement statement = connection.createStatement()) { + String autoIncrement = AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : ""; + + + statement.execute("CREATE TABLE " + tablePrefix + "admin_logs (" + + "id INTEGER PRIMARY KEY" + autoIncrement + ", " + + "admin VARCHAR(36) NOT NULL, " + + "admin_name VARCHAR(16) NOT NULL, " + + "target VARCHAR(36) NOT NULL, " + + "target_name VARCHAR(16) NOT NULL, " + + "item_name TEXT NOT NULL, " + + "item_id VARCHAR(36) NOT NULL, " + + "action VARCHAR(36) NOT NULL, " + + "time BigInt NOT NULL" + + + " )"); + } + } +}