Skip to content

Commit

Permalink
Fix #7, #9
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAz928 committed May 11, 2020
1 parent 8430274 commit 6cd1c7e
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 82 deletions.
175 changes: 110 additions & 65 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: CubeBox
version: 1.0.1
version: 1.1.0
api: 3.0.0
author: TheAz928
main: TheAz928\CubeBox\Loader
Expand Down
5 changes: 4 additions & 1 deletion src/TheAz928/CubeBox/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public function getCrate(string $id): ?Crate {

/**
* @param PlayerInteractEvent $event
* @priority MONITOR
* @ignoreCancelled false
*/
public function onInteract(PlayerInteractEvent $event): void {
$player = $event->getPlayer();
Expand Down Expand Up @@ -154,7 +156,8 @@ public function onInteract(PlayerInteractEvent $event): void {
$crateTile->spawnToAll();

unset($this->creationSession[$player->getName()]);
}elseif($tile instanceof CrateTile){
}
if($tile instanceof CrateTile){
$event->setCancelled();

if($item->equals($tile->getCrate()->getKey())){
Expand Down
19 changes: 17 additions & 2 deletions src/TheAz928/CubeBox/entity/FloatingText.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace TheAz928\CubeBox\entity;

use pocketmine\entity\Zombie;
use pocketmine\entity\Living;

use pocketmine\event\entity\EntityDamageEvent;

Expand All @@ -26,7 +26,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

class FloatingText extends Zombie {
class FloatingText extends Living {

public const NETWORK_ID = self::VEX;

/** @var float */
public $height = 1.00;

/** @var float */
public $width = 1.00;

/** @var float */
protected $gravity = 0.00;
Expand All @@ -44,6 +52,13 @@ public static function spawn(Position $pos, string $text): self {
return $entity;
}

/**
* @return string
*/
public function getName(): string {
return "Floating Text";
}

protected function initEntity(): void {
parent::initEntity();

Expand Down
10 changes: 6 additions & 4 deletions src/TheAz928/CubeBox/entity/GiftBoxEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected function initEntity(): void {
parent::initEntity();

$this->setScale(0.5);
$this->setCanSaveWithChunk(false);
}

/**
Expand Down Expand Up @@ -118,8 +119,8 @@ public function entityBaseTick(int $tickDiff = 1): bool {
$this->getTile()->setIsInUse(false);
$this->getTile()->setChestState(false);

if($this->rewardItem !== null){
$this->rewardItem->flagForDespawn();
if($this->rewardItem !== null and $this->rewardItem->isClosed() == false){
$this->rewardItem->close();
}

return true;
Expand Down Expand Up @@ -198,6 +199,7 @@ public function entityBaseTick(int $tickDiff = 1): bool {

if($reward->getItem()->isNull() == false){
$this->rewardItem = $this->getLevel()->dropItem($this, $reward->getItem(), new Vector3(0, 0, 0), 12000);

$this->rewardItem->setNameTag($rarity . $reward->getItem()->getName());
$this->rewardItem->setNameTagAlwaysVisible(true);
}
Expand All @@ -210,8 +212,8 @@ public function entityBaseTick(int $tickDiff = 1): bool {
if($this->timeCounter > (20 * 11)){
$this->flagForDespawn();

if($this->rewardItem !== null){
$this->rewardItem->flagForDespawn();
if($this->rewardItem !== null and $this->rewardItem->isClosed() == false){
$this->rewardItem->close();
}

$this->getTile()->setIsInUse(false);
Expand Down
21 changes: 13 additions & 8 deletions src/TheAz928/CubeBox/form/ConfirmOpenForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,17 @@
/**
* CubeBox: The next level crate plugin for PocketMine-MP
* CopyRight (C) 2020 CubePM (TheAz928)
*
* 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
* 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/>.
*/

class ConfirmOpenForm implements Form {

/** @var CrateTile */
Expand All @@ -46,13 +42,22 @@ public function __construct(CrateTile $tile) {
* @return array
*/
public function jsonSerialize(): array {
$content = TextFormat::GRAY . "Open this crate for ";
if(($m = $this->tile->getCrate()->getMoneyCost()) > -1){
$content .= "$" . number_format($m);
}
if(($e = $this->tile->getCrate()->getXpCost()) > -1){
$content .= " and " . number_format($e) . "XP Level(s)";
}
$content .= "?";

return [
"type" => "form",
"title" => "CubeBox",
"content" => "Are you sure you want to open this crate for\n" . TextFormat::GREEN . "XP: " . TextFormat::WHITE . $this->tile->getCrate()->getXpCost() . "\n" . TextFormat::GREEN . "Money: " . TextFormat::WHITE . "$" . $this->tile->getCrate()->getMoneyCost() . "\n\n\n\n\n\n\n\n",
"title" => $this->tile->getCrate()->getName(),
"content" => $content,
"buttons" => [
["text" => "Yes"],
["text" => "No"]
["text" => TextFormat::DARK_GREEN . "Yes"],
["text" => TextFormat::RED . "No"]
]
];
}
Expand Down
13 changes: 12 additions & 1 deletion src/TheAz928/CubeBox/tile/CrateTile.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function close(): void {
parent::close();

if($this->displayEntity !== null){
$this->displayEntity->flagForDespawn();
$this->displayEntity->close();
}
}

Expand Down Expand Up @@ -174,6 +174,8 @@ public function onUpdate(): bool {

$dust1 = new DustParticle($pos->asVector3(), ...$this->getCrate()->getRGBA());

$pos = $this->asVector3();

$pos->x = ($pos->x + 0.5) + -sin($i);
$pos->z = ($pos->z + 0.5) + cos($i);

Expand Down Expand Up @@ -209,6 +211,15 @@ public function onUpdate(): bool {
}
}
if($this->getDisplayEntity()->isClosed() == false){
if($this->getDisplayEntity()->isClosed()){
$pos = $this->asPosition();
$pos->x += 0.5;
$pos->y += 2.4;
$pos->z += 0.5;

$this->displayEntity = FloatingText::spawn($pos, "");
}

$this->getDisplayEntity()->setNameTag($this->getCrate()->getName() . "\n\n" . TextFormat::RESET . $display);
}
}
Expand Down

1 comment on commit 6cd1c7e

@JaxkDev
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear @CubePM,

I regret to inform you that your plugin "CubeBox" (v1.1.0 submitted on 2020-05-12T14:59:28.000Z) has been rejected.

C3 — Permission names:

If the plugin registers permissions, all permission names must start with the plugin name (does not need to contain the author name like the namespace). The permission name should only consist of alphabets, digits, hyphens and dots.

Tabs with no content.
D3 — Clean description:

Do not provide irrelevant information in the description. See description guide for details. Do not advertise in the description. (Leaving a reasonable number of contacts is allowed)

The plugin requires GD extension, please declare it.
B5 — Declare dependencies:

Declare your dependencies in plugin.yml and include them in the submission form. Plugins with dependencies not released on Poggit will not be approved since they cannot be used without non-Poggit sources.

Please resolve these issues and submit the plugin again.

This comment is posted here because this is the last commit when the released build was created.

Please sign in to comment.