mirror of
https://github.com/CarmJos/UltraDepository.git
synced 2026-06-04 16:48:21 +08:00
调整数据结构,完成MySQL数据存储部分
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.configuration.backpack;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface BackpackCapacity {
|
||||
|
||||
|
||||
int getDefault();
|
||||
|
||||
Map<Integer, String> getPermissions();
|
||||
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.configuration.backpack;
|
||||
|
||||
import cc.carm.plugin.ultrabackpack.api.configuration.gui.GUIConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface BackpackConfiguration {
|
||||
|
||||
@NotNull String getIdentifier();
|
||||
|
||||
@NotNull String getName();
|
||||
|
||||
@NotNull GUIConfiguration getGUIConfiguration();
|
||||
|
||||
@NotNull BackpackCapacity getCapacity();
|
||||
|
||||
int getCapacityFor(Player player);
|
||||
|
||||
@NotNull Map<String, BackpackItem> getItems();
|
||||
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.configuration.backpack;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BackpackItem {
|
||||
|
||||
Material getMaterial();
|
||||
|
||||
int getData();
|
||||
|
||||
int getSoldLimit();
|
||||
|
||||
int getSoldPrice();
|
||||
|
||||
int getDisplaySlot();
|
||||
|
||||
String getDisplayName();
|
||||
|
||||
List<String> getDisplayLore();
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.configuration.gui;
|
||||
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface GUIAction {
|
||||
|
||||
enum ActionType {
|
||||
|
||||
COMMAND,
|
||||
CONSOLE,
|
||||
MESSAGE,
|
||||
SOUND,
|
||||
CLOSE
|
||||
|
||||
}
|
||||
|
||||
@Nullable ClickType getClickType();
|
||||
|
||||
@NotNull ActionType getActionType();
|
||||
|
||||
@NotNull String getActionContent();
|
||||
|
||||
void executeAction();
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.configuration.gui;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface GUIConfiguration {
|
||||
|
||||
|
||||
String getTitle();
|
||||
|
||||
int getLines();
|
||||
|
||||
Map<Integer, GUIItemDetail> getItems();
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.configuration.gui;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GUIItemDetail {
|
||||
|
||||
|
||||
ItemStack getIcon();
|
||||
|
||||
List<GUIAction> getActions();
|
||||
|
||||
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.data;
|
||||
|
||||
import cc.carm.lib.easysql.api.SQLManager;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public enum DatabaseTables {
|
||||
|
||||
USER_DATA("ub_data", new String[]{
|
||||
"`uuid` VARCHAR(36) NOT NULL PRIMARY KEY", // 用户的UUID
|
||||
"`backpack` VARCHAR(32) NOT NULL",// 背包组名
|
||||
"`type` VARCHAR(32) NOT NULL",// 背包内具体物品类型
|
||||
"`amount` INT(11) NOT NULL DEFAULT 0", // 该物品的数量
|
||||
"`sold` INT(11) NOT NULL DEFAULT 0", // 一周卖出次数
|
||||
"`day` DATE NOT NULL", // 记录卖出数量的所在天
|
||||
"PRIMARY KEY `data`(`uuid`,`backpack`,`type`)" // 联合主键索引
|
||||
}),
|
||||
;
|
||||
|
||||
String name;
|
||||
String[] columns;
|
||||
|
||||
DatabaseTables(String name, String[] columns) {
|
||||
this.name = name;
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
|
||||
public static void createTables(SQLManager sqlManager) throws SQLException {
|
||||
for (DatabaseTables value : DatabaseTables.values()) {
|
||||
sqlManager.createTable(value.getName())
|
||||
.setColumns(value.getColumns())
|
||||
.build().execute();
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String[] getColumns() {
|
||||
return columns;
|
||||
}
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class UBContentsData {
|
||||
|
||||
private final Map<String, UBItemData> contents;
|
||||
|
||||
public UBContentsData(Map<String, UBItemData> contents) {
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
public Map<String, UBItemData> getContents() {
|
||||
return this.contents;
|
||||
}
|
||||
|
||||
public UBItemData getItemData(String itemType) {
|
||||
return getContents().get(itemType);
|
||||
}
|
||||
|
||||
|
||||
public static UBContentsData emptyContents() {
|
||||
return new UBContentsData(new HashMap<>());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.data;
|
||||
|
||||
public class UBItemData {
|
||||
|
||||
int amount;
|
||||
int sold;
|
||||
|
||||
public UBItemData(int amount, int sold) {
|
||||
this.amount = amount;
|
||||
this.sold = sold;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public int getSold() {
|
||||
return sold;
|
||||
}
|
||||
|
||||
public void clearSold() {
|
||||
this.sold = 0;
|
||||
}
|
||||
|
||||
public static UBItemData emptyItemData() {
|
||||
return new UBItemData(0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.data;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface UBUserData {
|
||||
|
||||
|
||||
@NotNull UUID getUserUUID();
|
||||
|
||||
@Nullable UBContentsData getBackpack(String backpackID);
|
||||
|
||||
@NotNull Set<String> getBackpackIDs();
|
||||
|
||||
int getItemAmount(String backpackID, String typeID);
|
||||
|
||||
int getItemSold(String backpackID, String typeID);
|
||||
|
||||
Date getDataDay();
|
||||
|
||||
boolean isCurrentDay();
|
||||
|
||||
void updateDate();
|
||||
|
||||
void save() throws Exception;
|
||||
|
||||
}
|
||||
+18
@@ -1,4 +1,22 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.manager;
|
||||
|
||||
import cc.carm.plugin.ultrabackpack.api.data.UBUserData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface UBUserManager {
|
||||
|
||||
@Nullable
|
||||
UBUserData getData(@NotNull UUID userUUID);
|
||||
|
||||
@NotNull
|
||||
UBUserData getData(@NotNull Player player);
|
||||
|
||||
@NotNull
|
||||
UBUserData loaData(@NotNull UUID userUUID);
|
||||
|
||||
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.storage;
|
||||
|
||||
import cc.carm.plugin.ultrabackpack.api.data.UBUserData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface UBStorage {
|
||||
|
||||
|
||||
boolean initialize();
|
||||
|
||||
@NotNull
|
||||
UBUserData loadData(@NotNull UUID uuid) throws Exception;
|
||||
|
||||
void saveUserData(@NotNull UBUserData data) throws Exception;
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package cc.carm.plugin.ultrabackpack.api.user;
|
||||
|
||||
public interface UBUserData {
|
||||
}
|
||||
Reference in New Issue
Block a user