Skip to content

Commit

Permalink
NotNullでnull許容しない変数を明示+個人用ストレージの作成を簡単に
Browse files Browse the repository at this point in the history
  • Loading branch information
Arisa9006 committed Nov 25, 2024
1 parent 1bdfe05 commit 5457ea5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
22 changes: 21 additions & 1 deletion src/main/java/dev/felnull/Data/GroupData.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -12,7 +15,7 @@ public class GroupData {
public boolean isPrivate; //個人用グループか否か
public StorageData storageData; //グループ保有のストレージデータ null許容

public GroupData (String groupName, Set<Player> playerList, Map<Player,String[]> playerPermission, boolean isPrivate, StorageData storageData) {
public GroupData (@NotNull String groupName,@NotNull Set<Player> playerList,@NotNull Map<Player,String[]> playerPermission, boolean isPrivate, StorageData storageData) {
this.groupName = groupName;
this.playerList = playerList;
this.playerPermission = playerPermission;
Expand All @@ -22,4 +25,21 @@ public GroupData (String groupName, Set<Player> playerList, Map<Player,String[]>
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;
}

}
13 changes: 9 additions & 4 deletions src/main/java/dev/felnull/Data/StorageData.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -10,11 +11,15 @@ public class StorageData {
public GroupData groupData;//ストレージの所属グループ
public final Set<String> requireBankPermission;//ストレージ直下の金庫の要求パーミッション(BukkitPermではない)
public int bankMoney;//ストレージ付属金庫の値
public Map<String,InventoryData> storageInventry;//ストレージに含まれているインベントリデータ キーのStringはページ名
@NotNull
public Map<String,InventoryData> storageInventory;//ストレージに含まれているインベントリデータ キーのStringはページ名

public StorageData(Set<String> requireBankPermission, Map<String,InventoryData> storageInventry, int bankMoney) {
public StorageData(@NotNull Set<String> requireBankPermission, Map<String,InventoryData> storageInventory, int bankMoney) {
this.requireBankPermission = requireBankPermission;
this.storageInventry = storageInventry;
if(storageInventory == null){
storageInventory = new HashMap<>();
}
this.storageInventory = storageInventory;
this.bankMoney = bankMoney;
}
}

0 comments on commit 5457ea5

Please sign in to comment.