Skip to content

Commit 3deefab

Browse files
committed
index実装とGroup_UUID追加
1 parent c61fea7 commit 3deefab

File tree

7 files changed

+332
-211
lines changed

7 files changed

+332
-211
lines changed

src/main/java/dev/felnull/Data/GroupData.java

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,57 @@
44
import org.bukkit.entity.Player;
55
import org.jetbrains.annotations.NotNull;
66

7-
import java.util.HashMap;
8-
import java.util.HashSet;
9-
import java.util.Map;
10-
import java.util.Set;
7+
import javax.annotation.Nullable;
8+
import java.util.*;
119

1210
public class GroupData {
13-
public final String groupName; //グループ名 プレイヤー個人の場合はプレイヤーUUID
11+
public final String groupName; // グループ名(表示用・識別用)
12+
public final String groupUUID; // グループ固有のUUID(内部識別子)
1413
public String displayName;
15-
public Set<OfflinePlayer> playerList; //グループ所属のプレイヤーリスト 最低1つは格納されるはず
16-
public Map<OfflinePlayer,String[]> playerPermission; //プレイヤーが保持している役職
17-
public boolean isPrivate; //個人用グループか否か
18-
public StorageData storageData; //グループ保有のストレージデータ null許容
14+
public Set<OfflinePlayer> playerList; // 所属プレイヤー
15+
public Map<OfflinePlayer, String[]> playerPermission; // 役職
16+
public boolean isPrivate; // 個人グループか
17+
public StorageData storageData; // ストレージ情報
1918
public String ownerPlugin;
2019
public long version = 0;
2120

22-
public GroupData (@NotNull String groupName, @NotNull String displayName,@NotNull Set<OfflinePlayer> playerList,@NotNull Map<OfflinePlayer,String[]> playerPermission, boolean isPrivate, StorageData storageData, String ownerPlugin) {
21+
// コンストラクタ(グループ新規作成用)
22+
public GroupData(@NotNull String groupName, @NotNull String displayName, @NotNull Set<OfflinePlayer> playerList,
23+
@NotNull Map<OfflinePlayer, String[]> playerPermission, boolean isPrivate,
24+
StorageData storageData, String ownerPlugin, @Nullable String groupUUID) {
2325
this.groupName = groupName;
2426
this.displayName = displayName;
2527
this.playerList = playerList;
2628
this.playerPermission = playerPermission;
2729
this.isPrivate = isPrivate;
28-
storageData.groupName = groupName;
29-
storageData.groupData = this;
30-
this.storageData = storageData;
3130
this.ownerPlugin = ownerPlugin;
32-
}
3331

34-
public GroupData (@NotNull OfflinePlayer player, StorageData storageData, String ownerPlugin) {
32+
this.groupUUID = groupUUID != null ? groupUUID : UUID.randomUUID().toString();
33+
34+
this.storageData = storageData;
35+
if (this.storageData != null) {
36+
this.storageData.groupName = this.groupName;
37+
this.storageData.groupData = this;
38+
}
39+
}
3540

41+
// 個人用グループ生成用(UUID自動生成)
42+
public GroupData(@NotNull OfflinePlayer player, StorageData storageData, String ownerPlugin) {
3643
this.groupName = player.getUniqueId().toString();
37-
//引数で得たプレイヤーをメンバに追加してowner権限を付与する
38-
playerList = new HashSet<>();
39-
playerPermission = new HashMap<>();
40-
playerList.add(player);
41-
String[] permission = {GroupPermENUM.OWNER.getPermName()};
42-
playerPermission.put(player, permission );
43-
//個人用を想定したコンストラクタなのでtrue
44+
this.groupUUID = UUID.randomUUID().toString();
45+
this.displayName = player.getName(); // 任意で変更可能
46+
47+
this.playerList = new HashSet<>();
48+
this.playerPermission = new HashMap<>();
49+
this.playerList.add(player);
50+
this.playerPermission.put(player, new String[]{GroupPermENUM.OWNER.getPermName()});
4451
this.isPrivate = true;
52+
this.ownerPlugin = ownerPlugin;
4553

46-
storageData.groupName = groupName;
47-
storageData.groupData = this;
4854
this.storageData = storageData;
49-
this.ownerPlugin = ownerPlugin;
55+
if (this.storageData != null) {
56+
this.storageData.groupName = this.groupName;
57+
this.storageData.groupData = this;
58+
}
5059
}
51-
52-
}
60+
}

0 commit comments

Comments
 (0)