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
7a4de2f0
Commit
7a4de2f0
authored
Apr 23, 2022
by
Melledy
Committed by
GitHub
Apr 23, 2022
Browse files
Merge pull request #128 from memetrollsXD/development
Use count for level for equips (dev branch)
parents
dac3cdbe
fd1890b0
Changes
3
Show whitespace changes
Inline
Side-by-side
README.md
View file @
7a4de2f0
...
...
@@ -46,7 +46,7 @@ There is a dummy user named "Server" in every player's friends list that you can
`spawn [monster id] [level] [amount]`
`give [item id] [amount]`
`give [item id] [amount]
[level]
`
`givechar [avatar id] [level]`
...
...
src/main/java/emu/grasscutter/command/commands/GiveCommand.java
View file @
7a4de2f0
...
...
@@ -13,16 +13,15 @@ import emu.grasscutter.server.packet.send.PacketItemAddHintNotify;
import
java.util.LinkedList
;
import
java.util.List
;
@Command
(
label
=
"give"
,
usage
=
"give [player] <itemId|itemName> [amount]
"
,
description
=
"Gives an item to you or the specified player"
,
aliases
=
{
"g"
,
"item"
,
"giveitem"
},
permission
=
"player.give"
)
@Command
(
label
=
"give"
,
usage
=
"give [player] <itemId|itemName> [amount]
[level]"
,
description
=
"Gives an item to you or the specified player"
,
aliases
=
{
"g"
,
"item"
,
"giveitem"
},
permission
=
"player.give"
)
public
final
class
GiveCommand
implements
CommandHandler
{
@Override
public
void
execute
(
GenshinPlayer
sender
,
List
<
String
>
args
)
{
int
target
,
item
,
amount
=
1
;
int
target
,
item
,
lvl
,
amount
=
1
;
if
(
sender
==
null
&&
args
.
size
()
<
2
)
{
CommandHandler
.
sendMessage
(
null
,
"Usage: give <player> <itemId|itemName> [amount]"
);
CommandHandler
.
sendMessage
(
null
,
"Usage: give <player> <itemId|itemName> [amount]
[level]
"
);
return
;
}
...
...
@@ -34,6 +33,7 @@ public final class GiveCommand implements CommandHandler {
try
{
item
=
Integer
.
parseInt
(
args
.
get
(
0
));
target
=
sender
.
getUid
();
lvl
=
1
;
}
catch
(
NumberFormatException
ignored
)
{
// TODO: Parse from item name using GM Handbook.
CommandHandler
.
sendMessage
(
sender
,
"Invalid item id."
);
...
...
@@ -43,6 +43,7 @@ public final class GiveCommand implements CommandHandler {
case
2
:
// <itemId|itemName> [amount] | [player] <itemId|itemName>
try
{
target
=
Integer
.
parseInt
(
args
.
get
(
0
));
lvl
=
1
;
if
(
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
)
==
null
&&
sender
!=
null
)
{
target
=
sender
.
getUid
();
...
...
@@ -57,17 +58,39 @@ public final class GiveCommand implements CommandHandler {
return
;
}
break
;
case
3
:
// [player] <itemId|itemName> [amount]
case
3
:
// [player] <itemId|itemName> [amount]
| <itemId|itemName> [amount] [level]
try
{
target
=
Integer
.
parseInt
(
args
.
get
(
0
));
if
(
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
)
==
null
)
{
CommandHandler
.
sendMessage
(
sender
,
"Invalid player ID."
);
if
(
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
)
==
null
&&
sender
!=
null
)
{
target
=
sender
.
getUid
();
item
=
Integer
.
parseInt
(
args
.
get
(
0
));
amount
=
Integer
.
parseInt
(
args
.
get
(
1
));
lvl
=
Integer
.
parseInt
(
args
.
get
(
2
));
}
else
{
item
=
Integer
.
parseInt
(
args
.
get
(
1
));
amount
=
Integer
.
parseInt
(
args
.
get
(
2
));
lvl
=
1
;
}
}
catch
(
NumberFormatException
ignored
)
{
// TODO: Parse from item name using GM Handbook.
CommandHandler
.
sendMessage
(
sender
,
"Invalid item or player ID."
);
return
;
}
break
;
case
4
:
// [player] <itemId|itemName> [amount] [level]
try
{
target
=
Integer
.
parseInt
(
args
.
get
(
0
));
if
(
Grasscutter
.
getGameServer
().
getPlayerByUid
(
target
)
==
null
)
{
CommandHandler
.
sendMessage
(
sender
,
"Invalid player ID."
);
return
;
}
else
{
item
=
Integer
.
parseInt
(
args
.
get
(
1
));
amount
=
Integer
.
parseInt
(
args
.
get
(
2
));
lvl
=
Integer
.
parseInt
(
args
.
get
(
3
));
}
}
catch
(
NumberFormatException
ignored
)
{
// TODO: Parse from item name using GM Handbook.
CommandHandler
.
sendMessage
(
sender
,
"Invalid item or player ID."
);
...
...
@@ -89,16 +112,37 @@ public final class GiveCommand implements CommandHandler {
return
;
}
this
.
item
(
targetPlayer
,
itemData
,
amount
);
this
.
item
(
targetPlayer
,
itemData
,
amount
,
lvl
);
if
(!
itemData
.
isEquip
())
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
"Given %s of %s to %s."
,
amount
,
item
,
target
));
else
CommandHandler
.
sendMessage
(
sender
,
String
.
format
(
"Given %s with level %s %s times to %s"
,
item
,
lvl
,
amount
,
target
));
}
private
void
item
(
GenshinPlayer
player
,
ItemData
itemData
,
int
amount
)
{
private
void
item
(
GenshinPlayer
player
,
ItemData
itemData
,
int
amount
,
int
lvl
)
{
if
(
itemData
.
isEquip
())
{
List
<
GenshinItem
>
items
=
new
LinkedList
<>();
for
(
int
i
=
0
;
i
<
amount
;
i
++)
{
items
.
add
(
new
GenshinItem
(
itemData
));
GenshinItem
item
=
new
GenshinItem
(
itemData
);
item
.
setCount
(
amount
);
item
.
setLevel
(
lvl
);
item
.
setPromoteLevel
(
0
);
if
(
lvl
>
20
)
{
// 20/40
item
.
setPromoteLevel
(
1
);
}
else
if
(
lvl
>
40
)
{
// 40/50
item
.
setPromoteLevel
(
2
);
}
else
if
(
lvl
>
50
)
{
// 50/60
item
.
setPromoteLevel
(
3
);
}
else
if
(
lvl
>
60
)
{
// 60/70
item
.
setPromoteLevel
(
4
);
}
else
if
(
lvl
>
70
)
{
// 70/80
item
.
setPromoteLevel
(
5
);
}
else
if
(
lvl
>
80
)
{
// 80/90
item
.
setPromoteLevel
(
6
);
}
items
.
add
(
item
);
}
player
.
getInventory
().
addItems
(
items
);
player
.
sendPacket
(
new
PacketItemAddHintNotify
(
items
,
ActionReason
.
SubfieldDrop
));
...
...
@@ -110,4 +154,3 @@ public final class GiveCommand implements CommandHandler {
}
}
}
src/main/java/emu/grasscutter/game/inventory/GenshinItem.java
View file @
7a4de2f0
...
...
@@ -90,7 +90,7 @@ public class GenshinItem {
// Equip data
if
(
getItemType
()
==
ItemType
.
ITEM_WEAPON
)
{
this
.
level
=
1
;
this
.
level
=
this
.
count
>
1
?
this
.
count
:
1
;
this
.
affixes
=
new
ArrayList
<>(
2
);
if
(
getItemData
().
getSkillAffix
()
!=
null
)
{
for
(
int
skillAffix
:
getItemData
().
getSkillAffix
())
{
...
...
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