Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Temporary workaround #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion EconomySell/src/onebone/economysell/EconomySell.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
use onebone\economysell\event\SellCreationEvent;
use onebone\economysell\event\SellTransactionEvent;

use onebone\economysell\task\SpawnTask;

class EconomySell extends PluginBase implements Listener{
/**
* @var DataProvider
Expand All @@ -54,7 +56,7 @@ class EconomySell extends PluginBase implements Listener{
private $queue = [], $tap = [], $removeQueue = [], $placeQueue = [];

/** @var ItemDisplayer[][] */
private $items = [];
public $items = [];

public function onEnable(){
$this->saveDefaultConfig();
Expand Down Expand Up @@ -90,6 +92,8 @@ public function onEnable(){
}

$this->getServer()->getPluginManager()->registerEvents($this, $this);

$this->getServer()->getScheduler()->scheduleRepeatingTask(new SpawnTask($this), 20 * 60 * 5);
}

public function onCommand(CommandSender $sender, Command $command, string $label, array $params): bool{
Expand Down
48 changes: 48 additions & 0 deletions EconomySell/src/onebone/economysell/task/SpawnTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/*
* EconomyS, the massive economy plugin with many features for PocketMine-MP
* Copyright (C) 2013-2017 onebone <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace onebone\economysell\task {

use pocketmine\{
scheduler\PluginTask
};

class SpawnTask extends PluginTask
{

/**
* Actions to execute when run
*
* @param int $currentTick
*
* @return void
*/
public function onRun(int $currentTick)
{
foreach($this->getOwner()->getServer()->getLevels() as $level) {
if (isset($this->getOwner()->items[$level->getName()])) {
foreach ($this->getOwner()->items[$level->getName()] as $displayer) {
$displayer->spawnToAll($level);
}
}
}
}
}
}
6 changes: 5 additions & 1 deletion EconomyShop/src/onebone/economyshop/EconomyShop.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
use onebone\economyshop\event\ShopCreationEvent;
use onebone\economyshop\event\ShopTransactionEvent;

use onebone\economyshop\task\SpawnTask;

class EconomyShop extends PluginBase implements Listener{
/**
* @var DataProvider
Expand All @@ -54,7 +56,7 @@ class EconomyShop extends PluginBase implements Listener{
private $queue = [], $tap = [], $removeQueue = [], $placeQueue = [];

/** @var ItemDisplayer[][] */
private $items = [];
public $items = [];

public function onEnable(){
$this->saveDefaultConfig();
Expand Down Expand Up @@ -90,6 +92,8 @@ public function onEnable(){
}

$this->getServer()->getPluginManager()->registerEvents($this, $this);

$this->getServer()->getScheduler()->scheduleRepeatingTask(new SpawnTask($this), 20 * 60 * 5);
}

public function onCommand(CommandSender $sender, Command $command, string $label, array $params): bool{
Expand Down
48 changes: 48 additions & 0 deletions EconomyShop/src/onebone/economyshop/task/SpawnTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/*
* EconomyS, the massive economy plugin with many features for PocketMine-MP
* Copyright (C) 2013-2017 onebone <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace onebone\economyshop\task {

use pocketmine\{
scheduler\PluginTask
};

class SpawnTask extends PluginTask
{

/**
* Actions to execute when run
*
* @param int $currentTick
*
* @return void
*/
public function onRun(int $currentTick)
{
foreach($this->getOwner()->getServer()->getLevels() as $level) {
if (isset($this->getOwner()->items[$level->getName()])) {
foreach ($this->getOwner()->items[$level->getName()] as $displayer) {
$displayer->spawnToAll($level);
}
}
}
}
}
}