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
3c5f3d41
Commit
3c5f3d41
authored
Apr 26, 2022
by
BaiSugar
Browse files
remove test avatar
parent
c6bd1fa5
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/GiveAllCommand.java
View file @
3c5f3d41
...
...
@@ -14,20 +14,22 @@ import emu.grasscutter.game.inventory.ItemType;
import
java.util.*
;
@Command
(
label
=
"giveall"
,
usage
=
"giveall [player] <amount>"
,
description
=
"Gives all items"
,
aliases
=
{
"givea"
},
permission
=
"player.giveall"
,
threading
=
true
)
description
=
"Gives all items"
,
aliases
=
{
"givea"
},
permission
=
"player.giveall"
,
threading
=
true
)
public
class
GiveAllCommand
implements
CommandHandler
{
@Override
public
void
execute
(
GenshinPlayer
sender
,
List
<
String
>
args
)
{
int
target
,
amount
=
99999
;
int
target
,
amount
=
99999
;
if
(
sender
==
null
){
CommandHandler
.
sendMessage
(
null
,
"Run this command in-game"
);
switch
(
args
.
size
())
{
case
0
:
// *no args*
if
(
sender
==
null
)
{
CommandHandler
.
sendMessage
(
null
,
"This usage can only be run in-game"
);
return
;
}
switch
(
args
.
size
())
{
default
:
// *no args*
target
=
sender
.
getUid
();
break
;
case
1
:
// [player]
try
{
target
=
Integer
.
parseInt
(
args
.
get
(
0
));
...
...
@@ -40,6 +42,7 @@ public class GiveAllCommand implements CommandHandler {
return
;
}
break
;
case
2
:
// [player] [amount]
try
{
target
=
Integer
.
parseInt
(
args
.
get
(
0
));
...
...
@@ -54,6 +57,10 @@ public class GiveAllCommand implements CommandHandler {
return
;
}
break
;
default
:
// invalid
CommandHandler
.
sendMessage
(
null
,
"Usage: giveall [player] <amount>"
);
return
;
}
GenshinPlayer
targetPlayer
=
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
);
...
...
@@ -62,47 +69,121 @@ public class GiveAllCommand implements CommandHandler {
return
;
}
this
.
Get
AllItem
(
targetPlayer
,
amount
);
CommandHandler
.
sendMessage
(
sender
,
"
Done! or Gett
ing all items done"
);
this
.
give
AllItem
s
(
targetPlayer
,
amount
);
CommandHandler
.
sendMessage
(
sender
,
"
Giv
ing all items done"
);
}
public
void
GetAllItem
(
GenshinPlayer
player
,
int
amount
){
CommandHandler
.
sendMessage
(
player
,
"Getting all item...."
);
public
void
giveAllItems
(
GenshinPlayer
player
,
int
amount
)
{
CommandHandler
.
sendMessage
(
player
,
"Giving all items..."
);
for
(
AvatarData
avatarData:
GenshinData
.
getAvatarDataMap
().
values
())
{
//Exclude test avatar
if
(
isTestAvatar
(
avatarData
.
getId
()))
continue
;
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarData
);
avatar
.
setLevel
(
90
);
avatar
.
setPromoteLevel
(
6
);
for
(
int
i
=
1
;
i
<=
6
;
++
i
)
{
avatar
.
getTalentIdList
().
add
((
avatar
.
getAvatarId
()
-
10000000
)
*
10
+
i
);
}
// This will handle stats and talents
avatar
.
recalcStats
();
player
.
addAvatar
(
avatar
);
}
Collection
<
GenshinItem
>
genshinItemList
=
new
LinkedList
<>();
//some test items
List
<
GenshinItem
>
genshinItemList
=
new
ArrayList
<>();
for
(
ItemData
itemdata:
GenshinData
.
getItemDataMap
().
values
())
{
if
(
itemdata
.
getId
()
>
1000
&&
itemdata
.
getId
()
<=
1099
)
continue
;
//is avatar
//Exclude test item
if
(
isTestItem
(
itemdata
.
getId
()))
continue
;
if
(
itemdata
.
isEquip
())
{
for
(
int
i
=
0
;
i
<
2
0
;
i
++)
{
for
(
int
i
=
0
;
i
<
1
0
;
++
i
)
{
GenshinItem
genshinItem
=
new
GenshinItem
(
itemdata
);
if
(
itemdata
.
getItemType
()
==
ItemType
.
ITEM_WEAPON
){
if
(
itemdata
.
getItemType
()
==
ItemType
.
ITEM_WEAPON
)
{
genshinItem
.
setLevel
(
90
);
genshinItem
.
setPromoteLevel
(
6
);
genshinItem
.
setRefinement
(
4
);
}
genshinItemList
.
add
(
genshinItem
);
}
}
else
{
}
else
{
GenshinItem
genshinItem
=
new
GenshinItem
(
itemdata
);
genshinItem
.
setCount
(
amount
);
genshinItemList
.
add
(
genshinItem
);
}
}
player
.
getInventory
().
addItems
(
genshinItemList
);
int
packetNum
=
20
;
int
itemLength
=
genshinItemList
.
size
();
int
number
=
itemLength
/
packetNum
;
int
remainder
=
itemLength
%
packetNum
;
int
offset
=
0
;
for
(
int
i
=
0
;
i
<
packetNum
;
++
i
)
{
if
(
remainder
>
0
)
{
player
.
getInventory
().
addItems
(
genshinItemList
.
subList
(
i
*
number
+
offset
,
(
i
+
1
)
*
number
+
offset
+
1
));
--
remainder
;
++
offset
;
}
else
{
player
.
getInventory
().
addItems
(
genshinItemList
.
subList
(
i
*
number
+
offset
,
(
i
+
1
)
*
number
+
offset
));
}
}
}
for
(
AvatarData
avatarData:
GenshinData
.
getAvatarDataMap
().
values
())
{
if
(
avatarData
.
getId
()
==
10000001
||
avatarData
.
getId
()
>=
10000099
)
continue
;
// Calculate ascension level.
int
ascension
=
(
int
)
Math
.
ceil
(
90
/
10
f
)
-
3
;
GenshinAvatar
avatar
=
new
GenshinAvatar
(
avatarData
);
avatar
.
setLevel
(
90
);
avatar
.
setPromoteLevel
(
ascension
);
for
(
int
i
=
1
;
i
<=
6
;
i
++){
avatar
.
getTalentIdList
().
add
((
avatar
.
getAvatarId
()-
10000000
)*
10
+
i
);
//(10000058-10000000)*10+i
public
boolean
isTestAvatar
(
int
avatarId
)
{
return
avatarId
<
10000002
||
avatarId
>=
11000000
;
}
// This will handle stats and talents
avatar
.
recalcStats
();
player
.
addAvatar
(
avatar
);
public
boolean
isTestItem
(
int
itemId
)
{
for
(
Range
range:
testItemRanges
)
{
if
(
range
.
check
(
itemId
))
{
return
true
;
}
}
if
(
testItemsList
.
contains
(
itemId
))
{
return
true
;
}
return
false
;
}
static
class
Range
{
private
int
min
;
private
int
max
;
public
Range
(
int
min
,
int
max
)
{
if
(
min
>
max
){
min
^=
max
;
max
^=
min
;
min
^=
max
;
}
this
.
min
=
min
;
this
.
max
=
max
;
}
public
boolean
check
(
int
value
)
{
return
value
>=
this
.
min
&&
value
<=
this
.
max
;
}
}
private
static
final
Range
[]
testItemRanges
=
new
Range
[]
{
new
Range
(
106
,
139
),
new
Range
(
1000
,
1099
),
new
Range
(
2001
,
2008
),
new
Range
(
2017
,
2029
),
// new Range(108001, 108387) //food
};
private
static
final
Integer
[]
testItemsIds
=
new
Integer
[]
{
210
,
211
,
314
,
315
,
317
,
1005
,
1007
,
1105
,
1107
,
1201
,
1202
,
2800
,
100001
,
100002
,
100244
,
100305
,
100312
,
100313
,
101212
,
11411
,
11506
,
11507
,
11508
,
12505
,
12506
,
12508
,
12509
,
13503
,
13506
,
14411
,
14503
,
14505
,
14508
,
15411
,
15504
,
15505
,
15506
,
15508
,
20001
,
10002
,
10003
,
10004
,
10005
,
10006
,
10008
//9
};
private
static
final
Collection
<
Integer
>
testItemsList
=
Arrays
.
asList
(
testItemsIds
);
}
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