Skip to content
This repository was archived by the owner on Feb 8, 2019. It is now read-only.

Commit 037735c

Browse files
committed
MaxXP
1 parent 0e1cd6d commit 037735c

File tree

1 file changed

+31
-0
lines changed
  • src/VectorNetworkProject/TheMix/game/level

1 file changed

+31
-0
lines changed

src/VectorNetworkProject/TheMix/game/level/XP.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,35 @@ public static function getXP(Player $player): int
6565
$db = new JSON($player->getXuid(), Level::FILE_NAME);
6666
return $db->get(self::XP);
6767
}
68+
69+
/**
70+
* プレイヤーのMaxXPを変更します。
71+
*
72+
* @param Player $player
73+
* @param int $max
74+
*
75+
* @return void
76+
*/
77+
public static function setMaxXP(Player $player, int $max): void
78+
{
79+
$event = new PlayerMaxXpChangeEvent($player, $max);
80+
Server::getInstance()->getPluginManager()->callEvent($event);
81+
if (!$event->isCancelled()) {
82+
$db = new JSON($player->getXuid(), Level::FILE_NAME);
83+
$db->set(self::MAX, $max);
84+
}
85+
}
86+
87+
/**
88+
* プレイヤーのMaxXPを取得します。
89+
*
90+
* @param Player $player
91+
*
92+
* @return int
93+
*/
94+
public static function getMaxXP(Player $player): int
95+
{
96+
$db = new JSON($player->getXuid(), Level::FILE_NAME);
97+
return $db->get(self::MAX);
98+
}
6899
}

0 commit comments

Comments
 (0)