-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
109 changed files
with
1,851 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\ResourcePack; | ||
use Artisan; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\File; | ||
use Illuminate\Support\Facades\Storage; | ||
|
||
class ResourcePackFetch extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'resourcepack:fetch | ||
{name : Filename of resource pack located on GitHub} | ||
{--use= : Whether the resource pack should be used} | ||
{--update= : Whether the resource pack should be updated}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Fetch resource pack, and optionally apply it as currently used textures'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
if (File::exists(public_path('storage/resource-packs-downloaded/' . $this->argument('name') . '.zip'))) { | ||
if ($this->option('update') !== "yes") { | ||
$this->info( | ||
sprintf("Resource pack '%s' already exists! Use --update=yes to update it", $this->argument('name')) | ||
); | ||
|
||
return 1; | ||
} | ||
} | ||
|
||
$this->info(sprintf("Downloading '%s'", $this->argument('name'))); | ||
|
||
// Download resource pack | ||
$resourcePack = @file_get_contents( | ||
'https://github.com/melkypie/resource-packs/archive/' . $this->argument('name') . '.zip' | ||
); | ||
|
||
if ($resourcePack === false) { | ||
$this->info(sprintf("Could not fetch '%s' from '%s'", $this->argument('name'), 'https://github.com/melkypie/resource-packs/archive/' . $this->argument('name') . '.zip')); | ||
|
||
return 1; | ||
} | ||
|
||
// Put resource pack file to download directory | ||
Storage::disk('public')->put( | ||
'resource-packs-downloaded/' . $this->argument('name') . '.zip', | ||
$resourcePack | ||
); | ||
|
||
// Verify resource pack is correctly downloaded, and insert to database | ||
if (File::exists(public_path('storage/resource-packs-downloaded/'.$this->argument('name').'.zip'))) { | ||
$resourcePack = ResourcePack::firstWhere('name', $this->argument('name')); | ||
|
||
if (!$resourcePack) { | ||
$this->info(sprintf("Inserting '%s' to database", $this->argument('name'))); | ||
|
||
$resourcePack = new ResourcePack(); | ||
|
||
$resourcePack->name = $this->argument('name'); | ||
$resourcePack->alias = ucfirst(str_replace("pack-", "", $this->argument('name'))); | ||
$resourcePack->url = 'https://github.com/melkypie/resource-packs/archive/' . $this->argument( | ||
'name' | ||
) . '.zip'; | ||
|
||
$resourcePack->save(); | ||
} else { | ||
$this->info(sprintf("Updating '%s' in database", $this->argument('name'))); | ||
|
||
$resourcePack->touch(); | ||
} | ||
} else { | ||
$this->info(sprintf("Something went wrong")); | ||
|
||
return 1; | ||
} | ||
|
||
if ($this->option('use') == "yes") { | ||
$this->info(sprintf("Applying new textures")); | ||
|
||
Artisan::call("resourcepack:switch " . $this->argument('name')); | ||
} | ||
|
||
$this->info(sprintf("Finished!")); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\File; | ||
use VIPSoft\Unzip\Unzip; | ||
|
||
class ResourcePackSwitch extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'resourcepack:switch | ||
{name : Filename of resource pack located on GitHub}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Switch and apply resource pack to current textures'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
if (!File::exists(public_path('storage/resource-packs-downloaded/'.$this->argument('name').'.zip'))) { | ||
$this->info(sprintf("Resource pack '%s' does not exist!", $this->argument('name'))); | ||
|
||
return 1; | ||
} | ||
|
||
$extractFrom = public_path('storage/resource-packs-downloaded/'.$this->argument('name').'.zip'); | ||
$extractTo = public_path('storage/resource-pack-tmp'); | ||
|
||
// Clean tmp dir | ||
File::cleanDirectory(public_path('storage/resource-pack-tmp')); | ||
|
||
$unzipper = new Unzip(); | ||
$filenames = $unzipper->extract($extractFrom, $extractTo); | ||
|
||
$this->info(sprintf("Applying new textures")); | ||
|
||
// Copy resource pack from parent dir in tmp dir, and extract files one level up | ||
File::copyDirectory(public_path('storage/resource-pack-tmp/'.$filenames[0]), public_path('storage/resource-pack')); | ||
|
||
// Clean tmp dir | ||
File::cleanDirectory(public_path('storage/resource-pack-tmp')); | ||
|
||
$this->info(sprintf("Finished!")); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Helpers\Helper; | ||
use Artisan; | ||
use Illuminate\Console\Command; | ||
|
||
class SkillCreate extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'skill:create'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create skill migration and model files'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
$skills = Helper::listSkills(); | ||
$skillCount = sizeof($skills); | ||
|
||
// This method create a skill migration and model file for each skill | ||
foreach (Helper::listSkills() as $key => $skill) { | ||
$count = ($key+1)."/".$skillCount; | ||
|
||
$this->info(sprintf("[%s] Making '%s' migration", $count, $skill)); | ||
|
||
$makeMigration = "make:migration create_".$skill."_table"; | ||
Artisan::call($makeMigration); | ||
|
||
$this->info(sprintf("[%s] Making '%s' model", $count, $skill)); | ||
|
||
$makeModel = "make:model Skill/".ucfirst($skill); | ||
Artisan::call($makeModel); | ||
} | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace App\Events; | ||
|
||
use App\Quest; | ||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Broadcasting\PresenceChannel; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class AccountQuest implements ShouldBroadcast | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
public $quest; | ||
|
||
/** | ||
* Create a new event instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(Quest $quest) | ||
{ | ||
$this->quest = $quest; | ||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return \Illuminate\Broadcasting\Channel|array | ||
*/ | ||
public function broadcastOn() | ||
{ | ||
return new Channel('account-quest'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.