Skip to content

Commit

Permalink
Merge pull request #36 from DuoIncure/stable
Browse files Browse the repository at this point in the history
🧍‍♂️
  • Loading branch information
Vecnavium authored Oct 22, 2022
2 parents e676623 + 7ee6b78 commit 9391e84
Show file tree
Hide file tree
Showing 25 changed files with 123 additions and 139 deletions.
8 changes: 4 additions & 4 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: SkyBlocksPM
api: 4.0.0
author: Vecnavium
main: Vecnavium\SkyBlocksPM\SkyBlocksPM
version: 1.0.7
version: 1.0.8

permissions:
skyblockspm.command:
Expand Down Expand Up @@ -32,6 +32,6 @@ permissions:
skyblockspm.accept:
default: true
description: Accept the incoming invite to a SkyBlock island
skyblockspm.chat:
default: true
description: SkyBlocks Island Chat
skyblockspm.chat:
default: true
description: SkyBlocks Island Chat
4 changes: 2 additions & 2 deletions resources/forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#Forms Config File for SkyBlocksPM
#==========================================#
visit:
title: '&l&4[SkyBlocksPM] Visit Menu'
buttons: '&l&4{NAME} SkyBlocksPM'
title: "&l&4[SkyBlocksPM] Visit Menu"
buttons: "&l&4{NAME} SkyBlocksPM"
32 changes: 16 additions & 16 deletions resources/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@

# Use & instead of double S for a quicker colorizing of texts

prefix: '&l&4[SkyBlocksPM]'
prefix: "&l&4[SkyBlocksPM]"

# seperator seperates the message from the prefix
# Format looks like:
# {prefix} {seperator} {message}
# the spaces are automatically added so you dont have to worry about that too :))
seperator: '&e=> &b'
seperator: "&e=>&b"

messages:
skyblock-creating: 'SkyBlock is currently creating...'
player-not-online: 'The player you have specified is currently not online or doesnt exist.'
have-sb: 'You already own a SkyBlock Island'
no-sb: 'You do not have a SkyBlock Island to use the command.'
not-registered: 'The player you have specified does not exist.'
no-island: 'The specified player does not own an island.'
no-default-island: "The default island has not been set, please ask the server staff to use '/sb setworld' command to set the island world"
skyblock-creating: "SkyBlock is currently creating..."
player-not-online: "The player you have specified is currently not online or doesnt exist."
have-sb: "You already own a SkyBlock Island"
no-sb: "You do not have a SkyBlock Island to use the command."
not-registered: "The player you have specified does not exist."
no-island: "The specified player does not own an island."
no-default-island: "The default island has not been set, please ask the server staff to use the '/sb setworld' command to set the island world"
no-sb-go: 'You do not own a SkyBlock island'
no-perms-delete: "You do not have the permission to delete other SkyBlock islands."
deleted-sb: "You have successfully deleted {NAME}'s SkyBlock Island."
invite-get: "You have recieved an invittation from {INVITER} to accept run /sb accept"
invite-expired: 'The invite that was pending has expired.'
invite-pending: 'You already have a pending invite.'
invite-get: "You have received an invitation from {INVITER}, to accept run '/sb accept {INVITER}'"
invite-expired: "The invite that was pending has expired."
invite-pending: "You already have a pending invite."
invite-sent: "You have successfully sent an invite to {PLAYER}."
invite-accepted: '{PLAYER} has joined your SkyBlock.'
member-limit: 'You have reached the member limit for your SkyBlock'
invite-accepted: "{PLAYER} has joined your SkyBlock."
member-limit: "You have reached the member limit for your SkyBlock"
create: "You have successfully created your SkyBlock."
visit: "You are currently visiting {NAME}'s Island.."
delete: 'Deleting your SkyBlock Island..'
delete: "Deleting your SkyBlock Island.."
default-world: "You can not set the default world of the server as a skyblock world"
toggle-chat: "toggled island chat"
toggle-chat: "Toggled Island chat"

skyblock-chat: "&f[SkyBlocksPM] &e[{PLAYER}] &6=> {MSG}"
16 changes: 8 additions & 8 deletions resources/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ CREATE TABLE IF NOT EXISTS skyblockspm_player
(
uuid VARCHAR(32) PRIMARY KEY,
name VARCHAR(32),
skyblock STRING DEFAULT ''
);
skyblock TEXT DEFAULT ''
);
-- # }

-- # { load
Expand Down Expand Up @@ -47,11 +47,11 @@ CREATE TABLE IF NOT EXISTS skyblockspm_sb
uuid VARCHAR(32) PRIMARY KEY,
name VARCHAR(32),
leader VARCHAR(32),
members STRING,
world STRING,
settings STRING,
spawn STRING
);
members TEXT,
world TEXT,
settings TEXT,
spawn TEXT
);
-- # }

