示例#1
0
 /**
  * @param XEcon $main
  * @param Player $player
  * @param int $from
  * @param int $to
  * @param int|string $fromToFilter T_LOGICAL_OR for all transactions, T_LOGICAL_AND for self-to-self inter-account transactions, T_LOGICAL_XOR for inter-entity transactions
  * @return string
  */
 public static function exportTransactions(XEcon $main, Player $player, $from = 0, $to = PHP_INT_MAX, $fromToFilter = T_LOGICAL_OR)
 {
     $ent = $main->getSession($player)->getEntity();
     $data = $main->getTransactions($ent->getAbsolutePrefix(), $ent->getName(), null, $ent->getAbsolutePrefix(), $ent->getName(), null, $from, $to, 0, PHP_INT_MAX, $fromToFilter);
     $dir = $main->getDataFolder() . "logs/";
     $file = strtolower($player->getName()) . " transaction logs on " . date("F j, Y") . " at " . date("H.i.s (e O, T)");
     $serialized = serialize($data);
     $lowName = strtolower($player->getName());
     $onRun = function () use($dir, $file, $serialized, $lowName) {
         @mkdir($dir);
         /** @var \xecon\log\Transaction[] $rawData */
         $rawData = unserialize($serialized);
         $output = [];
         foreach ($rawData as $transaction) {
             $timestamp = $transaction->getTimestamp();
             $out = [self::TYPE => "Pay", self::TARGET_NAME => "{$transaction->getToType()} {$transaction->getToName()}", self::TARGET_ACCOUNT => $transaction->getToAccount(), self::AMOUNT => $transaction->getAmount(), self::DETAILS => $transaction->getDetails(), self::DATE => "__DATE__{$timestamp}"];
             if ($transaction["totype"] === "Player" and $transaction["toname"] === $lowName) {
                 $out[self::TYPE] = "Receive";
                 $out[self::TARGET_NAME] = "{$transaction->getFromType()} {$transaction->getFromName()}";
                 $out[self::TARGET_ACCOUNT] = $transaction->getFromAccount();
             }
             $output[] = $out;
         }
         self::export($dir, $file, $output);
     };
     $onCompletion = function () use($main, $dir, $file) {
         $main->getLogger()->info("Exported transaction logs to {$dir}{$file}");
     };
     $task = new CallbackAsyncTask($onRun, $onCompletion);
     $main->getServer()->getScheduler()->scheduleAsyncTask($task);
     return $dir . $file;
 }
示例#2
-1
 public function onEnable()
 {
     $this->xEcon = $this->getServer()->getPluginManager()->getPlugin("xEcon");
     $this->xEcon->getService()->registerService("TaxColl");
     $this->service = $this->xEcon->getService()->getService("TaxColl");
     $this->saveDefaultConfig();
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     $this->loadTaxes();
     $this->freq = self::hcf_array(array_map(function (TaxWrapper $wrapper) {
         return $wrapper->getFrequency();
     }, $this->taxWrappers));
     $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new CollectTaxTask($this), $this->freq, $this->freq);
     $this->cvMgr = new ExemptionCommandManager($this);
 }
示例#3
-1
 public function __construct($player, XEcon $main)
 {
     $this->ent = $main->getPlayerEnt($player, true, true);
 }