Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Commit

Permalink
Fixed Bug if Player quits a running game
Browse files Browse the repository at this point in the history
  • Loading branch information
Fludixx authored Jul 15, 2018
1 parent a901e45 commit 8eaa2e4
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/Fludixx/WoolBattle/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

class Main extends PluginBase implements Listener{

public $version = "1.1.4";
public $lastquit = false;
public $prefix = f::WHITE . "Wool" . f::GREEN . "Battle" . f::GRAY . " | " . f::WHITE;
public $zuwenig = false;
public $setup = 0;
Expand Down Expand Up @@ -141,16 +141,17 @@ public function onQuit(PlayerQuitEvent $event) {
$playername = $player->getName();
$name = $player->getName();
$c = new Config("/cloud/users/$name.yml", Config::YAML);
$c->set("ingame", false);
//$c->set("ingame", false);
$c->set("woolcolor", false);
$c->set("ms", false);
$c->set("pw", false);
//$c->set("pw", false);
$c->set("leader", false);
$c->set("pos", 1);
$c->set("grouparray", array());
$c->set("spawnprotect", false);
$c->set("cooldown", false);
$c->save();
$this->lastquit = $name;
}
public function getEq($spieler) {
$spielername = $spieler->getName();
Expand Down Expand Up @@ -1288,20 +1289,8 @@ public function onRun(int $tick)
{
$player = $this->player;
if (!$player->isOnline()) {
$playername = $player->getName();
$name = $player->getName();
$c = new Config("/cloud/users/$name.yml", Config::YAML);
$c->set("ingame", false);
$c->set("woolcolor", false);
$c->set("ms", false);
$c->set("pw", false);
$c->set("leader", false);
$c->set("pos", 1);
$c->set("grouparray", array());
$c->set("spawnprotect", false);
$c->set("cooldown", false);
$c->save();
$wspwh = new Config("/cloud/users/".$playername.".yml", Config::YAML);
$playername = $this->plugin->lastquit;
$wspwh = new Config("/cloud/users/$playername.yml", Config::YAML);
$otherplayer = $wspwh->get("pw");
$ig = $wspwh->get("ingame");
if($ig == true) {
Expand Down Expand Up @@ -1346,7 +1335,22 @@ public function onRun(int $tick)
$wspwh->set("lifes", 10);
$wspwh->set("wooltode", $wspwh->get("wooltode")+1);
$wspwh->save();
$name = $player->getName();
$this->plugin->getScheduler()->cancelTask($this->getTaskId());
$this->plugin->getLogger()->info("$this->player quited the in an running Game!");
}
$name = $player->getName();
$c = new Config("/cloud/users/$name.yml", Config::YAML);
$c->set("ingame", false);
$c->set("woolcolor", false);
$c->set("ms", false);
$c->set("pw", false);
$c->set("leader", false);
$c->set("pos", 1);
$c->set("grouparray", array());
$c->set("spawnprotect", false);
$c->set("cooldown", false);
$c->save();
$this->plugin->getScheduler()->cancelTask($this->getTaskId());
$this->plugin->getLogger()->info("Task for $this->player was Disabled!");
} else {
Expand Down

0 comments on commit 8eaa2e4

Please sign in to comment.