Skip to content

Commit c189815

Browse files
committed
Replaced PluginBase::getResource() since is deprecated from PM 5.5
1 parent fd4c820 commit c189815

File tree

5 files changed

+39
-44
lines changed

5 files changed

+39
-44
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"sof3/libasynql": "^4.2.0",
1919
"sof3/await-generator": "^3.5.0",
2020
"dktapps/pmforms": "^2.2.0",
21-
"pocketmine/pocketmine-mp": "^5.0.0",
21+
"pocketmine/pocketmine-mp": "^5.5.0",
2222
"ifera-mc/update-notifier": "dev-master"
2323
},
2424
"require-dev": {

composer.lock

+29-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
name: BedcoreProtect
33
main: matcracker\BedcoreProtect\Main
4-
version: 1.2.4
5-
api: 5.0.0
4+
version: 1.3.0
5+
api: 5.5.0
66

77
load: POSTWORLD
88
author: matcracker

src/matcracker/BedcoreProtect/storage/DatabaseManager.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use poggit\libasynql\SqlError;
3232
use Symfony\Component\Filesystem\Path;
3333
use function count;
34+
use function fopen;
3435
use function version_compare;
3536

3637
final class DatabaseManager
@@ -64,8 +65,8 @@ public function connect(): bool
6465
return false;
6566
}
6667

67-
$patchResource = $this->plugin->getResource(Path::join("patches", $this->plugin->getParsedConfig()->getDatabaseType() . "_patch.sql"));
68-
if ($patchResource !== null) {
68+
$patchResource = fopen($this->plugin->getResourcePath(Path::join("patches", $this->plugin->getParsedConfig()->getDatabaseType() . "_patch.sql")), "r");
69+
if ($patchResource !== false) {
6970
$this->connector->loadQueryFile($patchResource);
7071
}
7172
$this->patchManager = new PatchManager($this->plugin, $this->connector);

src/matcracker/BedcoreProtect/storage/patches/PatchManager.php

+4-10
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
use pocketmine\plugin\PluginException;
2828
use poggit\libasynql\DataConnector;
2929
use poggit\libasynql\SqlDialect;
30+
use Symfony\Component\Filesystem\Path;
3031
use function array_filter;
3132
use function copy;
3233
use function count;
33-
use function fclose;
34+
use function file_get_contents;
3435
use function is_array;
35-
use function stream_get_contents;
3636
use function version_compare;
3737
use function yaml_parse;
3838

@@ -127,15 +127,9 @@ public function patch(): Generator
127127
*/
128128
private function getVersionsToPatch(string $db_version): array
129129
{
130-
$res = $this->plugin->getResource("patches/.patches");
131-
if ($res === null) {
132-
throw new PluginException("Could not find \".patches\" file. Be sure to use the original .phar plugin file.");
133-
}
134-
135-
$patchContent = stream_get_contents($res);
136-
fclose($res);
130+
$patchContent = file_get_contents($this->plugin->getResourcePath(Path::join("patches", ".patches")));
137131
if ($patchContent === false) {
138-
throw new PluginException("Could not read \".patches\" file.");
132+
throw new PluginException("Could not find \".patches\" file. Be sure to use the original .phar plugin file.");
139133
}
140134

141135
$patchConfig = yaml_parse($patchContent);

0 commit comments

Comments
 (0)