-- # { load
Expand All @@ -77,7 +77,7 @@ VALUES (:uuid, :name, :leader, :members, :world, :settings, :spawn);
-- # :uuid string
DELETE
FROM skyblockspm_sb
WHERE uuid=:uuid
WHERE uuid=:uuid;
-- # }

-- # { update
Expand Down
16 changes: 8 additions & 8 deletions resources/sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ CREATE TABLE IF NOT EXISTS skyblockspm_player
(
uuid VARCHAR(32) PRIMARY KEY,
name VARCHAR(32),
skyblock STRING DEFAULT ''
);
skyblock TEXT DEFAULT ''
);
-- # }

-- # { load
Expand Down Expand Up @@ -47,11 +47,11 @@ CREATE TABLE IF NOT EXISTS skyblockspm_sb
uuid VARCHAR(32) PRIMARY KEY,
name VARCHAR(32),
leader VARCHAR(32),
members STRING,
world STRING,
settings STRING,
spawn STRING
);
members TEXT,
world TEXT,
settings TEXT,
spawn TEXT
);
-- # }

-- # { load
Expand All @@ -77,7 +77,7 @@ VALUES (:uuid, :name, :leader, :members, :world, :settings, :spawn);
-- # :uuid string
DELETE
FROM skyblockspm_sb
WHERE uuid=:uuid
WHERE uuid=:uuid;
-- # }

