diff --git a/README.md b/README.md index b77801b..280171e 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,16 @@ -# RankUp 1.1 +# RankUp 1.2 -A @PocketMine MCPE server plugin. Player gets a higher rank as reward for voting or -after some time playing on the server. -For mcpe 0.11.1 / 0.12.1 with api 1.12.0 / 1.13.0 +A MCPE server plugin for servers running on ImagicalMine or PocketMine builds. +Player gets a higher rank as reward for voting or after some time playing on the server. +Player can also start/stop jobs. -RankUp requires PurePerms v1.1.11 or v1.1.12 on your server +For mcpe 0.12.1 / 0.13.1 with api 1.12.0 / 1.13.0 + +RankUp requires PurePerms v1.1.12 or higher on your server ##Download and Install -### [Download: RankUp.phar v1.0](https://s3-eu-west-1.amazonaws.com/devron/RankUp.phar) +### [Download: RankUp.phar v1.2](https://s3-eu-west-1.amazonaws.com/devron/RankUp_v12.phar) and copy the file into your plugins folder. @@ -47,6 +49,26 @@ status of other players /tr check ``` +###start / stop jobs + +job list + +``` +/job list +``` + +start job + +``` +/job start +``` + +stop job, player will reseted to his actual AutoRank Group + +``` +/job stop +``` + ##Configuration ``` @@ -100,6 +122,13 @@ Messages: timer-rankis: "Rank is: ##rank##" timer-timeplayed: "You have played ##timeplayed## minutes on this server.\n ##timetoplay## minutes until next rankup" timer-timeplayer: "Has played ##timeplayed## minutes on this server" + job-list: "You can choose one of this jobs: ##joblist##" + job-choose: "Please choose one of the jobs: ##joblist##" + job-rank-low: "You can't choose this job, your rank is to low" + job-rank-error: "Upps there is an ERROR, try again later" + job-usage: "list jobs: /job list\nchoose job: /job start " + job-no-stop: "You do not have a job to stop, use /job start to start a job" + ``` ##Permissions @@ -112,4 +141,7 @@ permissions: timeranks.command: description: "check time to play for next rank" default: true + jobranks.command: + description: "list or choose jobranks" + default: true ``` \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index b487ac1..ac02922 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: RankUp main: RankUp\MainRankUp -version: 1.1 +version: 1.2 api: [1.12.0] load: POSTWORLD @@ -20,7 +20,7 @@ commands: permission: timeranks.command jobranks: description: list/choose jobranks - usage: "/job [list/start] " + usage: "/job [list/start/stop] " aliases: [job, jobranks, jr] permission: jobranks.command permissions: diff --git a/resources/config.yml b/resources/config.yml index b255ee1..c5fcc58 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -43,7 +43,7 @@ AutoRanks: #messages Messages: command-in-game: "Command must be used in-game." - error-fetching-vote: "[VoteRanks] Error fetching vote status! Try again later." + error-fetching-vote: "[RankUp] Error fetching vote status! Try again later." no-permission: "You do not have permission to vote." pureperms-loaded: "Successfully loaded with PurePerms" pureperms-notfound: "Dependency PurePerms not found" @@ -64,3 +64,4 @@ Messages: job-rank-low: "You can't choose this job, your rank is to low" job-rank-error: "Upps there is an ERROR, try again later" job-usage: "list jobs: /job list\nchoose job: /job start " + job-no-stop: "You do not have a job to stop, use /job start to start a job" diff --git a/src/RankUp/RankUp.php b/src/RankUp/RankUp.php index f96d9a2..36dab05 100644 --- a/src/RankUp/RankUp.php +++ b/src/RankUp/RankUp.php @@ -133,6 +133,31 @@ public function jobRankUp(MainRankUp $plugin, Player $player, array $args) { } return str_replace("##joblist##", implode(', ', $jobNames), $this->config->getMessage("job-choose")); + break; + case "stop": + //stop works only if player has a jobrank + if(!in_array($userGroup, $jobNames)) { + return $this->config->getMessage("job-no-stop"); + } + $timeplayed = $plugin->data->get(strtolower($player->getName())); + $ranks = $this->config->getRanks(); + $newRank = false; + //search the origin rank + foreach($ranks as $rankName => $rankId) { + $timetoplay = $this->config->getAutoRankMinutes($rankName); + //player can switch back only to an AutoRank timetoplay must have a value + if(!empty($timetoplay) && $timeplayed >= $timetoplay){ + $newRank = $rankName; + } + } + if($newRank !== false){ + $pureRank = $this->getPureRank($newRank); + if ($pureRank != null) { + return $this->setRank($plugin, $player, $pureRank, $newRank); + } + } + + return $this->config->getMessage("job-usage"); break; default: return $this->config->getMessage("job-usage"); @@ -147,7 +172,8 @@ public function getTimeToAutoRankUp($data, Player $player) $newRankId = $oldRankId + 1; $newRank = array_search($newRankId, $this->config->getRanks()); if($newRank !== false && $timeplayed < $this->config->getAutoRankMinutes($newRank)){ - return $this->config->getAutoRankMinutes($newRank) - $timeplayed; + $timetoplay = $this->config->getAutoRankMinutes($newRank); + return (!empty($timetoplay)) ? ($timetoplay - $timeplayed) : 0; } return false;