Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamguxiang committed Apr 13, 2022
1 parent 06e1251 commit fda7bc2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ScriptEngine/API/PlayerAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,8 @@ Local<Value> PlayerClass::setBossBar(const Arguments& args)
CHECK_ARGS_COUNT(args, 2);
CHECK_ARG_TYPE(args[0], ValueKind::kString);
CHECK_ARG_TYPE(args[1], ValueKind::kNumber);

if (args.size() >= 3)
CHECK_ARG_TYPE(args[2], ValueKind::kNumber);
try{
Player* player = get();
if (!player)
Expand All @@ -1134,8 +1135,10 @@ Local<Value> PlayerClass::setBossBar(const Arguments& args)
else if(percent > 100)
percent = 100;
float value = (float)percent / 100;

player->sendBossEventPacket(BossEvent::Show, args[0].toStr(), value, BossEventColour::Red); //Set
BossEventColour colour = BossEventColour::Red;
if (args.size() >= 3)
colour = (BossEventColour)args[2].toInt();
player->sendBossEventPacket(BossEvent::Show, args[0].toStr(), value, colour); // Set
return Boolean::newBoolean(true);
}
CATCH("Fail in setBossBar!")
Expand Down

0 comments on commit fda7bc2

Please # to comment.