Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
ee3a0c32
Commit
ee3a0c32
authored
Apr 27, 2022
by
Kengxxiao
Committed by
Melledy
Apr 27, 2022
Browse files
use better shop config structure
parent
3e0ccbbb
Changes
4
Show whitespace changes
Inline
Side-by-side
data/Shop.json
View file @
ee3a0c32
[
{
"shopId"
:
1004
,
"items"
:
[
{
"goodsId"
:
1004202
,
"goodsItem"
:
{
"Id"
:
202
,
...
...
@@ -11,16 +13,23 @@
"beginTime"
:
1575129600
,
"endTime"
:
2051193600
,
"minLevel"
:
1
,
"maxLevel"
:
99
"maxLevel"
:
99
,
"costItemList"
:
[
{
"Id"
:
223
,
"Count"
:
100
}
]
},
{
"shopId"
:
1004
,
"goodsId"
:
10048006
,
"goodsItem"
:
{
"Id"
:
108006
,
"Count"
:
20
},
"scoin"
:
1
,
"scoin"
:
100
,
"hcoin"
:
100
,
"mcoin"
:
100
,
"buyLimit"
:
50000
,
"beginTime"
:
1575129600
,
"endTime"
:
2051193600
,
...
...
@@ -28,7 +37,6 @@
"maxLevel"
:
99
},
{
"shopId"
:
1004
,
"goodsId"
:
10048033
,
"goodsItem"
:
{
"Id"
:
108033
,
...
...
@@ -40,47 +48,7 @@
"endTime"
:
2051193600
,
"minLevel"
:
1
,
"maxLevel"
:
99
},
{
"shopId"
:
1004
,
"goodsId"
:
10040008
,
"goodsItem"
:
{
"Id"
:
220008
,
"Count"
:
1
},
"scoin"
:
1
,
"buyLimit"
:
1
,
"beginTime"
:
1575129600
,
"endTime"
:
2051193600
,
"minLevel"
:
1
,
"maxLevel"
:
99
},
{
"shopId"
:
1004
,
"goodsId"
:
10044003
,
"goodsItem"
:
{
"Id"
:
104003
,
"Count"
:
200
},
"scoin"
:
1
,
"buyLimit"
:
50000
,
"beginTime"
:
1575129600
,
"endTime"
:
2051193600
,
"minLevel"
:
1
,
"maxLevel"
:
99
},
{
"shopId"
:
1004
,
"goodsId"
:
10044013
,
"goodsItem"
:
{
"Id"
:
104013
,
"Count"
:
200
},
"scoin"
:
1
,
"buyLimit"
:
50000
,
"beginTime"
:
1575129600
,
"endTime"
:
2051193600
,
"minLevel"
:
1
,
"maxLevel"
:
99
}
]
}
]
\ No newline at end of file
src/main/java/emu/grasscutter/game/shop/ShopInfo.java
View file @
ee3a0c32
...
...
@@ -6,23 +6,22 @@ import java.util.ArrayList;
import
java.util.List
;
public
class
ShopInfo
{
public
int
shopId
=
1004
;
public
int
goodsId
=
0
;
public
ItemParamData
goodsItem
;
public
int
scoin
=
0
;
public
List
<
ItemParamData
>
costItemList
;
public
int
boughtNum
=
0
;
public
int
buyLimit
=
0
;
public
int
beginTime
=
0
;
public
int
endTime
=
1924992000
;
public
int
nextRefreshTime
=
1924992000
;
public
int
minLevel
=
0
;
public
int
maxLevel
=
61
;
public
List
<
Integer
>
preGoodsIdList
=
new
ArrayList
<>();
public
int
mcoin
=
0
;
public
int
hcoin
=
0
;
public
int
disableType
=
0
;
public
int
secondarySheetId
=
0
;
private
int
goodsId
=
0
;
private
ItemParamData
goodsItem
;
private
int
scoin
=
0
;
private
List
<
ItemParamData
>
costItemList
;
private
int
boughtNum
=
0
;
private
int
buyLimit
=
0
;
private
int
beginTime
=
0
;
private
int
endTime
=
1924992000
;
private
int
nextRefreshTime
=
1924992000
;
private
int
minLevel
=
0
;
private
int
maxLevel
=
61
;
private
List
<
Integer
>
preGoodsIdList
=
new
ArrayList
<>();
private
int
mcoin
=
0
;
private
int
hcoin
=
0
;
private
int
disableType
=
0
;
private
int
secondarySheetId
=
0
;
public
int
getHcoin
()
{
return
hcoin
;
...
...
@@ -64,14 +63,6 @@ public class ShopInfo {
this
.
secondarySheetId
=
secondarySheetId
;
}
public
int
getShopId
()
{
return
shopId
;
}
public
void
setShopId
(
int
shopId
)
{
this
.
shopId
=
shopId
;
}
public
int
getGoodsId
()
{
return
goodsId
;
}
...
...
src/main/java/emu/grasscutter/game/shop/ShopManager.java
View file @
ee3a0c32
...
...
@@ -7,7 +7,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
java.io.FileReader
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
...
...
@@ -29,13 +28,10 @@ public class ShopManager {
public
synchronized
void
load
()
{
try
(
FileReader
fileReader
=
new
FileReader
(
Grasscutter
.
getConfig
().
DATA_FOLDER
+
"Shop.json"
))
{
getShopData
().
clear
();
List
<
Shop
Info
>
banners
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
TypeToken
.
getParameterized
(
Collection
.
class
,
Shop
Info
.
class
).
getType
());
List
<
Shop
Table
>
banners
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
TypeToken
.
getParameterized
(
Collection
.
class
,
Shop
Table
.
class
).
getType
());
if
(
banners
.
size
()
>
0
)
{
for
(
ShopInfo
shopInfo
:
banners
)
{
if
(!
getShopData
().
containsKey
(
shopInfo
.
getShopId
()))
getShopData
().
put
(
shopInfo
.
getShopId
(),
new
ArrayList
<>());
getShopData
().
get
(
shopInfo
.
getShopId
()).
add
(
shopInfo
);
Grasscutter
.
getLogger
().
info
(
String
.
format
(
"Shop add: id [%d], data [%d*%d]"
,
shopInfo
.
getShopId
(),
shopInfo
.
getGoodsItem
().
getId
(),
shopInfo
.
getGoodsItem
().
getCount
()));
for
(
ShopTable
shopTable
:
banners
)
{
getShopData
().
put
(
shopTable
.
getShopId
(),
shopTable
.
getItems
());
}
Grasscutter
.
getLogger
().
info
(
"Shop data successfully loaded."
);
}
else
{
...
...
src/main/java/emu/grasscutter/game/shop/ShopTable.java
0 → 100644
View file @
ee3a0c32
package
emu.grasscutter.game.shop
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ShopTable
{
private
int
shopId
;
private
List
<
ShopInfo
>
items
=
new
ArrayList
<>();
public
int
getShopId
()
{
return
shopId
;
}
public
void
setShopId
(
int
shopId
)
{
this
.
shopId
=
shopId
;
}
public
List
<
ShopInfo
>
getItems
()
{
return
items
;
}
public
void
setItems
(
List
<
ShopInfo
>
items
)
{
this
.
items
=
items
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment