-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathAccountWideData.java
More file actions
132 lines (110 loc) · 4.74 KB
/
AccountWideData.java
File metadata and controls
132 lines (110 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package com.flippingutilities.model;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.util.*;
@Data
@Slf4j
public class AccountWideData {
List<Option> options = new ArrayList<>();
List<Section> sections = new ArrayList<>();
Map<String, Set<Integer>> favoriteItemLists = new HashMap<>();
boolean shouldMakeNewAdditions = true;
boolean enhancedSlots = true;
String jwt;
public boolean setDefaults() {
boolean didChangeData = changeOldPropertyNames();
if (options.isEmpty()) {
setDefaultOptions();
shouldMakeNewAdditions = false;
didChangeData = true;
}
//adding wiki options to users' existing options only once and making sure that its not added again by setting shouldMakeNewAdditions.
//i need to use that flag so i don't add it multiple times in case a user deletes those options.
boolean alreadyHasWikiOptions = options.stream().anyMatch(o -> o.getProperty().equals(Option.WIKI_BUY) || o.getProperty().equals(Option.WIKI_SELL));
if (shouldMakeNewAdditions && !alreadyHasWikiOptions) {
options.add(0, new Option("n", Option.WIKI_SELL, "+0", false));
options.add(0, new Option("j", Option.WIKI_BUY, "+0", false));
shouldMakeNewAdditions = false;
didChangeData = true;
}
if (sections.isEmpty()) {
didChangeData = true;
setDefaultFlippingItemPanelSections();
}
if (favoriteItemLists.isEmpty()) {
didChangeData = true;
favoriteItemLists.put("DEFAULT", new HashSet<>());
}
return didChangeData;
}
private boolean changeOldPropertyNames() {
boolean changedOldNames = false;
for (Option o : options) {
if (o.getProperty().equals("marg sell")) {
o.setProperty(Option.INSTA_BUY);
changedOldNames = true;
}
if (o.getProperty().equals("marg buy")) {
o.setProperty(Option.INSTA_SELL);
changedOldNames = true;
}
}
return changedOldNames;
}
private void setDefaultOptions() {
options.add(new Option("n", Option.WIKI_SELL, "+0", false));
options.add(new Option("j", Option.WIKI_BUY, "+0", false));
options.add(new Option("p", Option.INSTA_BUY, "+0", false));
options.add(new Option("l", Option.INSTA_SELL, "+0", false));
options.add(new Option("o", Option.LAST_BUY, "+0", false));
options.add(new Option("u", Option.LAST_SELL, "+0", false));
options.add(new Option("p", Option.GE_LIMIT, "+0", true));
options.add(new Option("l", Option.REMAINING_LIMIT, "+0", true));
options.add(new Option("o", Option.CASHSTACK, "+0", true));
}
private void setDefaultFlippingItemPanelSections() {
Section importantSection = new Section("Important");
Section otherSection = new Section("Other");
importantSection.defaultExpanded = true;
importantSection.showLabel(Section.WIKI_BUY_PRICE, true);
importantSection.showLabel(Section.WIKI_SELL_PRICE, true);
importantSection.showLabel(Section.LAST_BUY_PRICE, true);
importantSection.showLabel(Section.LAST_SELL_PRICE, true);
importantSection.showLabel(Section.LAST_INSTA_SELL_PRICE, true);
importantSection.showLabel(Section.LAST_INSTA_BUY_PRICE, true);
otherSection.showLabel(Section.WIKI_PROFIT_EACH, true);
otherSection.showLabel(Section.MARGIN_CHECK_PROFIT_EACH, true);
otherSection.showLabel(Section.POTENTIAL_PROFIT, true);
otherSection.showLabel(Section.REMAINING_GE_LIMIT, true);
otherSection.showLabel(Section.ROI, true);
otherSection.showLabel(Section.GE_LIMIT_REFRESH_TIMER, true);
sections.add(importantSection);
sections.add(otherSection);
}
public Set<Integer> getFavoriteListData(String listName) {
return favoriteItemLists.get(listName);
}
public Set<String> getAllListNames () {
return favoriteItemLists.keySet();
}
public boolean addNewFavoriteList (String listName){
if (!favoriteItemLists.containsKey(listName)){
favoriteItemLists.put(listName,new HashSet<>());
return true;
}
else{
return false;
}
}
public void addItemToFavoriteList(String listName, int itemId){
Set<Integer> list = favoriteItemLists.get(listName);
list.add(itemId);
}
public void removeItemFromList(String listName, int itemId) {
Set<Integer> set = favoriteItemLists.get(listName);
set.remove(itemId);
}
public void deleteItemList(String listName){
favoriteItemLists.remove(listName);
}
}