Skip to content

Commit

Permalink
Stucks PHP CS Fixer Config
Browse files Browse the repository at this point in the history
  • Loading branch information
harryitz committed Jul 6, 2024
1 parent f3763f0 commit 5bd58d7
Show file tree
Hide file tree
Showing 12 changed files with 325 additions and 373 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"php":"8.2.5","version":"3.17.0:v3.17.0#3f0ed862f22386c55a767461ef5083bddceeed79","indent":"\t","lineEnding":"\n","rules":{"align_multiline_comment":{"comment_type":"phpdocs_only"},"array_indentation":true,"array_syntax":{"syntax":"short"},"binary_operator_spaces":{"default":"single_space"},"blank_line_after_namespace":true,"blank_line_after_opening_tag":true,"blank_line_before_statement":{"statements":["declare"]},"braces":{"allow_single_line_closure":false,"position_after_anonymous_constructs":"same","position_after_control_structures":"same","position_after_functions_and_oop_constructs":"same"},"cast_spaces":{"space":"single"},"concat_space":{"spacing":"one"},"declare_strict_types":true,"elseif":true,"global_namespace_import":{"import_constants":true,"import_functions":true,"import_classes":null},"indentation_type":true,"native_function_invocation":{"scope":"namespaced","include":["@all"]},"no_closing_tag":true,"no_empty_phpdoc":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true},"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"no_whitespace_in_blank_line":true,"no_unused_imports":true,"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"alpha"},"phpdoc_line_span":{"property":"single","method":null,"const":null},"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"return_type_declaration":{"space_before":"one"},"single_import_per_statement":true,"strict_param":true,"unary_operator_spaces":true},"hashes":{"src\\taylordevs\\SimplySickles\\item\\Diamond_Sickle.php":"520c819ae82725579780efa0b2772823","src\\taylordevs\\SimplySickles\\item\\Golden_Sickle.php":"4e7b47af6216609cd78b4d893d152b1a","src\\taylordevs\\SimplySickles\\item\\Iron_Sickle.php":"af2cef807859548a9527085b37547342","src\\taylordevs\\SimplySickles\\item\\Netherite_Sickle.php":"29f2fa0437b5e4f8d44725c15194b0d8","src\\taylordevs\\SimplySickles\\SimplySickles.php":"a8e4261f125bf854f737b5774f3551cc","src\\taylordevs\\SimplySickles\\item\\Sickle.php":"f14ba7c2cc923a52cbf4dd1c17f673c7","src\\taylordevs\\SimplySickles\\listener\\EventListener.php":"71a9bdb28e1e3ee7c7092c96853174d9","src\\taylordevs\\SimplySickles\\math\\Math.php":"7023a7f7b5765d8bfc991d388c7416dc","src\\taylordevs\\SimplySickles\\utils\\Sound.php":"cd66d5213af6ff5eff8de4e6c46e6763","src\\taylordevs\\SimplySickles\\utils\\Particle.php":"b2d4e7bec15af80159d7adfed90becc8","src\\taylordevs\\SimplySickles\\utils\\Utils.php":"4455fc0e6ff7315df034a803720ccdcc"}}
{"php":"8.2.17","version":"3.17.0:v3.17.0#3f0ed862f22386c55a767461ef5083bddceeed79","indent":"\t","lineEnding":"\n","rules":{"align_multiline_comment":{"comment_type":"phpdocs_only"},"array_indentation":true,"array_syntax":{"syntax":"short"},"binary_operator_spaces":{"default":"single_space"},"blank_line_after_namespace":true,"blank_line_after_opening_tag":true,"blank_line_before_statement":{"statements":["declare"]},"braces":{"allow_single_line_closure":false,"position_after_anonymous_constructs":"same","position_after_control_structures":"same","position_after_functions_and_oop_constructs":"same"},"cast_spaces":{"space":"single"},"concat_space":{"spacing":"one"},"declare_strict_types":true,"elseif":true,"global_namespace_import":{"import_constants":true,"import_functions":true,"import_classes":null},"indentation_type":true,"native_function_invocation":{"scope":"namespaced","include":["@all"]},"no_closing_tag":true,"no_empty_phpdoc":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true},"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"no_whitespace_in_blank_line":true,"no_unused_imports":true,"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"alpha"},"phpdoc_line_span":{"property":"single","method":null,"const":null},"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"return_type_declaration":{"space_before":"one"},"single_import_per_statement":true,"strict_param":true,"unary_operator_spaces":true},"hashes":{"src\\taylordevs\\SimplySickles\\item\\Diamond_Sickle.php":"331a92aa38a2b46aa65e3fd46403ed2d","src\\taylordevs\\SimplySickles\\item\\Golden_Sickle.php":"389d09a9782d7e578b770f303c5eaebd","src\\taylordevs\\SimplySickles\\item\\Iron_Sickle.php":"4f3c3b10c7ceb67897aa0fb2bbb40e88","src\\taylordevs\\SimplySickles\\item\\Netherite_Sickle.php":"1fcb848019eb9ac4feb4f4e4b11314ad","src\\taylordevs\\SimplySickles\\item\\Sickle.php":"ccebeb9f2f8cc37080e9e06598850693","src\\taylordevs\\SimplySickles\\listener\\EventListener.php":"2a4d76158b72bede78547e8e46f418de","src\\taylordevs\\SimplySickles\\math\\Math.php":"5bb1fe5ab0750a09535c14c945883f4d","src\\taylordevs\\SimplySickles\\SimplySickles.php":"e88090eb32b12f9841e3a48efc00fdf8","src\\taylordevs\\SimplySickles\\utils\\Particle.php":"50fae933ba602371f1acb25ecbfdc2ea","src\\taylordevs\\SimplySickles\\utils\\Sound.php":"f02448f7ad6b601a16a67d8208c7c0c0","src\\taylordevs\\SimplySickles\\utils\\Utils.php":"5bf929865bfe31c9147a96429ba7ab2a"}}
111 changes: 54 additions & 57 deletions src/taylordevs/SimplySickles/SimplySickles.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,65 +24,62 @@
use function str_replace;
use function ucwords;