-- # { update
Expand Down
10 changes: 3 additions & 7 deletions src/Vecnavium/SkyBlocksPM/CheckUpdateTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use pocketmine\scheduler\AsyncTask;
use pocketmine\Server;
use pocketmine\utils\Internet;
use function is_array;
use function json_decode;
use function version_compare;
use function vsprintf;
Expand All @@ -27,9 +26,8 @@ public function onRun() : void{
if($json !== null){
$releases = json_decode($json->getBody(), true);
foreach($releases as $release){
if(version_compare($highestVersion, $release["version"], ">=")){
continue;
}
if(version_compare($highestVersion, $release["version"], ">=")) continue;

$highestVersion = $release["version"];
$artifactUrl = $release["artifact_url"];
$api = $release["api"][0]["from"] . " - " . $release["api"][0]["to"];
Expand All @@ -42,9 +40,7 @@ public function onRun() : void{

public function onCompletion() : void{
$plugin = Server::getInstance()->getPluginManager()->getPlugin($this->pluginName);
if($plugin === null){
return;
}
if($plugin === null) return;

[$highestVersion, $artifactUrl, $api, $err] = $this->getResult();
if($err !== null){
Expand Down
16 changes: 5 additions & 11 deletions src/Vecnavium/SkyBlocksPM/SkyBlocksPM.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Vecnavium\SkyBlocksPM;

use pocketmine\player\Player as P;
use Vecnavium\SkyBlocksPM\commands\SkyBlockCommand;
use Vecnavium\SkyBlocksPM\libs\CortexPE\Commando\PacketHooker;
use Vecnavium\SkyBlocksPM\generator\Generator;
Expand All @@ -12,27 +13,20 @@
use Vecnavium\SkyBlocksPM\messages\Messages;
use Vecnavium\SkyBlocksPM\skyblock\SkyBlockManager;
use Vecnavium\SkyBlocksPM\player\PlayerManager;
use cVecnavium\SkyBlocksPM\player\Player;
use pocketmine\plugin\PluginBase;
use Vecnavium\SkyBlocksPM\libs\poggit\libasynql\DataConnector;
use Vecnavium\SkyBlocksPM\libs\poggit\libasynql\libasynql;
use function array_search;

class SkyBlocksPM extends PluginBase
{

/** @var DataConnector */
private DataConnector $dataConnector;
/** @var Generator */
private Generator $generator;
/** @var Messages */
private Messages $messages;
/** @var PlayerManager */
private PlayerManager $playerManager;
/** @var SkyBlockManager */
private SkyBlockManager $SkyBlockManager;
/** @var InviteManager */
private InviteManager $inviteManager;
/** @var SkyBlocksPM */
private static self $instance;
/** @var P[] */
private array $chat;
Expand Down Expand Up @@ -85,16 +79,16 @@ public function getChat(): array

public function addPlayerToChat(P $player): void
{
$this->chat[] = $player;
$this->chat[] = $player->getName();
}

public function removePlayerFromChat(P $player): void
{
unset($this->chat[array_search($player->getName(), $this->chat)]);
}

public function checkUpdate(bool $isRetry = false): void {

public function checkUpdate(): void
{
$this->getServer()->getAsyncPool()->submitTask(new CheckUpdateTask($this->getDescription()->getName(), $this->getDescription()->getVersion()));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Vecnavium/SkyBlocksPM/commands/SkyBlockCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class SkyBlockCommand extends BaseCommand
public function prepare(): void
{
$this->setPermission('skyblockspm.command');
$this->registerSubCommand(new ChatSubCommand('chat', 'Chat with your island members'));
$this->registerSubCommand(new AcceptSubCommand('accept', 'Accept the incoming invite to a SkyBlock island'));
$this->registerSubCommand(new ChatSubCommand('chat', 'Chat with your island members'));
$this->registerSubCommand(new CreateSubCommand('create', 'Create your own SkyBlock island'));
$this->registerSubCommand(new DeleteSubCommand('delete', 'Delete a users SkyBlock Island'));
$this->registerSubCommand(new SetWorldCommand('setworld', 'Sets the current world as the SkyBlock World which will be copied to newer worlds upon Island creation'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ protected function prepare(): void
public function onRun(CommandSender $sender, string $aliasUsed, array $args): void
{
$invite = SkyBlocksPM::getInstance()->getInviteManager()->getPlayerInvites($args['name']);
if (!$invite instanceof Invite)
return;

if (!$invite->handleInvite())
return;
if (!$invite instanceof Invite) return;
if (!$invite->handleInvite()) return;

$player = SkyBlocksPM::getInstance()->getPlayerManager()->getPlayerByPrefix($sender->getName());
$inviter = SkyBlocksPM::getInstance()->getPlayerManager()->getPlayer($invite->getInviter());
$player->setSkyBlock($inviter->getSkyBlock());
$skyblock = SkyBlocksPM::getInstance()->getSkyBlockManager()->getSkyBlock($player->getSkyBlock());
$skyblock = SkyBlocksPM::getInstance()->getSkyBlockManager()->getSkyBlockByUuid($inviter->getSkyBlock());
$members = $skyblock->getMembers();
$skyblock->setMembers($members);
array_push($members, $sender->getName());
$skyblock->setMembers($members);
foreach ($skyblock->getMembers() as $member)
{
$mbr = SkyBlocksPM::getInstance()->getServer()->getPlayerByPrefix($member);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ protected function prepare(): void

public function onRun(CommandSender $sender, string $aliasUsed, array $args): void
{
if (!$sender instanceof P)
return;
if (!$sender instanceof P) return;

if (!in_array($sender->getName(), SkyBlocksPM::getInstance()->getChat()))
SkyBlocksPM::getInstance()->addPlayerToChat($sender);
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ protected function prepare(): void

public function onRun(CommandSender $sender, string $aliasUsed, array $args): void
{
if (!$sender instanceof Player)
return;
if (!$sender instanceof Player) return;

$player = SkyBlocksPM::getInstance()->getPlayerManager()->getPlayer($sender);
if ($player->getSkyBlock() !== '')
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ protected function prepare(): void

public function onRun(CommandSender $sender, string $aliasUsed, array $args): void
{
if (!$sender instanceof Player)
return;
if (!$sender instanceof Player) return;

if (!SkyBlocksPM::getInstance()->getInviteManager()->canInvite($sender))
{
$sender->sendMessage(SkyBlocksPM::getInstance()->getMessages()->getMessage('invite-pending'));
return;
}
$player = SkyBlocksPM::getInstance()->getServer()->getPlayerByPrefix($args['name']);
$skyblockPlayer = SkyBlocksPM::getInstance()->getPlayerManager()->getPlayerByPrefix($sender->getName());
$skyblock = SkyBlocksPM::getInstance()->getSkyBlockManager()->getSkyBlock($skyblockPlayer->getSkyBlock());
$skyblock = SkyBlocksPM::getInstance()->getSkyBlockManager()->getSkyBlockByUuid($skyblockPlayer->getSkyBlock());
if (!$skyblock instanceof SkyBlock)
{
$sender->sendMessage(SkyBlocksPM::getInstance()->getMessages()->getMessage('no-sb'));
Expand All @@ -49,8 +49,8 @@ public function onRun(CommandSender $sender, string $aliasUsed, array $args): vo
SkyBlocksPM::getInstance()->getMessages()->getMessage('player-not-online');
return;
}
if ($sender === $player)
return;
if ($sender === $player) return;

$id = Uuid::uuid4()->toString();
SkyBlocksPM::getInstance()->getInviteManager()->addInvite($id, $sender, $player);
$player->sendMessage(SkyBlocksPM::getInstance()->getMessages()->getMessage('invite-get', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ protected function prepare(): void

public function onRun(CommandSender $sender, string $aliasUsed, array $args): void
{
if (!$sender instanceof Player)
return;
if (!$sender instanceof Player) return;

SkyBlocksPM::getInstance()->getGenerator()->setIslandWorld($sender);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ protected function prepare(): void

public function onRun(CommandSender $sender, string $aliasUsed, array $args): void
{
if (!$sender instanceof Player)
return;
if (!$sender instanceof Player) return;

$skyblock = SkyBlocksPM::getInstance()->getPlayerManager()->getPlayer($sender)->getSkyblock();
if ($skyblock == '')
{
Expand Down
Loading

0 comments on commit 9391e84

Please sign in to comment.