diff --git a/README.md b/README.md index f1acfaa..a7c0236 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,28 @@ ## Festival -If you like Festival please leave a thumb up at [poggit](https://poggit.pmmp.io/p/Festival/1.0.6-13) to help getting the Festival plugin approved, thank you!_ +If you like Festival please leave a thumb up at [poggit](https://poggit.pmmp.io/p/Festival/1.0.7) to help getting the Festival plugin approved, thank you!_ -![Festival plugin logo large](https://genboy.net/wp-content/uploads/2018/02/festival_plugin_logo.png) +![Festival plugin logo large](https://genboy.net/wp-content/uploads/2018/02/festival_plugin_logo.png) -Create a festival with this custom area events plugin for Pocketmine Server ALPHA10+: -### Manage area's and run commmands attachted to area events. +Create a festival with this custom area events plugin for Pocketmine Server: +### Manage area's and run commmands attachted to area events. -![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/06/festival_usage_1.0.6-13x.png) + +![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/08/festival_usage_1.0.7-1.png) ###### Copyright [Genboy](https://genboy.net) 2018 ---- +--- ## Info # Festival -[![](https://poggit.pmmp.io/shield.state/Festival)](https://poggit.pmmp.io/p/Festival) +[![](https://poggit.pmmp.io/shield.state/Festival)](https://poggit.pmmp.io/p/Festival) [![](https://poggit.pmmp.io/shield.api/Festival)](https://poggit.pmmp.io/p/Festival) [![](https://poggit.pmmp.io/shield.dl.total/Festival)](https://poggit.pmmp.io/p/Festival) [![](https://poggit.pmmp.io/shield.dl/Festival)](https://poggit.pmmp.io/p/Festival) @@ -40,23 +41,25 @@ Create a festival with this custom area events plugin for Pocketmine Server ALPH - add area description - whitelist players for the area - tp to an area - - show area’s info at current position + - show area’s info at current position **Flags** - Set area flags true means - - edit: area is save from building/breaking + - edit: the area is save from building/breaking - god: players in the area are save in god mode - pvp: players in the area are save from PVP - flight: players in the area are not allowed to fly - touch: area is save from player interaction with chests/signs etc. - - effects: player can not keep using effects in the area (v.1.0.5-12) + - effects: player can not keep using effects in the area - msg: do not display area enter/leave messages - passage: no passage for non-whitelisted players! (previously barrier flag) - - perms: player permissions are used to determine area command execution (experiment) - drop: players can not drop things + - tnt: explosions protected area + - hunger: player does not exhaust / hunger + - perms: player permissions are used to determine area command execution (experiment) **Events & Commands** @@ -74,7 +77,7 @@ Create a festival with this custom area events plugin for Pocketmine Server ALPH - World: Default & world specific flags in config.yml - Flight: if server allows flight, and level flight-flag is true, an area in that level has still flight enabled untill flight flag is set true - - Perms: Area event commands are executed by default with op-permissions by players from the area. In v1.0.4-11 an experimental perms flag is added, perms flag true: area uses the player permissions + - Perms: Area event commands are executed by default with op-permissions by players or, if perms flag true: area uses the player permissions ###### Created by [Genboy](https://genboy.net) 2018 @@ -100,14 +103,14 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). ### Updates - + Updates available at [poggit](https://poggit.pmmp.io/ci/genboy/Festival/Festival) and [github](https://github.com/genboy/Festival/releases) ##### !Before update always copy your config.yml and areas.json files to a save place, with this you can revert your Festival installation - after .phar install and first restart/reload plugins; check console info and your areas.json and config.yml; restart after adjusted correctly **Since v1.0.3-11+** - - pass(passage) flag replaces the barrier flag + - pass(passage) flag gives the area a barrier for non ops/whitelisted - configuration for area messages (taken out of chat) - Msgtype: tip or pop (prefer depend on other plugin message display) - Msgdisplay: @@ -130,10 +133,28 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). - /fe list LEVELNAME - Area list of all area's in all levels, or for specified level - configuration should be updated [resources/config.yml](https://github.com/genboy/Festival/blob/master/resources/config.yml) - + **New in v1.0.7** + - new TNT flag + - new Hunger flag + - Fire is now extinguished when player does not get damage (aka. in area with god flag on) + + + + #### Usage Graphic + + ##### A visualisation of Festival command usage + + ![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/08/festival_usage_1.0.7-1.png) + + ###### Copyright [Genboy](https://genboy.net) 2018 + + + #### Create area First command '/fe pos1' and tab a block for position 1, - then command '/fe pos2' and ab a block to set position2, + + then command '/fe pos2' and tab a block to set position2, + these are the endpoints of the area longest diagonal. /fe pos1 @@ -147,7 +168,7 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). Now the area is ready to use You might want to set or edit the area description line - + /fe desc @@ -155,13 +176,13 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). Festival v1.0.1-11 introduced a fast toggle for flags: - /fe + /fe Area flag defaults are set in the config.yml), server defaults and world specific default flag. The basic command to control area flags: - /fe flag(f) + /fe flag(f) Area flag listing @@ -170,6 +191,8 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). #### Position info + See area information at position + /fe here #### List all area's @@ -179,7 +202,10 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). #### Teleport to area /fe tp - + + + + #### Set description /fe desc @@ -191,16 +217,32 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). #### Delete an area /fe delete(del,remove) + + + + #### Area event commands - /fe command - + **This is the fun part of Festival: assign commands to area events** + + When an area is created 3 events are available; + - enter; when a player enters the area + - center; when a player reaches the center (3x3xareaHeight blocks) + - leave; when a player leaves the area + + To add a command you need at least; - an areaname, - an unique id for the command - - make sure the command works! (when you are op). + - make sure the command works! (when you are op) + + + /fe command + + + #### Add a command: /fe command add @@ -259,18 +301,21 @@ Thank you - [x] Passage flag; turning the area into a barrier, no one in, no one out. - [x] /fe tp now sends player to the area top-center and prevents fall damage -### Milestones v1.0.3-11 - v1.0.6-13 +### Milestones v1.0.3-11 - v1.0.7 - [x] Config options: - Messages out of chat (tip/pop) - Messages persist display to ops (off/op/on) - Auto whitelist area creator (on/off) - [x] Effects flag: remove players effects in area - - [x] Perms flag: player perms used for area commands (vs OP pems) [experimental] + - [x] Perms flag: player perms used for area commands (vs OP pems) - [x] Drop flag: player can not drop things - [x] PVP flag: players can not PvP (warn message) - [x] Flight flag: players can not fly (incl. no fall damage & allowed messages) - [x] Area Commands: playerName can be used as **{player}** or **@p** in area event commands + - [x] TNT flag: explosion free area's + - [x] Hunger flag: players do not exhaust + - [x] Fire (animation) extinguished when player is save ------ @@ -280,7 +325,5 @@ Thank you The area code derives from the [iProctector plugin](https://github.com/LDX-MCPE/iProtector). All credits for the area creation and protection code go to the iProtector creator [LDX-MCPE](https://github.com/LDX-MCPE) and [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). -In a first fork from [poggit-orphanage](https://github.com/poggit-orphanage/iProtector) the new code was extending the area with enter and leave messages and adding options to attach separate event-objects to an area and trigger specific events with commands. These test versions kept the core iProtector areas unchanged (to be able to use excisting area's). - -These first adjustments worked well being a test plugin but keeping iProtector area's while adding separate event data made me create a split command structure (wich isn't logical or handy) and separate event objects are only needed if the original area class should stay the same. So, for a better plugin command structure and performance the iProtector Area code was used to create the setup for what now has become the Festival Plugin. +The Festival code is written and tested by Genboy and first released on 12 Feb 2018, first extendomg the area object with area events (enter and leave messages) and soon added functions and ingame commands to attach a commandstring to a area-event. Since v1.0.7 the area's and players can be protected with 12 flags, and trigger commands on areaEnter, areaCenter and areaLeave. diff --git a/plugin.yml b/plugin.yml index fd96597..6f207ab 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,14 +1,14 @@ name: Festival author: Genboy -version: 1.0.6-13 +version: 1.0.7 main: genboy\Festival\Main load: POSTWORLD -api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12] +api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0,4.0.0] website: "https://github.com/genboy/Festival" commands: fe: description: "Allows you to manage Festival area's and events." - usage: "See info: /fe ; Create area: select 2 positions /fe , then /fe create ; Toggle flags: /fe ; Set commands: /fe command ; (Edit)del command: /fe command <(edit)/del> (); Change command event: /fe command event " + usage: "See info: /fe ; Create area: select 2 positions /fe , then /fe create ; Toggle flags: /fe ; Set commands: /fe command ; (Edit)del command: /fe command <(edit)/del> (); Change event for command: /fe command event " permission: festival.command.fe permissions: festival: diff --git a/resources/config.yml b/resources/config.yml index 452fba0..31085a7 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -42,6 +42,12 @@ Default: # Keep players from dropping items in the area? Drop: false + # No explosions allowed in the area? + TNT: false + + # Keep players from hunger(exhaust) in the area? + Hunger: false + # Keep players from executing area event commands without specific perms Perms: false @@ -74,9 +80,15 @@ Worlds: # Prevent players from enter/leaving the area? (barrier) Passage: false - # Keep players from dropping items in the area? + # No explosions allowed in the area? Drop: false + # No explosions allowed in the area? + TNT: false + + # Keep players from hunger(exhaust) in the area? + Hunger: false + # Keep players from executing area event commands without specific perms Perms: false @@ -108,6 +120,12 @@ Worlds: # Keep players from dropping items in the area? Drop: false - + + # No explosions allowed in the area? + TNT: false + + # Keep players from hunger(exhaust) in the area? + Hunger: false + # Keep players from executing area event commands without specific perms Perms: false diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 203e797..055c75d 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -11,6 +11,7 @@ use pocketmine\event\block\BlockPlaceEvent; use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageByEntityEvent; +use pocketmine\event\entity\EntityExplodeEvent; use pocketmine\event\Listener; use pocketmine\level\Position; use pocketmine\math\Vector3; @@ -21,6 +22,7 @@ use pocketmine\event\player\PlayerMoveEvent; use pocketmine\event\player\PlayerInteractEvent; use pocketmine\event\player\PlayerCommandPreprocessEvent; +use pocketmine\event\player\PlayerExhaustEvent; use pocketmine\event\player\PlayerDropItemEvent; use pocketmine\event\player\PlayerQuitEvent; @@ -52,9 +54,13 @@ class Main extends PluginBase implements Listener{ /** @var bool */ private $passage = false; /** @var bool */ - private $perms = false; - /** @var bool */ private $drop = false; + /** @var bool */ + private $tnt = false; + /** @var bool */ + private $hunger = false; + /** @var bool */ + private $perms = false; /** @var bool[] */ private $selectingFirst = []; @@ -134,6 +140,15 @@ public function onEnable() : void{ $flags["flight"] = false; $newchange['Flight'] = "! Area Flight flag missing, now updated to 'false'; please see /resources/config.yml"; } + //new flags v 1.0.7 + if( !isset($datum["flags"]["tnt"]) ){ + $flags["tnt"] = false; + $newchange['TNT'] = "! Area TNT flag missing, now updated to 'false'; please see /resources/config.yml"; + } + if( !isset($datum["flags"]["hunger"]) ){ + $flags["hunger"] = false; + $newchange['Hunger'] = "! Area Hunger flag missing, now updated to 'false'; please see /resources/config.yml"; + } new Area($datum["name"], $datum["desc"], $flags, new Vector3($datum["pos1"]["0"], $datum["pos1"]["1"], $datum["pos1"]["2"]), new Vector3($datum["pos2"]["0"], $datum["pos2"]["1"], $datum["pos2"]["2"]), $datum["level"], $datum["whitelist"], $datum["commands"], $datum["events"], $this); } @@ -203,6 +218,15 @@ public function onEnable() : void{ if(!isset($c["Default"]["Flight"])) { $c["Default"]["Flight"] = false; } + // new in v1.0.7 + if(!isset($c["Default"]["TNT"])) { + $c["Default"]["TNT"] = false; + } + if(!isset($c["Default"]["Hunger"])) { + $c["Default"]["Hunger"] = false; + } + + $this->god = $c["Default"]["God"]; $this->edit = $c["Default"]["Edit"]; @@ -215,10 +239,14 @@ public function onEnable() : void{ $this->drop = $c["Default"]["Drop"]; // new in v1.0.5-12 $this->effects = $c["Default"]["Effects"]; - $this->flagset = $c['Default']; + $this->flagset = $c['Default']; // new in v1.0.6-13 $this->pvp = $c["Default"]["PVP"]; $this->flight = $c["Default"]["Flight"]; + // new in v1.0.7 + $this->tnt = $c["Default"]["TNT"]; + $this->tnt = $c["Default"]["Hunger"]; + // world default flag settings if(is_array( $c["Worlds"] )){ @@ -252,7 +280,13 @@ public function onEnable() : void{ if( !isset($flags["Flight"]) ){ $flags["Flight"] = $this->flight; } - + // new v1.0.7 + if( !isset($flags["TNT"]) ){ + $flags["TNT"] = $this->tnt; + } + if( !isset($flags["Hunger"]) ){ + $flags["Hunger"] = $this->hunger; + } $this->levels[$level] = $flags; } } @@ -260,16 +294,17 @@ public function onEnable() : void{ // all save :) $this->saveAreas(); - // console output - $this->codeSigned(); + /** console output */ + // codesign + $this->codeSigned(); + // plugin area info $ca = 0; foreach( $this->areas as $a ){ $ca = $ca + count( $a->getCommands() ); } $this->getLogger()->info( " ". $ca ." commands in " . count($this->areas) . " areas" ); - - //v1.0.6-13-dev + // warnings changes if( count($newchange) > 0 ){ foreach($newchange as $ttl => $txt){ $this->getLogger()->info( $ttl . ": " . $txt ); @@ -290,6 +325,8 @@ public function isFlag( $str ){ "edit","build","break","place", "touch","interact", "effects","magic","effect", + "tnt","explode", + "hunger","starve", "drop", "msg","message", "passage","pass","barrier", @@ -323,9 +360,15 @@ public function isFlag( $str ){ if( $str == "pass" || $str == "barrier" ){ $flag = "passage"; } + if( $str == "tnt" || $str == "explode" ){ + $flag = "tnt"; + } if( $str == "effect" || $str == "effects" ){ $flag = "effects"; } + if( $str == "hunger" || $str == "starve" ){ + $flag = "hunger"; + } } return $flag; } @@ -591,6 +634,10 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "barrier": case "perm": case "perms": + case "hunger": + case "starve": + case "tnt": + case "explode": case "drop": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.flag")){ if(isset($args[1])){ @@ -1048,6 +1095,9 @@ public function canDamage(EntityDamageEvent $ev) : bool{ $player = $ev->getEntity(); $playerName = strtolower($player->getName()); if(!$this->canGetHurt($player)){ + if( $player->isOnFire() ){ + $player->extinguish(); // 1.0.7-dev + } $ev->setCancelled(); return false; } @@ -1157,6 +1207,86 @@ public function onBlockTouch(PlayerInteractEvent $event) : void{ } } + /** hunger + * PlayerExhaustEvent + * @param PlayerExhaustEvent $event + * @return void + */ + + public function Hunger(PlayerExhaustEvent $event){ + if ( !$this->canHunger( $event->getPlayer()->getPosition() ) ) { + $event->setCancelled(); + } + } + + /** + * canhunger() + * Checks if player can exhaust (hunger) + * @param pocketmine\level\Position $pos + * @param pocketmine\level\Level $level + * @return bool + */ + public function canHunger( Position $pos ): bool{ + $o = true; + $g = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Hunger"] : $this->hunger); + if ($g) { + $o = false; + } + foreach ($this->areas as $area) { + if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { + if ($area->getFlag("hunger")) { + $o = false; + break; + } + if ($area->getFlag("hunger") && $g) { + $o = true; + break; + } + } + } + return $o; + } + + + /** on Explode entity + * EntityExplodeEvent + * @param EntityExplodeEvent $event + * @return void + */ + public function onEntityExplode(EntityExplodeEvent $event){ + if (!$this->canExplode( $event->getPosition() )) { + $event->setCancelled(); + } + } + + /** + * canExplode() + * Checks if entity can explode on given position + * @param pocketmine\level\Position $pos + * @param pocketmine\level\Level $level + * @return bool + */ + public function canExplode( Position $pos ): bool{ + $o = true; + $g = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["TNT"] : $this->tnt); + if ($g) { + $o = false; + } + foreach ($this->areas as $area) { + if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { + if ($area->getFlag("tnt")) { + $o = false; + break; + } + if ($area->getFlag("tnt") && $g) { + $o = true; + break; + } + } + } + return $o; + } + /** Item drop * @param itemDropEvent $event * @ignoreCancelled true