5555public class AdvancedCoreUser {
5656
5757 @ Getter
58- private boolean cacheData = true ;
58+ private UserDataFetchMode userDataFetchMode = UserDataFetchMode . DEFAULT ;
5959
6060 @ Setter
6161 private UserData data ;
@@ -68,19 +68,11 @@ public class AdvancedCoreUser {
6868 @ Getter
6969 private AdvancedCorePlugin plugin = null ;
7070
71- @ Getter
72- private boolean tempCache = false ;
73-
7471 /** The uuid. */
7572 private String uuid ;
7673
77- @ Getter
78- private boolean waitForCache = true ;
79-
8074 public AdvancedCoreUser (AdvancedCorePlugin plugin , AdvancedCoreUser user ) {
81- this .waitForCache = user .waitForCache ;
82- this .cacheData = user .cacheData ;
83- this .tempCache = user .tempCache ;
75+ this .userDataFetchMode = user .userDataFetchMode ;
8476 this .data = user .getUserData ();
8577 this .uuid = user .getUUID ();
8678 this .playerName = user .getPlayerName ();
@@ -222,11 +214,6 @@ public void run() {
222214 });
223215 }
224216
225- public AdvancedCoreUser cacheData () {
226- cacheData = true ;
227- return this ;
228- }
229-
230217 public void cacheIfNeeded () {
231218 plugin .getUserManager ().getDataManager ().cacheUserIfNeeded (UUID .fromString (uuid ));
232219 }
@@ -326,8 +313,8 @@ public void run() {
326313 }
327314 }
328315
329- public AdvancedCoreUser dontCache ( ) {
330- cacheData = false ;
316+ public AdvancedCoreUser userDataFetechMode ( UserDataFetchMode mode ) {
317+ this . userDataFetchMode = mode ;
331318 return this ;
332319 }
333320
@@ -382,7 +369,7 @@ public String getChoicePreference(String rewardName) {
382369 }
383370
384371 public ArrayList <String > getChoicePreferenceData () {
385- return getData ().getStringList ("ChoicePreference" , cacheData , waitForCache );
372+ return getData ().getStringList ("ChoicePreference" , userDataFetchMode );
386373 }
387374
388375 public UserData getData () {
@@ -393,15 +380,15 @@ public UserData getData() {
393380 }
394381
395382 public String getInputMethod () {
396- return getUserData ().getString ("InputMethod" , cacheData , waitForCache );
383+ return getUserData ().getString ("InputMethod" , userDataFetchMode );
397384 }
398385
399386 public UUID getJavaUUID () {
400387 return UUID .fromString (uuid );
401388 }
402389
403390 public long getLastOnline () {
404- String d = getData ().getString ("LastOnline" , cacheData , waitForCache );
391+ String d = getData ().getString ("LastOnline" , userDataFetchMode );
405392 long time = 0 ;
406393 if (d != null && !d .equals ("" ) && !d .equals ("null" )) {
407394 time = Long .valueOf (d );
@@ -435,7 +422,7 @@ public OfflinePlayer getOfflinePlayer() {
435422 }
436423
437424 public ArrayList <String > getOfflineRewards () {
438- return getUserData ().getStringList (plugin .getUserManager ().getOfflineRewardsPath (), cacheData , waitForCache );
425+ return getUserData ().getStringList (plugin .getUserManager ().getOfflineRewardsPath (), userDataFetchMode );
439426 }
440427
441428 /**
@@ -463,18 +450,18 @@ public String getPlayerName() {
463450 if (playerName != null ) {
464451 return playerName ;
465452 }
466- if (isTempCache ()) {
467- return getUserData ().getString ("PlayerName" , false , false );
453+ if (userDataFetchMode . allowTempCache ()) {
454+ return getUserData ().getString ("PlayerName" , UserDataFetchMode . TEMP_ONLY );
468455 }
469456 return "" ;
470457 }
471458
472459 public int getRepeatAmount (Reward reward ) {
473- return getData ().getInt ("Repeat" + reward .getName (), cacheData , waitForCache );
460+ return getData ().getInt ("Repeat" + reward .getName (), userDataFetchMode );
474461 }
475462
476463 public HashMap <String , Long > getTimedRewards () {
477- ArrayList <String > timedReward = getUserData ().getStringList ("TimedRewards" , cacheData , waitForCache );
464+ ArrayList <String > timedReward = getUserData ().getStringList ("TimedRewards" , userDataFetchMode );
478465 HashMap <String , Long > timedRewards = new HashMap <>();
479466 for (String str : timedReward ) {
480467 if (str != null && !str .equals ("null" )) {
@@ -492,7 +479,7 @@ public HashMap<String, Long> getTimedRewards() {
492479 }
493480
494481 public ArrayList <String > getUnClaimedChoices () {
495- return getData ().getStringList ("UnClaimedChoices" , cacheData , waitForCache );
482+ return getData ().getStringList ("UnClaimedChoices" , userDataFetchMode );
496483 }
497484
498485 public UserData getUserData () {
@@ -723,7 +710,7 @@ public boolean isBanned() {
723710 }
724711
725712 public boolean isBedrockUser () {
726- return getData ().getBoolean ("isBedrock" , cacheData , waitForCache );
713+ return getData ().getBoolean ("isBedrock" , userDataFetchMode );
727714 }
728715
729716 public void setBedrockUser (boolean isBedrock ) {
@@ -738,7 +725,7 @@ public boolean isCheckWorld() {
738725 if (!plugin .isLoadUserData ()) {
739726 return false ;
740727 }
741- return Boolean .valueOf (getData ().getString ("CheckWorld" , true ));
728+ return Boolean .valueOf (getData ().getString ("CheckWorld" , userDataFetchMode ));
742729 }
743730
744731 public boolean isInWorld (ArrayList <String > worlds ) {
@@ -1211,6 +1198,11 @@ public void setUnClaimedChoice(ArrayList<String> rewards) {
12111198 public void setUserInputMethod (InputMethod method ) {
12121199 setInputMethod (method .toString ());
12131200 }
1201+
1202+ @ Deprecated
1203+ public void dontCache () {
1204+ userDataFetchMode = UserDataFetchMode .NO_CACHE ;
1205+ }
12141206
12151207 /**
12161208 * Sets the uuid.
@@ -1221,27 +1213,21 @@ public void setUUID(String uuid) {
12211213 this .uuid = uuid ;
12221214 }
12231215
1224- public void setWaitForCache (boolean b ) {
1225- waitForCache = b ;
1226- }
1227-
12281216 public AdvancedCoreUser tempCache () {
1229- tempCache = true ;
12301217 getUserData ().tempCache ();
12311218 return this ;
12321219 }
12331220
12341221 public void updateName (boolean force ) {
12351222 if (getData ().hasData () || force ) {
1236- String playerName = getData ().getString ("PlayerName" , true );
1223+ String playerName = getData ().getString ("PlayerName" , userDataFetchMode );
12371224 if (playerName == null || !playerName .equals (getPlayerName ())) {
12381225 getData ().setString ("PlayerName" , getPlayerName (), true );
12391226 }
12401227 }
12411228 }
12421229
12431230 public void updateTempCacheWithColumns (ArrayList <Column > cols ) {
1244- tempCache = true ;
12451231 getUserData ().updateTempCacheWithColumns (cols );
12461232 }
12471233
0 commit comments