class SimplySickles extends PluginBase
{
private static ?ResourcePack $pack;
class SimplySickles extends PluginBase {
private static ?ResourcePack $pack;

protected function onEnable(): void
{
libCustomPack::registerResourcePack(self::$pack = libCustomPack::generatePackFromResources($this));
$this->getServer()->getPluginManager()->registerEvents(new EventListener(), $this);
protected function onEnable() : void {
libCustomPack::registerResourcePack(self::$pack = libCustomPack::generatePackFromResources($this));
$this->getServer()->getPluginManager()->registerEvents(new EventListener(), $this);

$itemFactory = CustomiesItemFactory::getInstance();
$namespace = mb_strtolower($this->getName() . ":");
foreach ([
"iron_sickle" => Iron_Sickle::class,
"golden_sickle" => Golden_Sickle::class,
"diamond_sickle" => Diamond_Sickle::class,
"netherite_sickle" => Netherite_Sickle::class
] as $name => $class) {
$itemFactory->registerItem($class, $namespace . $name, ucwords(str_replace('_', ' ', $name)));
$itemInstance = $itemFactory->get($namespace . $name);
StringToItemParser::getInstance()->register($name, static fn (string $input) => $itemInstance);
}
$itemFactory = CustomiesItemFactory::getInstance();
$namespace = mb_strtolower($this->getName() . ":");
foreach ([
"iron_sickle" => Iron_Sickle::class,
"golden_sickle" => Golden_Sickle::class,
"diamond_sickle" => Diamond_Sickle::class,
"netherite_sickle" => Netherite_Sickle::class
] as $name => $class) {
$itemFactory->registerItem($class, $namespace . $name, ucwords(str_replace('_', ' ', $name)));
$itemInstance = $itemFactory->get($namespace . $name);
StringToItemParser::getInstance()->register($name, static fn (string $input) => $itemInstance);
}

$craftManager = $this->getServer()->getCraftingManager();
foreach ([
"iron_sickle" => VanillaItems::IRON_INGOT(),
"golden_sickle" => VanillaItems::GOLD_INGOT(),
"diamond_sickle" => VanillaItems::DIAMOND()
] as $name => $item) {
$craftManager->registerShapedRecipe(new ShapedRecipe(
[
' AA',
' A',
'CA '
],
[
'A' => new ExactRecipeIngredient($item),
'C' => new ExactRecipeIngredient(VanillaItems::STICK())
],
[
'A' => $itemFactory->get($namespace . $name)
]
));
}
$craftManager->registerShapelessRecipe(new ShapelessRecipe(
[
new ExactRecipeIngredient($itemFactory->get($namespace . "diamond_sickle")),
new ExactRecipeIngredient(VanillaItems::NETHERITE_INGOT())
],
[
$itemFactory->get($namespace . "netherite_sickle")
],
ShapelessRecipeType::SMITHING()
));
}
$craftManager = $this->getServer()->getCraftingManager();
foreach ([
"iron_sickle" => VanillaItems::IRON_INGOT(),
"golden_sickle" => VanillaItems::GOLD_INGOT(),
"diamond_sickle" => VanillaItems::DIAMOND()
] as $name => $item) {
$craftManager->registerShapedRecipe(new ShapedRecipe(
[
' AA',
' A',
'CA '
],
[
'A' => new ExactRecipeIngredient($item),
'C' => new ExactRecipeIngredient(VanillaItems::STICK())
],
[
'A' => $itemFactory->get($namespace . $name)
]
));
}
$craftManager->registerShapelessRecipe(new ShapelessRecipe(
[
new ExactRecipeIngredient($itemFactory->get($namespace . "diamond_sickle")),
new ExactRecipeIngredient(VanillaItems::NETHERITE_INGOT())
],
[
$itemFactory->get($namespace . "netherite_sickle")
],
ShapelessRecipeType::SMITHING()
));
}

protected function onDisable(): void
{
if (self::$pack instanceof ResourcePack) {
libCustomPack::unregisterResourcePack(self::$pack);
}
}
protected function onDisable() : void {
if (self::$pack instanceof ResourcePack) {
libCustomPack::unregisterResourcePack(self::$pack);
}
}
}
88 changes: 40 additions & 48 deletions src/taylordevs/SimplySickles/item/Diamond_Sickle.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,55 @@
use taylordevs\SimplySickles\math\Math;
use taylordevs\SimplySickles\utils\Utils;

final class Diamond_Sickle extends Tool implements ItemComponents, Sickle
{
use ItemComponentsTrait;
final class Diamond_Sickle extends Tool implements ItemComponents, Sickle {
use ItemComponentsTrait;

private static int $ATTACK_POINTS = 5;
private static int $ATTACK_POINTS = 5;


public function __construct(ItemIdentifier $identifier, string $name = "Diamond Sickle")
{
parent::__construct($identifier, $name);
$this->initComponent("diamond_sickle", new CreativeInventoryInfo(CreativeInventoryInfo::CATEGORY_ITEMS, CreativeInventoryInfo::NONE));
}
public function __construct(ItemIdentifier $identifier, string $name = "Diamond Sickle") {
parent::__construct($identifier, $name);
$this->initComponent("diamond_sickle", new CreativeInventoryInfo(CreativeInventoryInfo::CATEGORY_ITEMS, CreativeInventoryInfo::NONE));
}


public function getMaxStackSize(): int
{
return 1;
}
public function getMaxStackSize() : int {
return 1;
}


public function getMaxDurability(): int
{
return 1650;
}
public function getMaxDurability() : int {
return 1650;
}

public function getAttackPoints(): int
{
return self::$ATTACK_POINTS;
}
public function getAttackPoints() : int {
return self::$ATTACK_POINTS;
}

public function getDamage(): int
{
return self::$ATTACK_POINTS;
}
public function getDamage() : int {
return self::$ATTACK_POINTS;
}

/**
* @param array<Item> $returnedItems
*/
public function onAttackEntity(Entity $victim, array &$returnedItems): bool
{
return $this->applyDamage(self::$ATTACK_POINTS);
}
/**
* @param array<Item> $returnedItems
*/
public function onAttackEntity(Entity $victim, array &$returnedItems) : bool {
return $this->applyDamage(self::$ATTACK_POINTS);
}

/**
* @param array<Item> $returnedItems
*/
public function onDestroyBlock(Block $block, array &$returnedItems): bool
{
$position = $block->getPosition();
$world = $position->getWorld();
$area = Math::makeRhombus($position);
Utils::autoRefill($block, $position, $world);
/** @var Vector3 $pos */
foreach ($area as $pos) {
$block = $world->getBlock($pos);
Utils::autoRefill($block, $pos, $world);
}
return true;
}
/**
* @param array<Item> $returnedItems
*/
public function onDestroyBlock(Block $block, array &$returnedItems) : bool {
$position = $block->getPosition();
$world = $position->getWorld();
$area = Math::makeRhombus($position);
Utils::autoRefill($block, $position, $world);
/** @var Vector3 $pos */
foreach ($area as $pos) {
$block = $world->getBlock($pos);
Utils::autoRefill($block, $pos, $world);
}
return true;
}
}
88 changes: 40 additions & 48 deletions src/taylordevs/SimplySickles/item/Golden_Sickle.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,62 +16,54 @@
use taylordevs\SimplySickles\math\Math;
use taylordevs\SimplySickles\utils\Utils;

final class Golden_Sickle extends Tool implements ItemComponents, Sickle
{
use ItemComponentsTrait;
final class Golden_Sickle extends Tool implements ItemComponents, Sickle {
use ItemComponentsTrait;

private static int $ATTACK_POINTS = 3;
private static int $ATTACK_POINTS = 3;


public function __construct(ItemIdentifier $identifier, string $name = "Golden Sickles")
{
parent::__construct($identifier, $name);
$this->initComponent("golden_sickle", new CreativeInventoryInfo(CreativeInventoryInfo::CATEGORY_ITEMS, CreativeInventoryInfo::NONE));
}
public function __construct(ItemIdentifier $identifier, string $name = "Golden Sickles") {
parent::__construct($identifier, $name);
$this->initComponent("golden_sickle", new CreativeInventoryInfo(CreativeInventoryInfo::CATEGORY_ITEMS, CreativeInventoryInfo::NONE));
}


public function getMaxStackSize(): int
{
return 1;
}
public function getMaxStackSize() : int {
return 1;
}

public function getMaxDurability(): int
{
return 75;
}
public function getMaxDurability() : int {
return 75;
}

public function getAttackPoints(): int
{
return self::$ATTACK_POINTS;
}
public function getAttackPoints() : int {
return self::$ATTACK_POINTS;
}

public function getDamage(): int
{
return self::$ATTACK_POINTS;
}
public function getDamage() : int {
return self::$ATTACK_POINTS;
}

/**
* @param array<Item> $returnedItems
*/
public function onAttackEntity(Entity $victim, array &$returnedItems): bool
{
return $this->applyDamage(self::$ATTACK_POINTS);
}
/**
* @param array<Item> $returnedItems
*/
public function onAttackEntity(Entity $victim, array &$returnedItems) : bool {
return $this->applyDamage(self::$ATTACK_POINTS);
}

/**
* @param array<Item> $returnedItems
*/
public function onDestroyBlock(Block $block, array &$returnedItems): bool
{
$position = $block->getPosition();
$world = $position->getWorld();
$area = Math::makeSquare($position);
Utils::autoRefill($block, $position, $world);
/** @var Vector3 $pos */
foreach ($area as $pos) {
$block = $world->getBlock($pos);
Utils::autoRefill($block, $pos, $world);
}
return true;
}
/**
* @param array<Item> $returnedItems
*/
public function onDestroyBlock(Block $block, array &$returnedItems) : bool {
$position = $block->getPosition();
$world = $position->getWorld();
$area = Math::makeSquare($position);
Utils::autoRefill($block, $position, $world);
/** @var Vector3 $pos */
foreach ($area as $pos) {
$block = $world->getBlock($pos);
Utils::autoRefill($block, $pos, $world);
}
return true;
}
}
Loading

0 comments on commit 5bd58d7

Please sign in to comment.