-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
236 additions
and
112 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/com/legendaryrealms/shop/Manager/PlayerDataManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.legendaryrealms.shop.Manager; | ||
|
||
import com.legendaryrealms.shop.Data.Player.PlayerData; | ||
import com.legendaryrealms.shop.LegendaryDailyShop; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class PlayerDataManager { | ||
|
||
private HashMap<String, PlayerData> cache; | ||
public PlayerDataManager(){ | ||
cache=new HashMap<>(); | ||
} | ||
public PlayerData getData(String player){ | ||
if (cache.containsKey(player)) { | ||
return cache.get(player); | ||
} | ||
PlayerData data= LegendaryDailyShop.getInstance().getDataProvider().loadData(player); | ||
cache.put(player,data); | ||
return data; | ||
} | ||
|
||
public void saveAndRemve(String player){ | ||
if (cache.containsKey(player)){ | ||
PlayerData data=cache.remove(player); | ||
LegendaryDailyShop.getInstance().getDataProvider().saveData(data); | ||
} | ||
} | ||
public void saveAll() | ||
{ | ||
int a=0; | ||
for (Map.Entry<String,PlayerData> entry:cache.entrySet()){ | ||
PlayerData data=entry.getValue(); | ||
LegendaryDailyShop.getInstance().getDataProvider().saveData(data); | ||
a++; | ||
} | ||
System.out.println("成功保存 "+a+" 个玩家数据"); | ||
} | ||
} |
Oops, something went wrong.