diff --git a/src/main/java/dev/felnull/Data/GroupData.java b/src/main/java/dev/felnull/Data/GroupData.java index b047028..060904b 100644 --- a/src/main/java/dev/felnull/Data/GroupData.java +++ b/src/main/java/dev/felnull/Data/GroupData.java @@ -1,7 +1,10 @@ package dev.felnull.Data; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -12,7 +15,7 @@ public class GroupData { public boolean isPrivate; //個人用グループか否か public StorageData storageData; //グループ保有のストレージデータ null許容 - public GroupData (String groupName, Set playerList, Map playerPermission, boolean isPrivate, StorageData storageData) { + public GroupData (@NotNull String groupName,@NotNull Set playerList,@NotNull Map playerPermission, boolean isPrivate, StorageData storageData) { this.groupName = groupName; this.playerList = playerList; this.playerPermission = playerPermission; @@ -22,4 +25,21 @@ public GroupData (String groupName, Set playerList, Map this.storageData = storageData; } + public GroupData (@NotNull String groupName,@NotNull Player player, boolean isPrivate, StorageData storageData) { + this.groupName = groupName; + + //引数で得たプレイヤーをメンバに追加してowner権限を付与する + playerList = new HashSet<>(); + playerPermission = new HashMap<>(); + playerList.add(player); + String[] permission = {GroupPermENUM.OWNER.getPermName()}; + playerPermission.put(player, permission ); + //個人用を想定したコンストラクタなのでtrue + this.isPrivate = true; + + storageData.groupName = groupName; + storageData.groupData = this; + this.storageData = storageData; + } + } diff --git a/src/main/java/dev/felnull/Data/StorageData.java b/src/main/java/dev/felnull/Data/StorageData.java index e110ba8..e1bd17a 100644 --- a/src/main/java/dev/felnull/Data/StorageData.java +++ b/src/main/java/dev/felnull/Data/StorageData.java @@ -1,7 +1,8 @@ package dev.felnull.Data; -import org.bukkit.inventory.Inventory; +import org.jetbrains.annotations.NotNull; +import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -10,11 +11,15 @@ public class StorageData { public GroupData groupData;//ストレージの所属グループ public final Set requireBankPermission;//ストレージ直下の金庫の要求パーミッション(BukkitPermではない) public int bankMoney;//ストレージ付属金庫の値 - public Map storageInventry;//ストレージに含まれているインベントリデータ キーのStringはページ名 + @NotNull + public Map storageInventory;//ストレージに含まれているインベントリデータ キーのStringはページ名 - public StorageData(Set requireBankPermission, Map storageInventry, int bankMoney) { + public StorageData(@NotNull Set requireBankPermission, Map storageInventory, int bankMoney) { this.requireBankPermission = requireBankPermission; - this.storageInventry = storageInventry; + if(storageInventory == null){ + storageInventory = new HashMap<>(); + } + this.storageInventory = storageInventory; this.bankMoney = bankMoney; } }