├── README.md ├── plugin.yml ├── .poggit.yml ├── src └── skh6075 │ └── protecteditemframe │ ├── ProtectedItemFrame.php │ └── listener │ └── EventListener.php └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # ProtectItemFrame 2 | [Plugin] Let's protect the frame. 3 | -------------------------------------------------------------------------------- /plugin.yml: -------------------------------------------------------------------------------- 1 | name: ProtectedItemFrame 2 | main: skh6075\protecteditemframe\ProtectedItemFrame 3 | author: AvasKr 4 | api: 3.10.0 5 | version: 1.0.0 6 | website: https://github.com/GodVas -------------------------------------------------------------------------------- /.poggit.yml: -------------------------------------------------------------------------------- 1 | --- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/GodVas/ProtectItemFrame 2 | build-by-default: true 3 | branches: 4 | - main 5 | projects: 6 | ProtectItemFrame: 7 | path: "" 8 | ... 9 | -------------------------------------------------------------------------------- /src/skh6075/protecteditemframe/ProtectedItemFrame.php: -------------------------------------------------------------------------------- 1 | getServer ()->getPluginManager ()->registerEvents (new EventListener (), $this); 13 | } 14 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Song ki ho 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/skh6075/protecteditemframe/listener/EventListener.php: -------------------------------------------------------------------------------- 1 | getPacket (); 21 | if ($packet->pid () === 0x47) { 22 | $player = $event->getPlayer (); 23 | $pos = new Position ($packet->x, $packet->y, $packet->z, $player->getLevel ()); 24 | if (($tile = $player->getLevel ()->getTile ($pos)) instanceof ItemFrame) { 25 | if (!$player->isOp ()) { 26 | $event->setCancelled (); 27 | } 28 | } 29 | } 30 | } 31 | 32 | public function onBlockBreak (BlockBreakEvent $event): void{ 33 | $block = $event->getBlock (); 34 | $player = $event->getPlayer (); 35 | if ($block->getId () === Block::ITEM_FRAME_BLOCK) { 36 | if ($player->isOp ()) { 37 | $tile = $player->getLevel ()->getTile ($block); 38 | $tile->setItem (null); 39 | } else { 40 | $event->setCancelled (); 41 | } 42 | } 43 | } 44 | 45 | public function onPlayerInteract (PlayerInteractEvent $event): void{ 46 | $player = $event->getPlayer (); 47 | $action = $event->getAction (); 48 | if ($action === PlayerInteractEvent::RIGHT_CLICK_BLOCK) { 49 | $block = $event->getBlock (); 50 | if ($block->getId () === Block::ITEM_FRAME_BLOCK) { 51 | if (!$player->isOp ()) { 52 | $event->setCancelled (); 53 | } 54 | } 55 | } 56 | } 57 | } --------------------------------------------------------------------------------