Skip to content

Commit

Permalink
Remove SETTING_ prefix
Browse files Browse the repository at this point in the history
As the class is named `SkyblockSettingTypes`, I feel it is unnecessary to include the `SETTING_` prefix, as it is already implied by the class name.
  • Loading branch information
DuoIncure committed Aug 18, 2023
1 parent cfa3914 commit ba3336b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public function onRun(CommandSender $sender, string $aliasUsed, array $args): vo
array_shift($data);

$newSettings = [];
$newSettings[SkyblockSettingTypes::SETTING_VISIT] = (bool)$data[0];
$newSettings[SkyblockSettingTypes::SETTING_PVP] = (bool)$data[1];
$newSettings[SkyblockSettingTypes::SETTING_INTERACT_CHEST] = (bool)$data[2];
$newSettings[SkyblockSettingTypes::SETTING_INTERACT_DOOR] = (bool)$data[3];
$newSettings[SkyblockSettingTypes::SETTING_PICKUP] = (bool)$data[4];
$newSettings[SkyblockSettingTypes::SETTING_BREAK] = (bool)$data[5];
$newSettings[SkyblockSettingTypes::SETTING_PLACE] = (bool)$data[6];
$newSettings[SkyblockSettingTypes::VISIT] = (bool)$data[0];
$newSettings[SkyblockSettingTypes::PVP] = (bool)$data[1];
$newSettings[SkyblockSettingTypes::INTERACT_CHEST] = (bool)$data[2];
$newSettings[SkyblockSettingTypes::INTERACT_DOOR] = (bool)$data[3];
$newSettings[SkyblockSettingTypes::PICKUP] = (bool)$data[4];
$newSettings[SkyblockSettingTypes::BREAK] = (bool)$data[5];
$newSettings[SkyblockSettingTypes::PLACE] = (bool)$data[6];

$skyblock->updateSettings($newSettings);
$player->sendMessage($plugin->getMessages()->getMessage('updated-settings'));
Expand All @@ -71,13 +71,13 @@ public function onRun(CommandSender $sender, string $aliasUsed, array $args): vo
$settingsForm->setTitle(TextFormat::colorize(strval($formConfig->getNested('settings.title'))));
$settingsForm->addLabel(TextFormat::colorize(strval($formConfig->getNested('settings.text'))));

$settingsForm->addToggle('Open for Visiting', $skyblock->getSetting(SkyblockSettingTypes::SETTING_VISIT));
$settingsForm->addToggle('PvP', $skyblock->getSetting(SkyblockSettingTypes::SETTING_PVP));
$settingsForm->addToggle('Open Chests', $skyblock->getSetting(SkyblockSettingTypes::SETTING_INTERACT_CHEST));
$settingsForm->addToggle('Open Doors', $skyblock->getSetting(SkyblockSettingTypes::SETTING_INTERACT_DOOR));
$settingsForm->addToggle('Pickup Items', $skyblock->getSetting(SkyblockSettingTypes::SETTING_PICKUP));
$settingsForm->addToggle('Break Blocks', $skyblock->getSetting(SkyblockSettingTypes::SETTING_BREAK));
$settingsForm->addToggle('Place Blocks', $skyblock->getSetting(SkyblockSettingTypes::SETTING_PLACE));
$settingsForm->addToggle('Open for Visiting', $skyblock->getSetting(SkyblockSettingTypes::VISIT));
$settingsForm->addToggle('PvP', $skyblock->getSetting(SkyblockSettingTypes::PVP));
$settingsForm->addToggle('Open Chests', $skyblock->getSetting(SkyblockSettingTypes::INTERACT_CHEST));
$settingsForm->addToggle('Open Doors', $skyblock->getSetting(SkyblockSettingTypes::INTERACT_DOOR));
$settingsForm->addToggle('Pickup Items', $skyblock->getSetting(SkyblockSettingTypes::PICKUP));
$settingsForm->addToggle('Break Blocks', $skyblock->getSetting(SkyblockSettingTypes::BREAK));
$settingsForm->addToggle('Place Blocks', $skyblock->getSetting(SkyblockSettingTypes::PLACE));

$sender->sendForm($settingsForm);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function onRun(CommandSender $sender, string $aliasUsed, array $args): vo
$sender->sendMessage($plugin->getMessages()->getMessage('no-island'));
return;
}
if(!$skyblock->getSetting(SkyblockSettingTypes::SETTING_VISIT)) {
if(!$skyblock->getSetting(SkyblockSettingTypes::VISIT)) {
$sender->sendMessage($plugin->getMessages()->getMessage('island-not-open'));
return;
}
Expand All @@ -63,7 +63,7 @@ public function onRun(CommandSender $sender, string $aliasUsed, array $args): vo
if(!$sbPlayer instanceof Player) continue;
$skyblock = $plugin->getSkyBlockManager()->getSkyBlockByUuid($sbPlayer->getSkyBlock());
if ($skyblock instanceof SkyBlock) {
if (!in_array($skyblock->getUuid(), $skyblocks, true) && $skyblock->getSetting(SkyblockSettingTypes::SETTING_VISIT)) {
if (!in_array($skyblock->getUuid(), $skyblocks, true) && $skyblock->getSetting(SkyblockSettingTypes::VISIT)) {
$skyblocks[] = $skyblock->getUuid();
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Vecnavium/SkyBlocksPM/listener/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function onBreak(BlockBreakEvent $event): void {
$skyblock = $this->plugin->getSkyBlockManager()->getSkyBlockByWorld($event->getBlock()->getPosition()->getWorld());
if(!$skyblock instanceof SkyBlock) return;

if (!in_array($player->getName(), $skyblock->getMembers(), true) && !$skyblock->getSetting(SkyblockSettingTypes::SETTING_BREAK)) {
if (!in_array($player->getName(), $skyblock->getMembers(), true) && !$skyblock->getSetting(SkyblockSettingTypes::BREAK)) {
$event->cancel();
return;
}
Expand Down Expand Up @@ -95,7 +95,7 @@ public function onPlace(BlockPlaceEvent $event): void {
$skyblock = $this->plugin->getSkyBlockManager()->getSkyBlockByWorld($event->getPlayer()->getPosition()->getWorld());
if(!$skyblock instanceof SkyBlock) return;

if (!in_array($event->getPlayer()->getName(), $skyblock->getMembers(), true) && !$skyblock->getSetting(SkyblockSettingTypes::SETTING_PLACE)) {
if (!in_array($event->getPlayer()->getName(), $skyblock->getMembers(), true) && !$skyblock->getSetting(SkyblockSettingTypes::PLACE)) {
$event->cancel();
}
}
Expand All @@ -112,11 +112,11 @@ public function onInteract(PlayerInteractEvent $event): void {

if (!in_array($player->getName(), $skyblock->getMembers(), true)) {
if ($event->getBlock() instanceof Chest) {
if (!$skyblock->getSetting(SkyblockSettingTypes::SETTING_INTERACT_CHEST)) {
if (!$skyblock->getSetting(SkyblockSettingTypes::INTERACT_CHEST)) {
$event->cancel();
}
} elseif ($event->getBlock() instanceof Door) {
if (!$skyblock->getSetting(SkyblockSettingTypes::SETTING_INTERACT_DOOR)) {
if (!$skyblock->getSetting(SkyblockSettingTypes::INTERACT_DOOR)) {
$event->cancel();
}
} else {
Expand All @@ -135,7 +135,7 @@ public function onPlayerDamage(EntityDamageEvent $event): void {
$skyblock = $this->plugin->getSkyBlockManager()->getSkyBlockByWorld($entity->getWorld());
if (!$skyblock instanceof SkyBlock) return;

if ($event instanceof EntityDamageByEntityEvent && $skyblock->getSetting(SkyblockSettingTypes::SETTING_PVP)) return;
if ($event instanceof EntityDamageByEntityEvent && $skyblock->getSetting(SkyblockSettingTypes::PVP)) return;

$shouldCancel = match ($event->getCause()) {
EntityDamageEvent::CAUSE_LAVA => $this->plugin->getNewConfig()->settings->damage->lava,
Expand Down Expand Up @@ -182,7 +182,7 @@ public function onPickup(EntityItemPickupEvent $event): void {
$skyblock = $this->plugin->getSkyBlockManager()->getSkyBlockByWorld($entity->getWorld());
if (!$skyblock instanceof SkyBlock) return;

if(!in_array($entity->getName(), $skyblock->getMembers(), true) && !$skyblock->getSetting(SkyblockSettingTypes::SETTING_PICKUP)) {
if(!in_array($entity->getName(), $skyblock->getMembers(), true) && !$skyblock->getSetting(SkyblockSettingTypes::PICKUP)) {
$event->cancel();
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/Vecnavium/SkyBlocksPM/skyblock/SkyblockSettingTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

final class SkyblockSettingTypes{

const SETTING_VISIT = 'visit';
const SETTING_PVP = 'pvp';
const SETTING_INTERACT_CHEST = 'interact_chest';
const SETTING_INTERACT_DOOR = 'interact_door';
const SETTING_PICKUP = 'pickup';
const SETTING_BREAK = 'break';
const SETTING_PLACE = 'place';
const VISIT = 'visit';
const PVP = 'pvp';
const INTERACT_CHEST = 'interact_chest';
const INTERACT_DOOR = 'interact_door';
const PICKUP = 'pickup';
const BREAK = 'break';
const PLACE = 'place';
}

0 comments on commit ba3336b

Please sign in to comment.