From 56ca6899a2ddfdcb039c42aa813d9b5f7f15b46e Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 11 Aug 2018 03:02:52 +0200 Subject: [PATCH 01/68] debug flight and warnings msg rules/flag --- plugin.yml | 2 +- src/genboy/Festival/Main.php | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/plugin.yml b/plugin.yml index a3a308d..550d796 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: Festival author: Genboy -version: 1.0.7 +version: 1.0.7.1-dev main: genboy\Festival\Main load: POSTWORLD api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0,3.0.1,3.0.2,3.0.3,3.0.4,3.0.5,3.0.6,3.0.7,3.0.8,3.0.9,3.1.0,3.1.1,3.1.2,3.1.3] diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 055c75d..02b0f02 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -604,7 +604,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $cy2 = max( $area->getSecondPosition()->getY(), $area->getFirstPosition()->getY()); $this->playerTP[$playerName] = true; // player tp active //$this->areaMessage( 'Fall save on!', $sender ); - $sender->sendMessage( $playerName ); + //$sender->sendMessage( $playerName ); $sender->teleport( new Position( $cx, $cy2+ 0.5, $cz, $area->getLevel() ) ); }else{ @@ -1463,6 +1463,7 @@ public function checkPlayerFlying(Player $player){ $fly = false; // flag default } + $sendmsg = false; foreach($this->areas as $area){ if( $area->contains( $player->getPosition(), $player->getLevel()->getName() ) ){ if( $area->getFlag("flight") && !$area->isWhitelisted( strtolower($player->getName())) ){ @@ -1470,6 +1471,11 @@ public function checkPlayerFlying(Player $player){ }else{ $fly = true; } + if( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ){ + $sendmsg = true; + }else{ + $sendmsg = false; + } } } if( $player->isOp() ){ @@ -1480,10 +1486,17 @@ public function checkPlayerFlying(Player $player){ if( !$fly && $player->isFlying() ){ $this->playerTP[ strtolower( $player->getName() ) ] = true; // player tp active (fall save) $player->setFlying(false); - $player->sendMessage( TextFormat::RED . "NO Flying here!" ); + //$player->sendMessage( TextFormat::RED . "NO Flying here!" ); + if( $sendmsg ){ + $msg = TextFormat::RED . "NO Flying here!"; + $player->sendMessage( $msg ); + } } if( $fly && !$player->isFlying() && !$player->getAllowFlight() ){ - $player->sendMessage( TextFormat::GREEN . "Flying allowed here!" ); + if( $sendmsg ){ + $msg = TextFormat::GREEN . "Flying allowed here!"; + $player->sendMessage( $msg ); + } } $player->setAllowFlight($fly); From 075e76530f8e3819e5386f8147097d90bf9250a2 Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 11 Aug 2018 03:06:41 +0200 Subject: [PATCH 02/68] A =P_i* --- plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.yml b/plugin.yml index 550d796..d379490 100644 --- a/plugin.yml +++ b/plugin.yml @@ -3,7 +3,7 @@ author: Genboy version: 1.0.7.1-dev main: genboy\Festival\Main load: POSTWORLD -api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0,3.0.1,3.0.2,3.0.3,3.0.4,3.0.5,3.0.6,3.0.7,3.0.8,3.0.9,3.1.0,3.1.1,3.1.2,3.1.3] +api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0] website: "https://github.com/genboy/Festival" commands: fe: From 41c4aebae106df02a664511d02fa5577c5f3ecfd Mon Sep 17 00:00:00 2001 From: iZeaoGamer Date: Wed, 15 Aug 2018 18:02:23 +0100 Subject: [PATCH 03/68] Main: Implement No Fall Damage flag Along with that, I've also added the needed events for No Fall Damage flag. --- src/genboy/Festival/Main.php | 73 +++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 10 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 02b0f02..6eab017 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -61,6 +61,8 @@ class Main extends PluginBase implements Listener{ private $hunger = false; /** @var bool */ private $perms = false; + /** @var bool */ + private $nofalldamage = false; /** @var bool[] */ private $selectingFirst = []; @@ -149,7 +151,10 @@ public function onEnable() : void{ $flags["hunger"] = false; $newchange['Hunger'] = "! Area Hunger flag missing, now updated to 'false'; please see /resources/config.yml"; } - + if( !isset($datum["flags"]["nofalldamage"]) ){ + $flags["nofalldamage"] = false; + $newchange['NoFallDamage'] = "! Area NoFallDamage 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); } @@ -225,8 +230,9 @@ public function onEnable() : void{ if(!isset($c["Default"]["Hunger"])) { $c["Default"]["Hunger"] = false; } - - + if(!isset($c["Default"]["NoFallDamage"])) { + $c["Default"]["NoFallDamage"] = false; + } $this->god = $c["Default"]["God"]; $this->edit = $c["Default"]["Edit"]; @@ -246,7 +252,7 @@ public function onEnable() : void{ // new in v1.0.7 $this->tnt = $c["Default"]["TNT"]; $this->tnt = $c["Default"]["Hunger"]; - + $this->nofalldamage = $c["Default"]["NoFallDamage"]; // world default flag settings if(is_array( $c["Worlds"] )){ @@ -287,6 +293,9 @@ public function onEnable() : void{ if( !isset($flags["Hunger"]) ){ $flags["Hunger"] = $this->hunger; } + if( !isset($flags["NoFallDamage"]) ){ + $flags["NoFallDamage"] = $this->nofalldamage; + } $this->levels[$level] = $flags; } } @@ -330,7 +339,8 @@ public function isFlag( $str ){ "drop", "msg","message", "passage","pass","barrier", - "perms","perm" + "perms","perm", + "nofalldamage" ]; $str = strtolower( $str ); $flag = false; @@ -369,6 +379,9 @@ public function isFlag( $str ){ if( $str == "hunger" || $str == "starve" ){ $flag = "hunger"; } + if( $str == "nofalldamage" ){ + $flag = "nofalldamage"; + } } return $flag; } @@ -639,6 +652,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "tnt": case "explode": case "drop": + case "nofalldamage"; if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.flag")){ if(isset($args[1])){ @@ -729,10 +743,10 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } $o = TextFormat::GREEN . "Flag " . $flag . " set to " . $status . " for area " . $area->getName() . "!"; }else{ - $o = TextFormat::RED . "Flag not found. (Flags: edit, god, pvp, flight, touch, effects, msg, passage, perms, drop)"; + $o = TextFormat::RED . "Flag not found. (Flags: edit, god, pvp, flight, touch, effects, msg, passage, perms, drop, nofalldamage)"; } }else{ - $o = TextFormat::RED . "Please specify a flag. (Flags: edit, god, pvp, flight, touch, effects, msg, passage, perms, drop)"; + $o = TextFormat::RED . "Please specify a flag. (Flags: edit, god, pvp, flight, touch, effects, msg, passage, perms, drop, nofalldamage)"; } } }else{ @@ -1122,7 +1136,34 @@ public function canDamage(EntityDamageEvent $ev) : bool{ public function onHurt(EntityDamageEvent $event) : void{ $this->canDamage( $event ); } - + /** On No fall Damage + * @param EntityDamageEvent $event + * @ignoreCancelled true + */ + /** + * @param Entity $entity + * + * @return bool + */ + public function nfdamage(Entity $entity) : bool{ + $o = true; + $default = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["NoFallDamage"] : $this->nofalldamage); + if($default){ + $o = false; + } + foreach($this->areas as $area){ + if($area->contains(new Vector3($entity->getX(), $entity->getY(), $entity->getZ()), $entity->getLevel()->getName())){ + if($default && !$area->getFlag("nofalldamage")){ + $o = true; + break; + } + if($area->getFlag("nofalldamage")){ + $o = false; + } + } + } + return $o; + } /** On Damage * @param EntityDamageEvent $event * @ignoreCancelled true @@ -1953,7 +1994,20 @@ public function areaInfoList( $area ){ return $l; } - + public function onFallDisable(EntityDamageEvent $event) : void{ + $player = $event->getEntity(); + $level = $player->getLevel()->getFolderName(); + $cause = $event->getCause(); + if($event->getEntity() instanceof Player){ + if(!$this->canGetHurt($player)){ + $event->setCancelled(); + } + + if($cause == EntityDamageEvent::CAUSE_FALL && !$this->nfdamage($player)){ + $event->setCancelled(true); + } + } + } /** Save areas * @var obj area @@ -1966,7 +2020,6 @@ public function saveAreas() : void{ } file_put_contents($this->getDataFolder() . "areas.json", json_encode($areas)); } - /** Festival Console Sign Flag for developers * makes it easy to find Festival console output fast */ From b54292f9daaab83458f98cc923b032fc6c2a53b0 Mon Sep 17 00:00:00 2001 From: iZeaoGamer Date: Wed, 15 Aug 2018 18:04:22 +0100 Subject: [PATCH 04/68] Add NFD to config BTW, NFD stands for NoFallDamage. --- resources/config.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/resources/config.yml b/resources/config.yml index 31085a7..a92858a 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -50,7 +50,10 @@ Default: # Keep players from executing area event commands without specific perms Perms: false - + + # Keep players from taking fall damage + NoFallDamage: false + # Settings for unprotected areas in individual worlds: Worlds: @@ -92,6 +95,9 @@ Worlds: # Keep players from executing area event commands without specific perms Perms: false + # Keep players from taking fall damage + NoFallDamage: false + world: # Keep players from getting hurt? @@ -129,3 +135,6 @@ Worlds: # Keep players from executing area event commands without specific perms Perms: false + + # Keep players from taking fall damage + NoFallDamage: false From 73bc4604ef71b9d724358812058777f34ed131f9 Mon Sep 17 00:00:00 2001 From: iZeaoGamer Date: Wed, 15 Aug 2018 18:07:39 +0100 Subject: [PATCH 05/68] Added type hints. --- src/genboy/Festival/Main.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 6eab017..4276ec0 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -151,6 +151,7 @@ public function onEnable() : void{ $flags["hunger"] = false; $newchange['Hunger'] = "! Area Hunger flag missing, now updated to 'false'; please see /resources/config.yml"; } + //new in v1.0.8 if( !isset($datum["flags"]["nofalldamage"]) ){ $flags["nofalldamage"] = false; $newchange['NoFallDamage'] = "! Area NoFallDamage flag missing, now updated to 'false'; please see /resources/config.yml"; @@ -230,6 +231,7 @@ public function onEnable() : void{ if(!isset($c["Default"]["Hunger"])) { $c["Default"]["Hunger"] = false; } + // new in v1.0.8 if(!isset($c["Default"]["NoFallDamage"])) { $c["Default"]["NoFallDamage"] = false; } @@ -252,6 +254,7 @@ public function onEnable() : void{ // new in v1.0.7 $this->tnt = $c["Default"]["TNT"]; $this->tnt = $c["Default"]["Hunger"]; + // new in v1.0.8 $this->nofalldamage = $c["Default"]["NoFallDamage"]; // world default flag settings @@ -293,6 +296,7 @@ public function onEnable() : void{ if( !isset($flags["Hunger"]) ){ $flags["Hunger"] = $this->hunger; } + // new in v1.0.8 if( !isset($flags["NoFallDamage"]) ){ $flags["NoFallDamage"] = $this->nofalldamage; } From aeb435a4d97c05506918c8216bfabc69cedec39c Mon Sep 17 00:00:00 2001 From: iZeaoGamer Date: Wed, 15 Aug 2018 18:08:47 +0100 Subject: [PATCH 06/68] version bump. --- plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.yml b/plugin.yml index d379490..6cab740 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: Festival author: Genboy -version: 1.0.7.1-dev +version: 1.0.8 main: genboy\Festival\Main load: POSTWORLD api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0] From 2005202a6215ddcb0b50b2004623bf68d49f2dc4 Mon Sep 17 00:00:00 2001 From: genboy Date: Wed, 15 Aug 2018 22:50:38 +0200 Subject: [PATCH 07/68] NoFallDamage flag test and hunger flag fix --- plugin.yml | 2 +- src/genboy/Festival/Main.php | 157 +++++++++++++++-------------------- 2 files changed, 66 insertions(+), 93 deletions(-) diff --git a/plugin.yml b/plugin.yml index 6cab740..e96fb1c 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: Festival author: Genboy -version: 1.0.8 +version: 1.0.7.2-dev main: genboy\Festival\Main load: POSTWORLD api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0] diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 4276ec0..e9b02e6 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1,6 +1,9 @@ getDataFolder())){ mkdir($this->getDataFolder()); } - if(!file_exists($this->getDataFolder() . "areas.json")){ file_put_contents($this->getDataFolder() . "areas.json", "[]"); } - if(!file_exists($this->getDataFolder() . "config.yml")){ $c = $this->getResource("config.yml"); $o = stream_get_contents($c); @@ -112,14 +113,12 @@ public function onEnable() : void{ foreach($data as $datum){ - $flags = $datum["flags"]; if( isset($datum["flags"]["barrier"]) ){ $flags["passage"] = $datum["flags"]["barrier"]; unset($flags["barrier"]); $newchange['Passage'] = "! Old Barrier config was used, now set to 'false'; please rename 'Barrier' to 'Passage' in config.yml"; } - if( !isset($datum["flags"]["perms"]) ){ $flags["perms"] = false; $newchange['Perms'] = "! Area Perms flag missing, now updated to 'false'; please see /resources/config.yml"; @@ -128,31 +127,27 @@ public function onEnable() : void{ $flags["drop"] = false; $newchange['Drop'] = "! Area Drop flag missing, now updated to 'false'; please see /resources/config.yml"; } - //new flags v 1.0.5-12 - if( !isset($datum["flags"]["effects"]) ){ + if( !isset($datum["flags"]["effects"]) ){ // new flags v 1.0.5-12 $flags["effects"] = false; $newchange['Effects'] = "! Area Effects flag missing, now updated to 'false'; please see /resources/config.yml"; } - //new flags v 1.0.6-13 - if( !isset($datum["flags"]["pvp"]) ){ + if( !isset($datum["flags"]["pvp"]) ){ //new flags v 1.0.6-13 $flags["pvp"] = false; $newchange['PVP'] = "! Area PVP flag missing, now updated to 'false'; please see /resources/config.yml"; } - if( !isset($datum["flags"]["flight"]) ){ + if( !isset($datum["flags"]["flight"]) ){ //new flags v 1.0.6-13 $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"]) ){ + if( !isset($datum["flags"]["tnt"]) ){ // new flags v 1.0.7 $flags["tnt"] = false; $newchange['TNT'] = "! Area TNT flag missing, now updated to 'false'; please see /resources/config.yml"; } - if( !isset($datum["flags"]["hunger"]) ){ + if( !isset($datum["flags"]["hunger"]) ){ // new flags v 1.0.7 $flags["hunger"] = false; $newchange['Hunger'] = "! Area Hunger flag missing, now updated to 'false'; please see /resources/config.yml"; } - //new in v1.0.8 - if( !isset($datum["flags"]["nofalldamage"]) ){ + if( !isset($datum["flags"]["nofalldamage"]) ){ / /new in v1.0.8 $flags["nofalldamage"] = false; $newchange['NoFallDamage'] = "! Area NoFallDamage flag missing, now updated to 'false'; please see /resources/config.yml"; } @@ -161,7 +156,7 @@ public function onEnable() : void{ $c = yaml_parse_file($this->getDataFolder() . "config.yml"); - /* Config updating Code */ + // Config updating Code if( isset( $c["Options"] ) && is_array( $c["Options"] ) ){ if(!isset($c["Options"]["Msgtype"])){ @@ -171,13 +166,11 @@ public function onEnable() : void{ if(!isset($c["Options"]["Msgdisplay"])){ $c["Options"]["Msgdisplay"] = 'off'; $newchange['Msgdisplay'] = "! Msgdisplay option missing in config.yml, now set to 'off'; please see /resources/config.yml"; - } //.. 1.0.3-11+ options check - - // check since v1.0.5-12 - if(!isset($c["Options"]["AutoWhitelist"])){ + } + if(!isset($c["Options"]["AutoWhitelist"])){ // check since v1.0.5-12 $c["Options"]["AutoWhitelist"] = 'on'; $newchange['AutoWhitelist'] = "! AutoWhitelist option missing in config.yml, now set to 'on'; please see /resources/config.yml"; - } //.. new options check + } $this->options = $c["Options"]; @@ -186,9 +179,7 @@ public function onEnable() : void{ $newchange['Options'] = "! Config Options missing in config.yml, defautls are set for now; please see /resources/config.yml"; } - /** - * config default check and overwrite plugin defaults - */ + // config default check and overwrite plugin defaults if(!isset($c["Default"]["God"])) { $c["Default"]["God"] = false; } @@ -206,113 +197,92 @@ public function onEnable() : void{ }else if(!isset($c["Default"]["Passage"])) { $c["Default"]["Passage"] = false; } - // new in v1.0.4-11 - if(!isset($c["Default"]["Perms"])) { + if(!isset($c["Default"]["Perms"])) { // new in v1.0.4-11 $c["Default"]["Perms"] = false; } - if(!isset($c["Default"]["Drop"])) { + if(!isset($c["Default"]["Drop"])) { // new in v1.0.4-11 $c["Default"]["Drop"] = false; } - // new in v1.0.5-12 - if(!isset($c["Default"]["Effects"])) { + if(!isset($c["Default"]["Effects"])) { // new in v1.0.5-12 $c["Default"]["Effects"] = false; } - // new in v1.0.6-13 - if(!isset($c["Default"]["PVP"])) { + if(!isset($c["Default"]["PVP"])) { // new in v1.0.6-13 $c["Default"]["PVP"] = false; } if(!isset($c["Default"]["Flight"])) { $c["Default"]["Flight"] = false; } - // new in v1.0.7 - if(!isset($c["Default"]["TNT"])) { + if(!isset($c["Default"]["TNT"])) { // new in v1.0.7 $c["Default"]["TNT"] = false; } - if(!isset($c["Default"]["Hunger"])) { + if(!isset($c["Default"]["Hunger"])) { // new in v1.0.7 $c["Default"]["Hunger"] = false; } - // new in v1.0.8 if(!isset($c["Default"]["NoFallDamage"])) { - $c["Default"]["NoFallDamage"] = false; - } - - $this->god = $c["Default"]["God"]; - $this->edit = $c["Default"]["Edit"]; - $this->touch = $c["Default"]["Touch"]; - $this->msg = $c["Default"]["Msg"]; - // changed in v1.0.3-11 - $this->passage = $c["Default"]["Passage"]; - // new in v1.0.4-11 - $this->perms = $c["Default"]["Perms"]; - $this->drop = $c["Default"]["Drop"]; - // new in v1.0.5-12 - $this->effects = $c["Default"]["Effects"]; - $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"]; - // new in v1.0.8 - $this->nofalldamage = $c["Default"]["NoFallDamage"]; + $c["Default"]["NoFallDamage"] = false; // new in v1.0.8 + } + + $this->god = $c["Default"]["God"]; + $this->edit = $c["Default"]["Edit"]; + $this->touch = $c["Default"]["Touch"]; + $this->msg = $c["Default"]["Msg"]; + $this->passage = $c["Default"]["Passage"]; // changed in v1.0.3-11 + $this->perms = $c["Default"]["Perms"]; // new in v1.0.4-11 + $this->drop = $c["Default"]["Drop"]; // new in v1.0.4-11 + $this->effects = $c["Default"]["Effects"]; // new in v1.0.5-12 + $this->pvp = $c["Default"]["PVP"]; // new in v1.0.6-13 + $this->flight = $c["Default"]["Flight"]; // new in v1.0.6-13 + $this->tnt = $c["Default"]["TNT"]; // new in v1.0.7 + $this->hunger = $c["Default"]["Hunger"]; // new in v1.0.7 + $this->nofalldamage = $c["Default"]["NoFallDamage"]; // new in 1.0.7.2-dev(1.0.8) + + $this->flagset = $c['Default']; // new in v1.0.5-12 // world default flag settings if(is_array( $c["Worlds"] )){ foreach($c["Worlds"] as $level => $flags){ - - // check since v1.0.3-11 - if( isset($flags["Barrier"]) ){ + if( isset($flags["Barrier"]) ){ // check since v1.0.3-11 $flags["Passage"] = $flags["Barrier"]; unset($flags["Barrier"]); } if( !isset($flags["Passage"]) ){ $flags["Passage"] = $this->passage; } - - // new v1.0.4-11 - if( !isset($flags["Perms"]) ){ + if( !isset($flags["Perms"]) ){ // new v1.0.4-11 $flags["Perms"] = $this->perms; } - if( !isset($flags["Drop"]) ){ + if( !isset($flags["Drop"]) ){ // new v1.0.4-11 $flags["Drop"] = $this->drop; } - // new v1.0.5-12 - if( !isset($flags["Effects"]) ){ + if( !isset($flags["Effects"]) ){ // new v1.0.5-12 $flags["Effects"] = $this->effects; } - - // new v1.0.6-13 - if( !isset($flags["PVP"]) ){ + if( !isset($flags["PVP"]) ){ // new v1.0.6-13 $flags["PVP"] = $this->pvp; } - if( !isset($flags["Flight"]) ){ + if( !isset($flags["Flight"]) ){ // new v1.0.6-13 $flags["Flight"] = $this->flight; } - // new v1.0.7 - if( !isset($flags["TNT"]) ){ + if( !isset($flags["TNT"]) ){ // new v1.0.7 $flags["TNT"] = $this->tnt; } - if( !isset($flags["Hunger"]) ){ + if( !isset($flags["Hunger"]) ){ // new v1.0.7 $flags["Hunger"] = $this->hunger; } - // new in v1.0.8 - if( !isset($flags["NoFallDamage"]) ){ + if( !isset($flags["NoFallDamage"]) ){ // new in v1.0.8 $flags["NoFallDamage"] = $this->nofalldamage; } $this->levels[$level] = $flags; } } - // all save :) - $this->saveAreas(); - + $this->saveAreas(); // all save :) /** console output */ - // codesign - $this->codeSigned(); - // plugin area info - $ca = 0; + $this->codeSigned(); // codesign + + $ca = 0; // plugin area info + foreach( $this->areas as $a ){ $ca = $ca + count( $a->getCommands() ); } @@ -344,7 +314,7 @@ public function isFlag( $str ){ "msg","message", "passage","pass","barrier", "perms","perm", - "nofalldamage" + "nofalldamage","falldamage","nfd" ]; $str = strtolower( $str ); $flag = false; @@ -383,7 +353,7 @@ public function isFlag( $str ){ if( $str == "hunger" || $str == "starve" ){ $flag = "hunger"; } - if( $str == "nofalldamage" ){ + if( $str == "nofalldamage" || $str == "falldamage" || $str == "nfd"){ $flag = "nofalldamage"; } } @@ -657,6 +627,8 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "explode": case "drop": case "nofalldamage"; + case "falldamage"; + case "nfd"; if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.flag")){ if(isset($args[1])){ @@ -747,10 +719,11 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } $o = TextFormat::GREEN . "Flag " . $flag . " set to " . $status . " for area " . $area->getName() . "!"; }else{ - $o = TextFormat::RED . "Flag not found. (Flags: edit, god, pvp, flight, touch, effects, msg, passage, perms, drop, nofalldamage)"; + $o = TextFormat::RED . "Flag not found. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, hunger, perms, nofalldamage)"; } + }else{ - $o = TextFormat::RED . "Please specify a flag. (Flags: edit, god, pvp, flight, touch, effects, msg, passage, perms, drop, nofalldamage)"; + $o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, hunger, perms, nofalldamage)"; } } }else{ @@ -1921,7 +1894,7 @@ public function areaEventSound( $player ){ /** Todo: * 1. add sounds * 2. sound flag, config & command - * 3. add config different sounds & specification + * 3. add config different sounds & specification */ } From 5d860cbe4870ca7d68dd90c8f3f4a5211da92850 Mon Sep 17 00:00:00 2001 From: genboy Date: Thu, 16 Aug 2018 03:09:12 +0200 Subject: [PATCH 08/68] No Fall Damage flag implement (thank you iZeaoGamer) & flight msg op --- src/genboy/Festival/Main.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index e9b02e6..e886c6e 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -147,7 +147,7 @@ public function onEnable() : void{ $flags["hunger"] = false; $newchange['Hunger'] = "! Area Hunger flag missing, now updated to 'false'; please see /resources/config.yml"; } - if( !isset($datum["flags"]["nofalldamage"]) ){ / /new in v1.0.8 + if( !isset($datum["flags"]["nofalldamage"]) ){ //new in v1.0.8 $flags["nofalldamage"] = false; $newchange['NoFallDamage'] = "! Area NoFallDamage flag missing, now updated to 'false'; please see /resources/config.yml"; } @@ -424,7 +424,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar new Area( strtolower($args[1]), "", - ["edit" => $flags['Edit'], "god" => $flags['God'], "pvp" => $flags["PVP"], "flight"=> $flags["Flight"], "touch" => $flags['Touch'], "effects" => $flags['Effects'], "drop" => $flags['Drop'], "msg" => $flags['Msg'], "passage" => $flags['Passage'], "perms" => $flags['Perms']], + ["edit" => $flags['Edit'], "god" => $flags['God'], "pvp" => $flags["PVP"], "flight"=> $flags["Flight"], "touch" => $flags['Touch'], "effects" => $flags['Effects'], "drop" => $flags['Drop'], "msg" => $flags['Msg'], "passage" => $flags['Passage'], "perms" => $flags['Perms'], "nofalldamage" => $flags['NoFallDamage']], $this->firstPosition[$playerName], $this->secondPosition[$playerName], $sender->getLevel()->getName(), @@ -1475,13 +1475,14 @@ public function canUseEffects( Player $player ) : bool{ public function checkPlayerFlying(Player $player){ $fly = true; + $sendmsg = false; + $nofalldamage = false; $position = $player->getPosition(); + $f = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Flight"] : $this->flight); if( $f ){ $fly = false; // flag default } - - $sendmsg = false; foreach($this->areas as $area){ if( $area->contains( $player->getPosition(), $player->getLevel()->getName() ) ){ if( $area->getFlag("flight") && !$area->isWhitelisted( strtolower($player->getName())) ){ @@ -1489,20 +1490,23 @@ public function checkPlayerFlying(Player $player){ }else{ $fly = true; } - if( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ){ + if( !$area->getFlag("msg") ){ $sendmsg = true; - }else{ - $sendmsg = false; + } + if( $area->getFlag("nofalldamage") ){ + $nofalldamage = true; } } } if( $player->isOp() ){ - $fly = true; // ops can fly + $fly = true; // ops can fly || + $sendmsg = $this->msgOpDsp( $area, $player ); } - $msg = ''; if( !$fly && $player->isFlying() ){ + if( $nofalldamage ){ $this->playerTP[ strtolower( $player->getName() ) ] = true; // player tp active (fall save) + } $player->setFlying(false); //$player->sendMessage( TextFormat::RED . "NO Flying here!" ); if( $sendmsg ){ @@ -1517,7 +1521,6 @@ public function checkPlayerFlying(Player $player){ } } $player->setAllowFlight($fly); - return $fly; } From d418de654b944264aa9099fec797ff5a9bcde5f1 Mon Sep 17 00:00:00 2001 From: genboy Date: Thu, 16 Aug 2018 03:19:49 +0200 Subject: [PATCH 09/68] Function namechange and TP adjustment --- src/genboy/Festival/Main.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index e886c6e..2fd87e5 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -589,10 +589,12 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $cz = $area->getSecondPosition()->getZ() + ( ( $area->getFirstPosition()->getZ() - $area->getSecondPosition()->getZ() ) / 2 ); $cy1 = min( $area->getSecondPosition()->getY(), $area->getFirstPosition()->getY()); $cy2 = max( $area->getSecondPosition()->getY(), $area->getFirstPosition()->getY()); - $this->playerTP[$playerName] = true; // player tp active - //$this->areaMessage( 'Fall save on!', $sender ); + if( $this->hasNoFallDamage($sender) ){ + $this->playerTP[$playerName] = true; // player tp active + //$this->areaMessage( 'Fall save on!', $sender ); + } + $sender->teleport( new Position( $cx, $cy2 - 2, $cz, $area->getLevel() ) ); //$sender->sendMessage( $playerName ); - $sender->teleport( new Position( $cx, $cy2+ 0.5, $cz, $area->getLevel() ) ); }else{ $o = TextFormat::RED . "The level " . $levelName . " for Area ". $args[1] ." cannot be found"; @@ -1122,7 +1124,7 @@ public function onHurt(EntityDamageEvent $event) : void{ * * @return bool */ - public function nfdamage(Entity $entity) : bool{ + public function hasNoFallDamage(Entity $entity) : bool{ $o = true; $default = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["NoFallDamage"] : $this->nofalldamage); if($default){ @@ -1983,7 +1985,7 @@ public function onFallDisable(EntityDamageEvent $event) : void{ $event->setCancelled(); } - if($cause == EntityDamageEvent::CAUSE_FALL && !$this->nfdamage($player)){ + if($cause == EntityDamageEvent::CAUSE_FALL && !$this->hasNoFallDamage($player)){ $event->setCancelled(true); } } From f93556c9e97e925eb12793c0067d9c7741e77e16 Mon Sep 17 00:00:00 2001 From: genboy Date: Thu, 16 Aug 2018 23:45:17 +0200 Subject: [PATCH 10/68] Shoot flag implement & testing message inside method for area flag --- resources/config.yml | 11 ++- src/genboy/Festival/Main.php | 127 +++++++++++++++++++++++++++++++---- 2 files changed, 125 insertions(+), 13 deletions(-) diff --git a/resources/config.yml b/resources/config.yml index a92858a..5aa26ae 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -45,6 +45,9 @@ Default: # No explosions allowed in the area? TNT: false + # No shooting allowed in the area? + Shoot: false + # Keep players from hunger(exhaust) in the area? Hunger: false @@ -89,6 +92,9 @@ Worlds: # No explosions allowed in the area? TNT: false + # No shooting allowed in the area? + Shoot: false + # Keep players from hunger(exhaust) in the area? Hunger: false @@ -97,7 +103,7 @@ Worlds: # Keep players from taking fall damage NoFallDamage: false - + world: # Keep players from getting hurt? @@ -130,6 +136,9 @@ Worlds: # No explosions allowed in the area? TNT: false + # No shooting allowed in the area? + Shoot: false + # Keep players from hunger(exhaust) in the area? Hunger: false diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 2fd87e5..671517e 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -15,6 +15,7 @@ use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\event\entity\EntityExplodeEvent; +use pocketmine\event\entity\EntityShootBowEvent; use pocketmine\event\Listener; use pocketmine\level\Position; use pocketmine\math\Vector3; @@ -61,6 +62,8 @@ class Main extends PluginBase implements Listener{ /** @var bool */ private $tnt = false; /** @var bool */ + private $shoot = false; + /** @var bool */ private $hunger = false; /** @var bool */ private $perms = false; @@ -119,6 +122,10 @@ public function onEnable() : void{ unset($flags["barrier"]); $newchange['Passage'] = "! Old Barrier config was used, now set to 'false'; please rename 'Barrier' to 'Passage' in config.yml"; } + if( !isset($datum["flags"]["shoot"]) ){ + $flags["shoot"] = false; + $newchange['Shoot'] = "! Area Shoot flag missing (alias launch), now updated to 'false'; please see /resources/config.yml"; + } if( !isset($datum["flags"]["perms"]) ){ $flags["perms"] = false; $newchange['Perms'] = "! Area Perms flag missing, now updated to 'false'; please see /resources/config.yml"; @@ -215,6 +222,9 @@ public function onEnable() : void{ if(!isset($c["Default"]["TNT"])) { // new in v1.0.7 $c["Default"]["TNT"] = false; } + if(!isset($c["Default"]["Shoot"])) { // new in v1.0.7 + $c["Default"]["Shoot"] = false; + } if(!isset($c["Default"]["Hunger"])) { // new in v1.0.7 $c["Default"]["Hunger"] = false; } @@ -235,6 +245,7 @@ public function onEnable() : void{ $this->tnt = $c["Default"]["TNT"]; // new in v1.0.7 $this->hunger = $c["Default"]["Hunger"]; // new in v1.0.7 $this->nofalldamage = $c["Default"]["NoFallDamage"]; // new in 1.0.7.2-dev(1.0.8) + $this->shoot = $c["Default"]["Shoot"]; // new in 1.0.7.2-dev(1.0.8) $this->flagset = $c['Default']; // new in v1.0.5-12 @@ -266,6 +277,9 @@ public function onEnable() : void{ if( !isset($flags["TNT"]) ){ // new v1.0.7 $flags["TNT"] = $this->tnt; } + if( !isset($flags["Shoot"]) ){ // new v1.0.7 + $flags["Shoot"] = $this->shoot; + } if( !isset($flags["Hunger"]) ){ // new v1.0.7 $flags["Hunger"] = $this->hunger; } @@ -314,7 +328,8 @@ public function isFlag( $str ){ "msg","message", "passage","pass","barrier", "perms","perm", - "nofalldamage","falldamage","nfd" + "nofalldamage","falldamage","nfd", + "shoot", "launch", ]; $str = strtolower( $str ); $flag = false; @@ -347,6 +362,9 @@ public function isFlag( $str ){ if( $str == "tnt" || $str == "explode" ){ $flag = "tnt"; } + if( $str == "shoot" || $str == "launch" ){ + $flag = "shoot"; + } if( $str == "effect" || $str == "effects" ){ $flag = "effects"; } @@ -424,7 +442,21 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar new Area( strtolower($args[1]), "", - ["edit" => $flags['Edit'], "god" => $flags['God'], "pvp" => $flags["PVP"], "flight"=> $flags["Flight"], "touch" => $flags['Touch'], "effects" => $flags['Effects'], "drop" => $flags['Drop'], "msg" => $flags['Msg'], "passage" => $flags['Passage'], "perms" => $flags['Perms'], "nofalldamage" => $flags['NoFallDamage']], + [ "edit" => $flags['Edit'], + "god" => $flags['God'], + "pvp" => $flags["PVP"], + "flight"=> $flags["Flight"], + "touch" => $flags['Touch'], + "effects" => $flags['Effects'], + "msg" => $flags['Msg'], + "passage" => $flags['Passage'], + "drop" => $flags['Drop'], + "tnt" => $flags['TNT'], + "shoot" => $flags['Shoot'], + "hunger" => $flags['Hunger'], + "perms" => $flags['Perms'], + "nofalldamage" => $flags['NoFallDamage']], + $this->firstPosition[$playerName], $this->secondPosition[$playerName], $sender->getLevel()->getName(), @@ -627,10 +659,13 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "starve": case "tnt": case "explode": + case "shoot"; + case "launch"; case "drop": case "nofalldamage"; case "falldamage"; case "nfd"; + if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.flag")){ if(isset($args[1])){ @@ -721,11 +756,11 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } $o = TextFormat::GREEN . "Flag " . $flag . " set to " . $status . " for area " . $area->getName() . "!"; }else{ - $o = TextFormat::RED . "Flag not found. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, hunger, perms, nofalldamage)"; + $o = TextFormat::RED . "Flag not found. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, shoot, hunger, perms, nofalldamage)"; } }else{ - $o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, hunger, perms, nofalldamage)"; + $o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, shoot, hunger, perms, nofalldamage)"; } } }else{ @@ -1108,13 +1143,6 @@ public function canDamage(EntityDamageEvent $ev) : bool{ } - /** On hurt - * @param EntityDamageEvent $event - * @ignoreCancelled true - */ - public function onHurt(EntityDamageEvent $event) : void{ - $this->canDamage( $event ); - } /** On No fall Damage * @param EntityDamageEvent $event * @ignoreCancelled true @@ -1143,6 +1171,16 @@ public function hasNoFallDamage(Entity $entity) : bool{ } return $o; } + + + /** On hurt + * @param EntityDamageEvent $event + * @ignoreCancelled true + */ + public function onHurt(EntityDamageEvent $event) : void{ + $this->canDamage( $event ); + } + /** On Damage * @param EntityDamageEvent $event * @ignoreCancelled true @@ -1355,6 +1393,70 @@ public function canDrop(Player $player, Position $position) : bool{ } + /** Shoot / Launch projectiles + * @param EntityShootBowEvent $event + * @ignoreCancelled true + */ + public function onEntityShootBow( EntityShootBowEvent $event ){ + + $e = $event->getEntity(); + if( $e instanceof Player){ + if( !$this->canShoot($e) ){ + $event->setCancelled(); + } + } + + } + + + /** onShoot + * @param Player $player + * @return bool + */ + public function canShoot( Player $player ) : bool{ + + if( $player->isOp() || $player->hasPermission("festival") || $player->hasPermission("festival.access")){ + return true; + } + + $position = $player->getPosition(); + $o = true; + $m = true; + $g = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Shoot"] : $this->shoot); + if($g){ + $o = false; + } + foreach($this->areas as $area){ + if($area->contains($position, $position->getLevel()->getName())){ + if($area->getFlag("shoot")){ + $o = false; + } + if($area->isWhitelisted(strtolower($player->getName()))){ + $o = true; + break; + } + if(!$area->getFlag("shoot") && $g){ + $o = true; + break; + } + if( $area->getFlag("msg") ){ + $m = false; + } + } + + } + + // new message method + if( $m && !$o ){ + $msg = TextFormat::RED . "NO Shooting here!"; + $player->sendMessage( $msg ); + } + + return $o; + + } + + /** Block Place * @param BlockPlaceEvent $event * @ignoreCancelled true @@ -1534,6 +1636,7 @@ public function checkPlayerFlying(Player $player){ * @return true */ public function onMove(PlayerMoveEvent $ev) : void{ + $player = $ev->getPlayer(); $playerName = strtolower( $player->getName() ); @@ -1955,7 +2058,7 @@ public function areaInfoList( $area ){ }else{ $l .= TextFormat::RED . "off"; } - } + } // Area Commands by event if( $cmds = $area->getCommands() && count( $area->getCommands() ) > 0 ){ From defa37370ab40f90e1f1ccd6b60ababf3335ec24 Mon Sep 17 00:00:00 2001 From: genboy Date: Fri, 17 Aug 2018 20:15:32 +0200 Subject: [PATCH 11/68] update flag info --- README.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a7c0236..e29ee8d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ 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) @@ -11,7 +10,7 @@ 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/08/festival_usage_1.0.7-1.png) +![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/08/festival_usage_1.0.7-2-dev.png) ###### Copyright [Genboy](https://genboy.net) 2018 @@ -19,7 +18,7 @@ Create a festival with this custom area events plugin for Pocketmine Server: --- ## Info - + # Festival [![](https://poggit.pmmp.io/shield.state/Festival)](https://poggit.pmmp.io/p/Festival) @@ -58,8 +57,10 @@ Create a festival with this custom area events plugin for Pocketmine Server: - passage: no passage for non-whitelisted players! (previously barrier flag) - drop: players can not drop things - tnt: explosions protected area - - hunger: player does not exhaust / hunger + - shoot: player can not shoot (bow) - perms: player permissions are used to determine area command execution (experiment) + - hunger: player does not exhaust / hunger + - nfd: player will not have fall damage (no fall damage) **Events & Commands** @@ -137,14 +138,17 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). - new TNT flag - new Hunger flag - Fire is now extinguished when player does not get damage (aka. in area with god flag on) + - new shoot flag (experimental no shooting/launching) + - new nofalldamage flag (nfd) + #### 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) + ![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/08/festival_usage_1.0.7.2-dev.png) ###### Copyright [Genboy](https://genboy.net) 2018 @@ -176,13 +180,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 @@ -281,7 +285,7 @@ If you like to help improve this plugin; - look at the code and give feedback - both by submitting [issues @ github](https://github.com/genboy/Festival/issues) and/or [reviews @ poggit](https://poggit.pmmp.io/p/Festival) -or send an email to msg @ genboy.net +or send an email to msg @ genboy.net Thank you @@ -316,6 +320,8 @@ Thank you - [x] TNT flag: explosion free area's - [x] Hunger flag: players do not exhaust - [x] Fire (animation) extinguished when player is save + - [x] No shooting (bow) + - [x] No Fall Damage flag (was implemented as effect for TP dropping and flight break) ------ From 8a95cf26493ffd90f04cd4d4f7b8c4f5bb5af2e2 Mon Sep 17 00:00:00 2001 From: genboy Date: Fri, 17 Aug 2018 20:31:38 +0200 Subject: [PATCH 12/68] info text --- README.md | 4 ++-- src/genboy/Festival/Main.php | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e29ee8d..0120209 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ Create a festival with this custom area events plugin for Pocketmine Server: --- -## Info - +## Info + # Festival [![](https://poggit.pmmp.io/shield.state/Festival)](https://poggit.pmmp.io/p/Festival) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 671517e..a6edac1 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1,7 +1,7 @@ hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.flag")){ From 0625d829f05e537667f850b3a36c2d6722aea8f6 Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 18 Aug 2018 17:49:01 +0200 Subject: [PATCH 13/68] Test loop only player related area's ( inArea, areaList) for player events --- src/genboy/Festival/Main.php | 244 ++++++++++++++++++++++++++++++++--- 1 file changed, 225 insertions(+), 19 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index a6edac1..894a1ec 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -80,13 +80,16 @@ class Main extends PluginBase implements Listener{ /** @var Vector3[] */ private $secondPosition = []; - /** @var string[] */ + /** @var array[] */ private $inArea = []; + /** @var array[] */ + private $areaList = []; + /** @var array[] */ private $skipsec = []; - /** @var string[] */ + /** @var array[] */ public $playerTP = []; /** Enable @@ -290,7 +293,7 @@ public function onEnable() : void{ } } - $this->saveAreas(); // all save :) + $this->saveAreas(); // all save $this->areaList available :) /** console output */ $this->codeSigned(); // codesign @@ -1049,10 +1052,28 @@ public function onQuit(PlayerQuitEvent $event){ */ public function canGetHurt(Entity $entity) : bool{ $o = true; - $default = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["God"] : $this->god); - if($default){ - $o = false; - } + + if( $entity instanceof Player){ + $default = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["God"] : $this->god); + if($default){ + $o = false; + } + $playername = strtolower($entity->getName()); + + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[ $areaname ]; + if($default && !$area->getFlag("god")){ + $o = true; + break; + } + if($area->getFlag("god")){ + $o = false; + } + } + } + } + /* inarea replace foreach($this->areas as $area){ if($area->contains(new Vector3($entity->getX(), $entity->getY(), $entity->getZ()), $entity->getLevel()->getName())){ @@ -1067,7 +1088,7 @@ public function canGetHurt(Entity $entity) : bool{ } - } + }*/ return $o; } @@ -1086,6 +1107,22 @@ public function canPVP(EntityDamageEvent $ev) : bool{ if($default){ $o = false; } + $playername = $entity->getName(); + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + $god = $area->getFlag("god"); + if($default && !$area->getFlag("pvp")){ + $o = true; + break; + } + if($area->getFlag("pvp")){ + $o = false; + break; + } + } + } + /* foreach($this->areas as $area){ if($area->contains(new Vector3($entity->getX(), $entity->getY(), $entity->getZ()), $entity->getLevel()->getName())){ $god = $area->getFlag("god"); @@ -1099,6 +1136,7 @@ public function canPVP(EntityDamageEvent $ev) : bool{ } } } + */ } } if( !$o ){ @@ -1154,11 +1192,31 @@ public function canDamage(EntityDamageEvent $ev) : bool{ * @return bool */ public function hasNoFallDamage(Entity $entity) : bool{ + $o = true; - $default = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["NoFallDamage"] : $this->nofalldamage); - if($default){ - $o = false; - } + if( $entity instanceof Player ){ + + $default = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["NoFallDamage"] : $this->nofalldamage); + if($default){ + $o = false; + } + + $playername = strtolower($entity->getName()); + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + if($default && !$area->getFlag("nofalldamage")){ + $o = true; + break; + } + if($area->getFlag("nofalldamage")){ + $o = false; + } + } + } + + } + /* foreach($this->areas as $area){ if($area->contains(new Vector3($entity->getX(), $entity->getY(), $entity->getZ()), $entity->getLevel()->getName())){ if($default && !$area->getFlag("nofalldamage")){ @@ -1170,6 +1228,7 @@ public function hasNoFallDamage(Entity $entity) : bool{ } } } + */ return $o; } @@ -1204,6 +1263,25 @@ public function canEdit(Player $player, Position $position) : bool{ if($g){ $o = false; } + + $playername = strtolower($player->getName()); + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + if($area->getFlag("edit")){ + $o = false; + } + if($area->isWhitelisted(strtolower($player->getName()))){ + $o = true; + break; + } + if(!$area->getFlag("edit") && $g){ + $o = true; + break; + } + } + } + /* foreach($this->areas as $area){ if($area->contains($position, $position->getLevel()->getName())){ if($area->getFlag("edit")){ @@ -1219,6 +1297,7 @@ public function canEdit(Player $player, Position $position) : bool{ } } } + */ return $o; } @@ -1231,11 +1310,29 @@ public function canTouch(Player $player, Position $position) : bool{ if($player->hasPermission("festival") || $player->hasPermission("festival.access")){ return true; } + $playername = strtolower($player->getName()); $o = true; $default = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Touch"] : $this->touch); if($default){ $o = false; } + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + if($area->getFlag("touch")){ + $o = false; + } + if($area->isWhitelisted(strtolower($player->getName()))){ + $o = true; + break; + } + if(!$area->getFlag("touch") && $default){ + $o = true; + break; + } + } + } + /* foreach($this->areas as $area){ if($area->contains(new Vector3($position->getX(), $position->getY(), $position->getZ()), $position->getLevel()->getName())){ if($area->getFlag("touch")){ @@ -1251,6 +1348,7 @@ public function canTouch(Player $player, Position $position) : bool{ } } } + */ return $o; } @@ -1273,7 +1371,7 @@ public function onBlockTouch(PlayerInteractEvent $event) : void{ */ public function Hunger(PlayerExhaustEvent $event){ - if ( !$this->canHunger( $event->getPlayer()->getPosition() ) ) { + if ( !$this->canHunger( $event ) ) { $event->setCancelled(); } } @@ -1285,12 +1383,28 @@ public function Hunger(PlayerExhaustEvent $event){ * @param pocketmine\level\Level $level * @return bool */ - public function canHunger( Position $pos ): bool{ + public function canHunger( PlayerExhaustEvent $event ): bool{ + $pos = $event->getPlayer()->getPosition(); + $playername = strtolower($event->getPlayer()->getName()); $o = true; $g = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Hunger"] : $this->hunger); if ($g) { $o = false; } + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + if ($area->getFlag("hunger")) { + $o = false; + break; + } + if ($area->getFlag("hunger") && $g) { + $o = true; + break; + } + } + } + /* foreach ($this->areas as $area) { if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { if ($area->getFlag("hunger")) { @@ -1303,6 +1417,7 @@ public function canHunger( Position $pos ): bool{ } } } + */ return $o; } @@ -1331,6 +1446,7 @@ public function canExplode( Position $pos ): bool{ if ($g) { $o = false; } + // including entities/mobs in any area foreach ($this->areas as $area) { if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { if ($area->getFlag("tnt")) { @@ -1343,6 +1459,7 @@ public function canExplode( Position $pos ): bool{ } } } + return $o; } @@ -1375,6 +1492,24 @@ public function canDrop(Player $player, Position $position) : bool{ if($g){ $o = false; } + $playername = strtolower($player->getName()); + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + if($area->getFlag("drop")){ + $o = false; + } + if($area->isWhitelisted(strtolower($player->getName()))){ + $o = true; + break; + } + if(!$area->getFlag("drop") && $g){ + $o = true; + break; + } + } + } + /* foreach($this->areas as $area){ if($area->contains($position, $position->getLevel()->getName())){ if($area->getFlag("drop")){ @@ -1390,6 +1525,7 @@ public function canDrop(Player $player, Position $position) : bool{ } } } + */ return $o; } @@ -1421,12 +1557,34 @@ public function canShoot( Player $player ) : bool{ } $position = $player->getPosition(); + $playername = strtolower($player->getName()); $o = true; $m = true; $g = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Shoot"] : $this->shoot); if($g){ $o = false; } + + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + if($area->getFlag("shoot")){ + $o = false; + } + if($area->isWhitelisted(strtolower($player->getName()))){ + $o = true; + break; + } + if(!$area->getFlag("shoot") && $g){ + $o = true; + break; + } + if( $area->getFlag("msg") ){ + $m = false; + } + } + } + /* foreach($this->areas as $area){ if($area->contains($position, $position->getLevel()->getName())){ if($area->getFlag("shoot")){ @@ -1446,6 +1604,7 @@ public function canShoot( Player $player ) : bool{ } } + */ // new message method if( $m && !$o ){ @@ -1549,11 +1708,30 @@ public function canUseEffects( Player $player ) : bool{ } $position = $player->getPosition(); + $playername = strtolower($player->getName()); $o = true; $g = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Effects"] : $this->effects); if($g){ $o = false; } + + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + if($area->getFlag("effects")){ + $o = false; + } + if($area->isWhitelisted(strtolower($player->getName()))){ + $o = true; + break; + } + if(!$area->getFlag("effects") && $g){ + $o = true; + break; + } + } + } + /* foreach($this->areas as $area){ if($area->contains($position, $position->getLevel()->getName())){ if($area->getFlag("effects")){ @@ -1569,6 +1747,7 @@ public function canUseEffects( Player $player ) : bool{ } } } + */ return $o; } @@ -1583,11 +1762,35 @@ public function checkPlayerFlying(Player $player){ $sendmsg = false; $nofalldamage = false; $position = $player->getPosition(); + $playername = strtolower($player->getName()); $f = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Flight"] : $this->flight); if( $f ){ $fly = false; // flag default } + + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + if( $area->getFlag("flight") && !$area->isWhitelisted( $playername ) ){ + $fly = false; // flag area + }else{ + $fly = true; + } + if( !$area->getFlag("msg") ){ + $sendmsg = true; + } + if( $area->getFlag("nofalldamage") ){ + $nofalldamage = true; + } + if( $player->isOp() ){ + $fly = true; // ops can fly || + $sendmsg = $this->msgOpDsp( $area, $player ); + } + } + } + + /* foreach($this->areas as $area){ if( $area->contains( $player->getPosition(), $player->getLevel()->getName() ) ){ if( $area->getFlag("flight") && !$area->isWhitelisted( strtolower($player->getName())) ){ @@ -1601,12 +1804,13 @@ public function checkPlayerFlying(Player $player){ if( $area->getFlag("nofalldamage") ){ $nofalldamage = true; } + if( $player->isOp() ){ + $fly = true; // ops can fly || + $sendmsg = $this->msgOpDsp( $area, $player ); + } } } - if( $player->isOp() ){ - $fly = true; // ops can fly || - $sendmsg = $this->msgOpDsp( $area, $player ); - } + */ $msg = ''; if( !$fly && $player->isFlying() ){ if( $nofalldamage ){ @@ -1702,7 +1906,7 @@ public function onMove(PlayerMoveEvent $ev) : void{ } - $this->checkPlayerFlying( $player ); + $this->checkPlayerFlying( $ev->getPlayer() ); return; } @@ -2103,6 +2307,8 @@ public function saveAreas() : void{ $areas = []; foreach($this->areas as $area){ $areas[] = ["name" => $area->getName(), "desc" => $area->getDesc(), "flags" => $area->getFlags(), "pos1" => [$area->getFirstPosition()->getFloorX(), $area->getFirstPosition()->getFloorY(), $area->getFirstPosition()->getFloorZ()] , "pos2" => [$area->getSecondPosition()->getFloorX(), $area->getSecondPosition()->getFloorY(), $area->getSecondPosition()->getFloorZ()], "level" => $area->getLevelName(), "whitelist" => $area->getWhitelist(), "commands" => $area->getCommands(), "events" => $area->getEvents()]; + + $this->areaList[strtolower( $area->getName() )] = $area; // name associated area list for inArea check } file_put_contents($this->getDataFolder() . "areas.json", json_encode($areas)); } From d72a8b9bb510c7dd932a8825380633309ae250df Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 18 Aug 2018 20:26:34 +0200 Subject: [PATCH 14/68] renamed function areaInfoDisplayList & more inArea --- src/genboy/Festival/Main.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 894a1ec..59b535c 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -550,7 +550,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar if( ( !empty($l) && $l == $lvl->getName() ) || $l == false ){ - $t .= $this->areaInfoList( $area ); + $t .= $this->areaInfoDisplayList( $area ); $i++; @@ -589,14 +589,24 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "here": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.here")){ $o = ""; + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + $o .= TextFormat::DARK_PURPLE ."---- Area here ----\n"; + $o .= $this->areaInfoDisplayList( $area ); + $o .= TextFormat::DARK_PURPLE ."----------------\n"; + } + } + /* foreach($this->areas as $area){ if($area->contains($sender->getPosition(), $sender->getLevel()->getName()) && $area->getWhitelist() !== null){ $o .= TextFormat::DARK_PURPLE ."---- Area here ----\n"; - $o .= $this->areaInfoList( $area ); + $o .= $this->areaInfoDisplayList( $area ); $o .= TextFormat::DARK_PURPLE ."----------------\n"; } - } + }*/ + if($o === "") { $o = TextFormat::RED . "You are in an unknown area"; } @@ -2230,7 +2240,7 @@ public function listAllAreas(){ /** List Area Info * @var obj area */ - public function areaInfoList( $area ){ + public function areaInfoDisplayList( $area ){ $l = TextFormat::GRAY . " area " . TextFormat::AQUA . $area->getName(); // Players in area From c038124aa0a67056feaaddcfb93612f1b7eb5231 Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 19 Aug 2018 11:49:30 +0200 Subject: [PATCH 15/68] Update full loop / no breaks reading rule order area's + code cleanup --- resources/config.yml | 10 +- src/genboy/Festival/Main.php | 607 ++++++++++------------------------- 2 files changed, 175 insertions(+), 442 deletions(-) diff --git a/resources/config.yml b/resources/config.yml index 5aa26ae..06035ed 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -54,8 +54,8 @@ Default: # Keep players from executing area event commands without specific perms Perms: false - # Keep players from taking fall damage - NoFallDamage: false + # Keep players from taking fall damage (default for teleport/flying drop) + NoFallDamage: true # Settings for unprotected areas in individual worlds: Worlds: @@ -63,7 +63,7 @@ Worlds: DEFAULT: # Keep players from getting hurt? - God: true + God: false # Keep players from getting hurt by other players? PVP: false @@ -102,7 +102,7 @@ Worlds: Perms: false # Keep players from taking fall damage - NoFallDamage: false + NoFallDamage: true world: @@ -146,4 +146,4 @@ Worlds: Perms: false # Keep players from taking fall damage - NoFallDamage: false + NoFallDamage: true diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 59b535c..2f5f57c 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1,9 +1,8 @@ getServer()->getPluginManager()->registerEvents($this, $this); - - $newchange = []; // check missing flags or options in config - if(!is_dir($this->getDataFolder())){ mkdir($this->getDataFolder()); } @@ -115,25 +117,20 @@ public function onEnable() : void{ $newchange['Config'] = 'Festival setup..'; } + // innitialize default flags & update data $data = json_decode(file_get_contents($this->getDataFolder() . "areas.json"), true); - - foreach($data as $datum){ $flags = $datum["flags"]; if( isset($datum["flags"]["barrier"]) ){ - $flags["passage"] = $datum["flags"]["barrier"]; + $flags["passage"] = $datum["flags"]["barrier"]; // replaced in v1.0.5-11 can use both unset($flags["barrier"]); $newchange['Passage'] = "! Old Barrier config was used, now set to 'false'; please rename 'Barrier' to 'Passage' in config.yml"; } - if( !isset($datum["flags"]["shoot"]) ){ - $flags["shoot"] = false; - $newchange['Shoot'] = "! Area Shoot flag missing (alias launch), now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["perms"]) ){ + if( !isset($datum["flags"]["perms"]) ){ // new flags v 1.0.5-12 $flags["perms"] = false; $newchange['Perms'] = "! Area Perms flag missing, now updated to 'false'; please see /resources/config.yml"; } - if( !isset($datum["flags"]["drop"]) ){ + if( !isset($datum["flags"]["drop"]) ){ // new flags v 1.0.5-12 $flags["drop"] = false; $newchange['Drop'] = "! Area Drop flag missing, now updated to 'false'; please see /resources/config.yml"; } @@ -157,16 +154,20 @@ public function onEnable() : void{ $flags["hunger"] = false; $newchange['Hunger'] = "! Area Hunger flag missing, now updated to 'false'; please see /resources/config.yml"; } - if( !isset($datum["flags"]["nofalldamage"]) ){ //new in v1.0.8 + if( !isset($datum["flags"]["nofalldamage"]) ){ //new in v1.0.7.2 $flags["nofalldamage"] = false; $newchange['NoFallDamage'] = "! Area NoFallDamage flag missing, now updated to 'false'; please see /resources/config.yml"; } + if( !isset($datum["flags"]["shoot"]) ){ //new in v1.0.7.2 + $flags["shoot"] = false; + $newchange['Shoot'] = "! Area Shoot flag missing (alias launch), 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); } $c = yaml_parse_file($this->getDataFolder() . "config.yml"); - // Config updating Code + // innitialize configurations & update options if( isset( $c["Options"] ) && is_array( $c["Options"] ) ){ if(!isset($c["Options"]["Msgtype"])){ @@ -181,15 +182,13 @@ public function onEnable() : void{ $c["Options"]["AutoWhitelist"] = 'on'; $newchange['AutoWhitelist'] = "! AutoWhitelist option missing in config.yml, now set to 'on'; please see /resources/config.yml"; } - $this->options = $c["Options"]; - }else{ $this->options = array("Msgtype"=>"pop", "Msgdisplay"=>"off", "AutoWhitelist"=>"on"); // Fallback defaults $newchange['Options'] = "! Config Options missing in config.yml, defautls are set for now; please see /resources/config.yml"; } - // config default check and overwrite plugin defaults + // set defaults if(!isset($c["Default"]["God"])) { $c["Default"]["God"] = false; } @@ -199,12 +198,12 @@ public function onEnable() : void{ if(!isset($c["Default"]["Touch"])) { $c["Default"]["Touch"] = false; } - if(!isset($c["Default"]["Msg"])) { + if(!isset($c["Default"]["Msg"])) { // new in v1.0.3 $c["Default"]["Msg"] = false; } - if( isset($c["Default"]["Barrier"]) ){ // remove in v1.0.5-11 + if( isset($c["Default"]["Barrier"]) ){ // new in v1.0.4-11 $c["Default"]["Passage"] = $c["Default"]["Barrier"]; - }else if(!isset($c["Default"]["Passage"])) { + }else if(!isset($c["Default"]["Passage"])) { // replaced in v1.0.5-11 $c["Default"]["Passage"] = false; } if(!isset($c["Default"]["Perms"])) { // new in v1.0.4-11 @@ -219,7 +218,7 @@ public function onEnable() : void{ if(!isset($c["Default"]["PVP"])) { // new in v1.0.6-13 $c["Default"]["PVP"] = false; } - if(!isset($c["Default"]["Flight"])) { + if(!isset($c["Default"]["Flight"])) { // new in v1.0.6-13 $c["Default"]["Flight"] = false; } if(!isset($c["Default"]["TNT"])) { // new in v1.0.7 @@ -256,7 +255,7 @@ public function onEnable() : void{ if(is_array( $c["Worlds"] )){ foreach($c["Worlds"] as $level => $flags){ if( isset($flags["Barrier"]) ){ // check since v1.0.3-11 - $flags["Passage"] = $flags["Barrier"]; + $flags["Passage"] = $flags["Barrier"]; // replaced in v1.0.5-11 unset($flags["Barrier"]); } if( !isset($flags["Passage"]) ){ @@ -280,15 +279,15 @@ public function onEnable() : void{ if( !isset($flags["TNT"]) ){ // new v1.0.7 $flags["TNT"] = $this->tnt; } - if( !isset($flags["Shoot"]) ){ // new v1.0.7 - $flags["Shoot"] = $this->shoot; - } if( !isset($flags["Hunger"]) ){ // new v1.0.7 $flags["Hunger"] = $this->hunger; } - if( !isset($flags["NoFallDamage"]) ){ // new in v1.0.8 + if( !isset($flags["NoFallDamage"]) ){ // new in v1.0.7.2 $flags["NoFallDamage"] = $this->nofalldamage; } + if( !isset($flags["Shoot"]) ){ // new v1.0.7.2 + $flags["Shoot"] = $this->shoot; + } $this->levels[$level] = $flags; } } @@ -297,9 +296,7 @@ public function onEnable() : void{ /** console output */ $this->codeSigned(); // codesign - $ca = 0; // plugin area info - foreach( $this->areas as $a ){ $ca = $ca + count( $a->getCommands() ); } @@ -484,13 +481,14 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar }else{ $o = TextFormat::RED . "You do not have permission to use this subcommand."; } - break; + break; + case "desc": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.desc")){ if(isset($args[1])){ if(isset($this->areas[strtolower($args[1])])){ if(isset($args[2])){ - $ar = $args[1]; + $ar = $args[1]; unset($args[0]); unset($args[1]); $desc = implode(" ", $args); @@ -510,85 +508,56 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar }else{ $o = TextFormat::RED . "You do not have permission to use this subcommand."; } - break; + break; + case "list": if( $sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.list")){ - - $levelNamesArray = scandir($this->getServer()->getDataPath() . "worlds/"); foreach($levelNamesArray as $levelName) { - if($levelName === "." || $levelName === "..") { + if($levelName === "." || $levelName === "..") { continue; - } - $this->getServer()->loadLevel($levelName); //Note that this will return false if the world folder is not a valid level, and could not be loaded. + } + $this->getServer()->loadLevel($levelName); //Note that this will return false if the world folder is not a valid level, and could not be loaded. } $lvls = $this->getServer()->getLevels(); + $o = ''; + $l = ''; - $o = ''; - - $l = ''; - - if( isset( $args[1] )){ - - $l = $args[1]; - - }else{ - - $l = false; - - } - - foreach( $lvls as $lvl ){ - - $i = 0; - - $t = ''; - - foreach($this->areas as $area){ - - if( $area->getLevelName() == $lvl->getName() ){ - - if( ( !empty($l) && $l == $lvl->getName() ) || $l == false ){ - - $t .= $this->areaInfoDisplayList( $area ); - - $i++; - - } - - } - - } - - if( $i > 0 ){ - - $o .= TextFormat::DARK_PURPLE ."---- Area list ----\n"; - - $o .= TextFormat::GRAY . "level " . TextFormat::YELLOW . $lvl->getName() .":\n". $t; - - } - - } - - if($o != ''){ - - $o .= TextFormat::DARK_PURPLE ."----------------\n"; - - } - - - - if($o == ''){ - - $o = "There are no areas that you can edit"; + if( isset( $args[1] )){ + $l = $args[1]; + }else{ + $l = false; + } - } + foreach( $lvls as $lvl ){ + $i = 0; + $t = ''; + foreach($this->areas as $area){ + if( $area->getLevelName() == $lvl->getName() ){ + if( ( !empty($l) && $l == $lvl->getName() ) || $l == false ){ + $t .= $this->areaInfoDisplayList( $area ); + $i++; + } + } + } + if( $i > 0 ){ + $o .= TextFormat::DARK_PURPLE ."---- Area list ----\n"; + $o .= TextFormat::GRAY . "level " . TextFormat::YELLOW . $lvl->getName() .":\n". $t; + } + } + if($o != ''){ + $o .= TextFormat::DARK_PURPLE ."----------------\n"; + } + if($o == ''){ + $o = "There are no areas that you can edit"; + } + } + break; - } - break; case "here": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.here")){ $o = ""; + $playername = strtolower($sender->getName()); foreach($this->inArea[$playername] as $areaname){ if( isset($this->areaList[ $areaname ]) ){ $area = $this->areaList[$areaname]; @@ -597,21 +566,12 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o .= TextFormat::DARK_PURPLE ."----------------\n"; } } - /* - foreach($this->areas as $area){ - - if($area->contains($sender->getPosition(), $sender->getLevel()->getName()) && $area->getWhitelist() !== null){ - $o .= TextFormat::DARK_PURPLE ."---- Area here ----\n"; - $o .= $this->areaInfoDisplayList( $area ); - $o .= TextFormat::DARK_PURPLE ."----------------\n"; - } - }*/ - if($o === "") { $o = TextFormat::RED . "You are in an unknown area"; } } - break; + break; + case "tp": if (!isset($args[1])){ $o = TextFormat::RED . "You must specify an existing Area name"; @@ -620,27 +580,22 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar if( isset( $this->areas[strtolower($args[1])] ) ){ $area = $this->areas[strtolower($args[1])]; - $position = $sender->getPosition(); - $perms = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[ $position->getLevel()->getName() ]["Perms"] : $this->perms); if( $perms || $area->isWhitelisted($playerName) || $sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.tp")){ $levelName = $area->getLevelName(); if(isset($levelName) && Server::getInstance()->loadLevel($levelName) != false){ - $o = TextFormat::GREEN . "You are teleporting to Area " . $args[1]; - $cx = $area->getSecondPosition()->getX() + ( ( $area->getFirstPosition()->getX() - $area->getSecondPosition()->getX() ) / 2 ); - $cz = $area->getSecondPosition()->getZ() + ( ( $area->getFirstPosition()->getZ() - $area->getSecondPosition()->getZ() ) / 2 ); - $cy1 = min( $area->getSecondPosition()->getY(), $area->getFirstPosition()->getY()); - $cy2 = max( $area->getSecondPosition()->getY(), $area->getFirstPosition()->getY()); - if( $this->hasNoFallDamage($sender) ){ - $this->playerTP[$playerName] = true; // player tp active - //$this->areaMessage( 'Fall save on!', $sender ); - } - $sender->teleport( new Position( $cx, $cy2 - 2, $cz, $area->getLevel() ) ); - //$sender->sendMessage( $playerName ); - + $o = TextFormat::GREEN . "You are teleporting to Area " . $args[1]; + $cx = $area->getSecondPosition()->getX() + ( ( $area->getFirstPosition()->getX() - $area->getSecondPosition()->getX() ) / 2 ); + $cz = $area->getSecondPosition()->getZ() + ( ( $area->getFirstPosition()->getZ() - $area->getSecondPosition()->getZ() ) / 2 ); + $cy1 = min( $area->getSecondPosition()->getY(), $area->getFirstPosition()->getY()); + $cy2 = max( $area->getSecondPosition()->getY(), $area->getFirstPosition()->getY()); + if( $this->hasNoFallDamage($sender) ){ + $this->playerTP[$playerName] = true; // player tp active $this->areaMessage( 'Fall save on!', $sender ); + } + $sender->teleport( new Position( $cx, $cy2 - 2, $cz, $area->getLevel() ) ); }else{ $o = TextFormat::RED . "The level " . $levelName . " for Area ". $args[1] ." cannot be found"; } @@ -651,7 +606,8 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $list = $this->listAllAreas(); $o = TextFormat::RED . "The Area " . $args[1] . " could not be found. ". $list; } - break; + break; + case "f": case "flag": case "touch": @@ -706,10 +662,8 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar }else if(isset($this->areas[strtolower($args[1])])){ $area = $this->areas[strtolower($args[1])]; - $flag = $this->isFlag( $args[0] ); // v1.0.6-13 if( $flag ){ - if( isset($args[2]) && ( $args[2] == "true" || $args[2] == "on" || $args[2] == "false" || $args[2] == "off" ) ){ $mode = strtolower($args[2]); if($mode === "true" || $mode === "on"){ @@ -729,14 +683,9 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o = TextFormat::GREEN . "Flag " . $flag . " set to " . $status . " for area " . $area->getName() . "!"; }else{ - - - // excute long (old) notation - if(isset($args[2])){ - + + if(isset($args[2])){ // excute long (old) notation if( $args[2] == "list" ){ - - //$o = TextFormat::RED . "Flag list in develoment"; $flgs = $area->getFlags(); $l = $area->getName() . TextFormat::GRAY . " flags:"; foreach($flgs as $fi => $flg){ @@ -748,9 +697,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } } $o = $l; - }else if( isset($area->flags[strtolower($args[2])]) ){ - $flag = strtolower($args[2]); if(isset($args[3])){ $mode = strtolower($args[3]); @@ -772,7 +719,6 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar }else{ $o = TextFormat::RED . "Flag not found. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, shoot, hunger, perms, nofalldamage)"; } - }else{ $o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, shoot, hunger, perms, nofalldamage)"; } @@ -786,7 +732,8 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar }else{ $o = TextFormat::RED . "You do not have permission to use this subcommand."; } - break; + break; + case "del": case "delete": case "remove": @@ -805,7 +752,8 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar }else{ $o = TextFormat::RED . "You do not have permission to use this subcommand."; } - break; + break; + case "whitelist": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.whitelist")){ if(isset($args[1], $this->areas[strtolower($args[1])])){ @@ -852,7 +800,8 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar }else{ $o = TextFormat::RED . "You do not have permission to use this subcommand."; } - break; + break; + case "c": case "cmd": case "command": /** /fe command */ @@ -900,7 +849,8 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar }else{ $o = TextFormat::RED .'Please specify the command ID and command string to add. Usage: /fe command add '; } - break; + break; + case "list": $ar = $this->areas[strtolower($args[1])]; if( isset($ar->commands) ){ @@ -919,9 +869,9 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $this->saveAreas(); } } - } - break; + break; + case "event": //$o = '/fe command event '; if( isset($args[3]) && isset($args[4]) ){ @@ -932,9 +882,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o = ''; if( $evl = $area->getEvents() ){ $ts = 0; - foreach($evl as $t => $cids ){ - $arr = explode(",",$cids); if( in_array($cid,$arr) && $t != $evt){ foreach($arr as $k => $ci){ @@ -964,7 +912,8 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } } } - break; + break; + case "edit": if( isset($args[3]) && isset($args[4]) ){ $ar = $args[1]; @@ -986,10 +935,12 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar }else{ $o = TextFormat::RED .'Please specify the command ID and command string to add. Usage: /fe command add '; } - break; + break; + case "del": case "delete": case "remove": + if( isset($args[3]) ){ $area = $this->areas[strtolower($args[1])]; $cid = $args[3]; @@ -1019,8 +970,9 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar }else{ $o = TextFormat::RED .'Please specify the command ID to delete. Usage /fe event command del '; } - break; - default: + break; + + default: return false; } }else{ @@ -1036,9 +988,10 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o = TextFormat::RED . "You do not have permission to use this subcommand."; } } - break; + break; + default: - return false; + return false; } $sender->sendMessage($o); return true; @@ -1062,43 +1015,24 @@ public function onQuit(PlayerQuitEvent $event){ */ public function canGetHurt(Entity $entity) : bool{ $o = true; - if( $entity instanceof Player){ $default = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["God"] : $this->god); if($default){ $o = false; } $playername = strtolower($entity->getName()); - foreach($this->inArea[$playername] as $areaname){ if( isset($this->areaList[ $areaname ]) ){ $area = $this->areaList[ $areaname ]; - if($default && !$area->getFlag("god")){ - $o = true; - break; - } if($area->getFlag("god")){ $o = false; } + if($area->isWhitelisted($playername)){ + $o = false; + } } } } - /* inarea replace - foreach($this->areas as $area){ - - if($area->contains(new Vector3($entity->getX(), $entity->getY(), $entity->getZ()), $entity->getLevel()->getName())){ - - if($default && !$area->getFlag("god")){ - $o = true; - break; - } - if($area->getFlag("god")){ - $o = false; - } - - } - - }*/ return $o; } @@ -1109,12 +1043,11 @@ public function canGetHurt(Entity $entity) : bool{ public function canPVP(EntityDamageEvent $ev) : bool{ $o = true; $god = false; - if($ev instanceof EntityDamageByEntityEvent){ if($ev->getEntity() instanceof Player && $ev->getDamager() instanceof Player){ $entity = $ev->getEntity(); - $default = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["PVP"] : $this->pvp); - if($default){ + $p = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["PVP"] : $this->pvp); + if($p){ $o = false; } $playername = $entity->getName(); @@ -1122,31 +1055,14 @@ public function canPVP(EntityDamageEvent $ev) : bool{ if( isset($this->areaList[ $areaname ]) ){ $area = $this->areaList[$areaname]; $god = $area->getFlag("god"); - if($default && !$area->getFlag("pvp")){ - $o = true; - break; - } if($area->getFlag("pvp")){ $o = false; - break; - } - } - } - /* - foreach($this->areas as $area){ - if($area->contains(new Vector3($entity->getX(), $entity->getY(), $entity->getZ()), $entity->getLevel()->getName())){ - $god = $area->getFlag("god"); - if($default && !$area->getFlag("pvp")){ - $o = true; - break; } - if($area->getFlag("pvp")){ + if($area->isWhitelisted($playername)){ $o = false; - break; } } } - */ } } if( !$o ){ @@ -1205,40 +1121,23 @@ public function hasNoFallDamage(Entity $entity) : bool{ $o = true; if( $entity instanceof Player ){ - - $default = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["NoFallDamage"] : $this->nofalldamage); - if($default){ + $f = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["NoFallDamage"] : $this->nofalldamage); + if($f){ $o = false; } - $playername = strtolower($entity->getName()); foreach($this->inArea[$playername] as $areaname){ if( isset($this->areaList[ $areaname ]) ){ $area = $this->areaList[$areaname]; - if($default && !$area->getFlag("nofalldamage")){ - $o = true; - break; - } if($area->getFlag("nofalldamage")){ $o = false; } + if($area->isWhitelisted($playername)){ + $o = false; + } } } - } - /* - foreach($this->areas as $area){ - if($area->contains(new Vector3($entity->getX(), $entity->getY(), $entity->getZ()), $entity->getLevel()->getName())){ - if($default && !$area->getFlag("nofalldamage")){ - $o = true; - break; - } - if($area->getFlag("nofalldamage")){ - $o = false; - } - } - } - */ return $o; } @@ -1269,11 +1168,10 @@ public function canEdit(Player $player, Position $position) : bool{ return true; } $o = true; - $g = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Edit"] : $this->edit); - if($g){ + $e = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Edit"] : $this->edit); + if($e){ $o = false; } - $playername = strtolower($player->getName()); foreach($this->inArea[$playername] as $areaname){ if( isset($this->areaList[ $areaname ]) ){ @@ -1281,33 +1179,11 @@ public function canEdit(Player $player, Position $position) : bool{ if($area->getFlag("edit")){ $o = false; } - if($area->isWhitelisted(strtolower($player->getName()))){ - $o = true; - break; - } - if(!$area->getFlag("edit") && $g){ + if($area->isWhitelisted($playername)){ $o = true; - break; } } } - /* - foreach($this->areas as $area){ - if($area->contains($position, $position->getLevel()->getName())){ - if($area->getFlag("edit")){ - $o = false; - } - if($area->isWhitelisted(strtolower($player->getName()))){ - $o = true; - break; - } - if(!$area->getFlag("edit") && $g){ - $o = true; - break; - } - } - } - */ return $o; } @@ -1322,8 +1198,8 @@ public function canTouch(Player $player, Position $position) : bool{ } $playername = strtolower($player->getName()); $o = true; - $default = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Touch"] : $this->touch); - if($default){ + $t = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Touch"] : $this->touch); + if($t){ $o = false; } foreach($this->inArea[$playername] as $areaname){ @@ -1332,33 +1208,11 @@ public function canTouch(Player $player, Position $position) : bool{ if($area->getFlag("touch")){ $o = false; } - if($area->isWhitelisted(strtolower($player->getName()))){ - $o = true; - break; - } - if(!$area->getFlag("touch") && $default){ + if($area->isWhitelisted($playername)){ $o = true; - break; } } } - /* - foreach($this->areas as $area){ - if($area->contains(new Vector3($position->getX(), $position->getY(), $position->getZ()), $position->getLevel()->getName())){ - if($area->getFlag("touch")){ - $o = false; - } - if($area->isWhitelisted(strtolower($player->getName()))){ - $o = true; - break; - } - if(!$area->getFlag("touch") && $default){ - $o = true; - break; - } - } - } - */ return $o; } @@ -1406,28 +1260,12 @@ public function canHunger( PlayerExhaustEvent $event ): bool{ $area = $this->areaList[$areaname]; if ($area->getFlag("hunger")) { $o = false; - break; - } - if ($area->getFlag("hunger") && $g) { - $o = true; - break; } - } - } - /* - foreach ($this->areas as $area) { - if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { - if ($area->getFlag("hunger")) { + if($area->isWhitelisted($playername)){ $o = false; - break; - } - if ($area->getFlag("hunger") && $g) { - $o = true; - break; } } } - */ return $o; } @@ -1461,15 +1299,12 @@ public function canExplode( Position $pos ): bool{ 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) { + if (!$area->getFlag("tnt") && $g) { $o = true; - break; } } } - return $o; } @@ -1509,37 +1344,14 @@ public function canDrop(Player $player, Position $position) : bool{ if($area->getFlag("drop")){ $o = false; } - if($area->isWhitelisted(strtolower($player->getName()))){ + if($area->isWhitelisted($playername)){ $o = true; - break; - } - if(!$area->getFlag("drop") && $g){ - $o = true; - break; } } } - /* - foreach($this->areas as $area){ - if($area->contains($position, $position->getLevel()->getName())){ - if($area->getFlag("drop")){ - $o = false; - } - if($area->isWhitelisted(strtolower($player->getName()))){ - $o = true; - break; - } - if(!$area->getFlag("drop") && $g){ - $o = true; - break; - } - } - } - */ return $o; } - /** Shoot / Launch projectiles * @param EntityShootBowEvent $event * @ignoreCancelled true @@ -1555,7 +1367,6 @@ public function onEntityShootBow( EntityShootBowEvent $event ){ } - /** onShoot * @param Player $player * @return bool @@ -1581,52 +1392,23 @@ public function canShoot( Player $player ) : bool{ if($area->getFlag("shoot")){ $o = false; } - if($area->isWhitelisted(strtolower($player->getName()))){ - $o = true; - break; - } - if(!$area->getFlag("shoot") && $g){ + if($area->isWhitelisted($playername)){ $o = true; - break; } if( $area->getFlag("msg") ){ $m = false; } } } - /* - foreach($this->areas as $area){ - if($area->contains($position, $position->getLevel()->getName())){ - if($area->getFlag("shoot")){ - $o = false; - } - if($area->isWhitelisted(strtolower($player->getName()))){ - $o = true; - break; - } - if(!$area->getFlag("shoot") && $g){ - $o = true; - break; - } - if( $area->getFlag("msg") ){ - $m = false; - } - } - - } - */ - // new message method - if( $m && !$o ){ - $msg = TextFormat::RED . "NO Shooting here!"; - $player->sendMessage( $msg ); + if( $m && !$o ){ // 'ínline' message method + $msg = TextFormat::RED . "NO Shooting here!"; + $player->sendMessage( $msg ); } - return $o; } - /** Block Place * @param BlockPlaceEvent $event * @ignoreCancelled true @@ -1662,13 +1444,11 @@ public function onBlockBreak(BlockBreakEvent $event) : void{ $playerName = strtolower($player->getName()); if(isset($this->selectingFirst[$playerName])){ unset($this->selectingFirst[$playerName]); - $this->firstPosition[$playerName] = $block->asVector3(); $player->sendMessage(TextFormat::GREEN . "Position 1 set to: (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); $event->setCancelled(); }elseif(isset($this->selectingSecond[$playerName])){ unset($this->selectingSecond[$playerName]); - $this->secondPosition[$playerName] = $block->asVector3(); $player->sendMessage(TextFormat::GREEN . "Position 2 set to: (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); $event->setCancelled(); @@ -1731,33 +1511,12 @@ public function canUseEffects( Player $player ) : bool{ if($area->getFlag("effects")){ $o = false; } - if($area->isWhitelisted(strtolower($player->getName()))){ - $o = true; - break; - } - if(!$area->getFlag("effects") && $g){ + if( $area->isWhitelisted( $playername ) ){ $o = true; - break; } } } - /* - foreach($this->areas as $area){ - if($area->contains($position, $position->getLevel()->getName())){ - if($area->getFlag("effects")){ - $o = false; - } - if($area->isWhitelisted(strtolower($player->getName()))){ - $o = true; - break; - } - if(!$area->getFlag("effects") && $g){ - $o = true; - break; - } - } - } - */ + return $o; } @@ -1793,34 +1552,15 @@ public function checkPlayerFlying(Player $player){ if( $area->getFlag("nofalldamage") ){ $nofalldamage = true; } - if( $player->isOp() ){ - $fly = true; // ops can fly || - $sendmsg = $this->msgOpDsp( $area, $player ); - } } } - - /* - foreach($this->areas as $area){ - if( $area->contains( $player->getPosition(), $player->getLevel()->getName() ) ){ - if( $area->getFlag("flight") && !$area->isWhitelisted( strtolower($player->getName())) ){ - $fly = false; // flag area - }else{ - $fly = true; - } - if( !$area->getFlag("msg") ){ - $sendmsg = true; - } - if( $area->getFlag("nofalldamage") ){ - $nofalldamage = true; - } - if( $player->isOp() ){ - $fly = true; // ops can fly || - $sendmsg = $this->msgOpDsp( $area, $player ); - } + if( $player->isOp() ){ + $fly = true; // ops can fly || + $sendmsg = true; + if( isset($area) ){ + $sendmsg = $this->msgOpDsp( $area, $player ); } } - */ $msg = ''; if( !$fly && $player->isFlying() ){ if( $nofalldamage ){ @@ -2011,17 +1751,16 @@ public function enterArea(Area $area, PlayerMoveEvent $ev): void{ } } + $playerName = strtolower( $player->getName() ); + $this->inArea[$playerName][] = strtolower( $area->getName() ); // player area's + // effects check - if( $this->canUseEffects( $player ) ){ - // use effects + if( $this->canUseEffects( $player ) ){// use effects }else{ foreach ($player->getEffects() as $effect) { $player->removeEffect($effect->getId()); } } - - $playerName = strtolower( $player->getName() ); - $this->inArea[$playerName][] = strtolower( $area->getName() ); $this->runAreaEvent($area, $ev, "enter"); return; } @@ -2191,9 +1930,7 @@ public function areaMessage( $msg , $player ){ * @return bool */ public function msgOpDsp( $area, $player ){ - if( isset( $this->options['Msgdisplay'] ) && $player->isOp() ){ - if( $this->options['Msgdisplay'] == 'on' ){ return true; }else if( $this->options['Msgdisplay'] == 'op' && $area->isWhitelisted(strtolower($player->getName())) ){ @@ -2201,12 +1938,9 @@ public function msgOpDsp( $area, $player ){ }else{ return false; } - }else{ return false; } - - } /** areaSounds @@ -2302,7 +2036,6 @@ public function onFallDisable(EntityDamageEvent $event) : void{ if(!$this->canGetHurt($player)){ $event->setCancelled(); } - if($cause == EntityDamageEvent::CAUSE_FALL && !$this->hasNoFallDamage($player)){ $event->setCancelled(true); } From 5421948cd3e9ed0f71905085c42a4bfce32808ed Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 19 Aug 2018 12:30:24 +0200 Subject: [PATCH 16/68] Update 1.0.7.3-dev --- plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.yml b/plugin.yml index e96fb1c..a89276d 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: Festival author: Genboy -version: 1.0.7.2-dev +version: 1.0.7.3-dev main: genboy\Festival\Main load: POSTWORLD api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0] From 9f30f0ff2547b5001ce49ac34d57ad4a59a37c2f Mon Sep 17 00:00:00 2001 From: genboy Date: Tue, 21 Aug 2018 16:08:04 +0200 Subject: [PATCH 17/68] name change FallDamage flag + info --- resources/config.yml | 101 +++++++++++----------- src/genboy/Festival/Main.php | 161 ++++++++++++++++++----------------- 2 files changed, 137 insertions(+), 125 deletions(-) diff --git a/resources/config.yml b/resources/config.yml index 06035ed..ddd5b8b 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -3,147 +3,150 @@ # Festival options Options: - # Messages (tip/pop) + # Area Messages Display position (tip/pop) Msgtype: pop - # Messages persist display to ops (off/op/on) + # Area Messages persist display to ops (off/op/on) Msgdisplay: off # Auto whitelist area creator (on/off) AutoWhitelist: on -# Settings for unprotected areas in worlds without specific settings: +# Flag settings for unprotected areas +# Flag rule: a flag protects the area and the players in it +# These are the default flags, default flags for new worlds and defaults for individual worlds: Default: - # Keep players from getting hurt? + # Keep players from getting hurt? (true = Player god mode) God: false - # Keep players from getting hurt by other players? + # Keep players from getting hurt by other players? (true = NoPVP) PVP: false - # Keep players from flying? + # Keep players from flying? (true = NoFlight) Flight: true - # Keep players from editing the world? + # Keep players from editing the world? (true = NoEdit) Edit: true - # Keep players from touching blocks and activating things like chests? + # Keep players from touching blocks and activating things like chests? (true = NoTouching) Touch: false - # Keep players from having effects like speed or night vision? + # Keep players from having effects like speed or night vision? (true = NoEffects) Effects: false - # Keep players from seeing enter/leave/description messages? + # Keep players from seeing enter/leave/description messages? (true = NoMessages) Msg: false - # Prevent players from enter/leaving the area? (barrier) + # Prevent players from enter/leaving the area? (barrier) (true = NoPassage) Passage: false - # Keep players from dropping items in the area? + # Keep players from dropping items in the area? (true = NoDropping) Drop: false - # No explosions allowed in the area? + # No explosions allowed in the area? (true = NoExplosions) TNT: false - # No shooting allowed in the area? + # No shooting allowed in the area? (true = NoShooting) Shoot: false - # Keep players from hunger(exhaust) in the area? + # Keep players from hunger(exhaust) in the area? (true = NoExhaust) Hunger: false - # Keep players from executing area event commands without specific perms + # Keep players from executing area event commands without specific perms (true = No Op Permissons) Perms: false - # Keep players from taking fall damage (default for teleport/flying drop) - NoFallDamage: true + # Keep players from taking fall damage (true = NoFallDamage) + FallDamage: true # Settings for unprotected areas in individual worlds: Worlds: - + + # New worlds (ie. automatic generated) DEFAULT: - # Keep players from getting hurt? + # Keep players from getting hurt? (true = Player god mode) God: false - # Keep players from getting hurt by other players? + # Keep players from getting hurt by other players? (true = NoPVP) PVP: false - # Keep players from flying? + # Keep players from flying? (true = NoFlight) Flight: true - # Keep players from editing the world? + # Keep players from editing the world? (true = NoEdit) Edit: true - # Keep players from touching blocks and activating things like chests? + # Keep players from touching blocks and activating things like chests? (true = NoTouching) Touch: false - # Keep players from touching blocks and activating things like chests? + # Keep players from having effects like speed or night vision? (true = NoEffects) Effects: false - # Keep players from seeing enter/leave/description messages? + # Keep players from seeing enter/leave/description messages? (true = NoMessages) Msg: false - # Prevent players from enter/leaving the area? (barrier) + # Prevent players from enter/leaving the area? (barrier) (true = NoPassage) Passage: false - # No explosions allowed in the area? + # Keep players from dropping items in the area? (true = NoDropping) Drop: false - # No explosions allowed in the area? + # No explosions allowed in the area? (true = NoExplosions) TNT: false - # No shooting allowed in the area? + # No shooting allowed in the area? (true = NoShooting) Shoot: false - # Keep players from hunger(exhaust) in the area? + # Keep players from hunger(exhaust) in the area? (true = NoExhaust) Hunger: false - # Keep players from executing area event commands without specific perms + # Keep players from executing area event commands without specific perms (true = No Op Permissons) Perms: false - # Keep players from taking fall damage - NoFallDamage: true + # Keep players from taking fall damage (true = NoFallDamage) + FallDamage: true world: - # Keep players from getting hurt? + # Keep players from getting hurt? (true = Player god mode) God: false - # Keep players from getting hurt by other players? + # Keep players from getting hurt by other players? (true = NoPVP) PVP: false - # Keep players from flying? + # Keep players from flying? (true = NoFlight) Flight: true - # Keep players from editing the world? + # Keep players from editing the world? (true = NoEdit) Edit: true - # Keep players from touching blocks and activating things like chests? + # Keep players from touching blocks and activating things like chests? (true = NoTouching) Touch: false - # Keep players from touching blocks and activating things like chests? + # Keep players from having effects like speed or night vision? (true = NoEffects) Effects: false - # Keep players from seeing enter/leave/description messages? + # Keep players from seeing enter/leave/description messages? (true = NoMessages) Msg: false - # Prevent players from enter/leaving the area? (barrier) + # Prevent players from enter/leaving the area? (barrier) (true = NoPassage) Passage: false - # Keep players from dropping items in the area? + # Keep players from dropping items in the area? (true = NoDropping) Drop: false - # No explosions allowed in the area? + # No explosions allowed in the area? (true = NoExplosions) TNT: false - # No shooting allowed in the area? + # No shooting allowed in the area? (true = NoShooting) Shoot: false - # Keep players from hunger(exhaust) in the area? + # Keep players from hunger(exhaust) in the area? (true = NoExhaust) Hunger: false - # Keep players from executing area event commands without specific perms + # Keep players from executing area event commands without specific perms (true = No Op Permissons) Perms: false - # Keep players from taking fall damage - NoFallDamage: true + # Keep players from taking fall damage (true = NoFallDamage) + FallDamage: true diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 2f5f57c..bd28b02 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1,7 +1,7 @@ god = $c["Default"]["God"]; @@ -246,7 +251,7 @@ public function onEnable() : void{ $this->flight = $c["Default"]["Flight"]; // new in v1.0.6-13 $this->tnt = $c["Default"]["TNT"]; // new in v1.0.7 $this->hunger = $c["Default"]["Hunger"]; // new in v1.0.7 - $this->nofalldamage = $c["Default"]["NoFallDamage"]; // new in 1.0.7.2-dev(1.0.8) + $this->falldamage = $c["Default"]["FallDamage"]; // new in 1.0.7.2-dev(1.0.8) $this->shoot = $c["Default"]["Shoot"]; // new in 1.0.7.2-dev(1.0.8) $this->flagset = $c['Default']; // new in v1.0.5-12 @@ -282,8 +287,8 @@ public function onEnable() : void{ if( !isset($flags["Hunger"]) ){ // new v1.0.7 $flags["Hunger"] = $this->hunger; } - if( !isset($flags["NoFallDamage"]) ){ // new in v1.0.7.2 - $flags["NoFallDamage"] = $this->nofalldamage; + if( !isset($flags["FallDamage"]) ){ // new in v1.0.7.2 + $flags["FallDamage"] = $this->falldamage; } if( !isset($flags["Shoot"]) ){ // new v1.0.7.2 $flags["Shoot"] = $this->shoot; @@ -328,7 +333,7 @@ public function isFlag( $str ){ "msg","message", "passage","pass","barrier", "perms","perm", - "nofalldamage","falldamage","nfd","fall", + "falldamage","nofalldamage","fd","nfd","fall", "shoot", "launch", ]; $str = strtolower( $str ); @@ -371,8 +376,8 @@ public function isFlag( $str ){ if( $str == "hunger" || $str == "starve" ){ $flag = "hunger"; } - if( $str == "nofalldamage" || $str == "falldamage" || $str == "nfd" || $str == "fall"){ - $flag = "nofalldamage"; + if( $str == "nofalldamage" || $str == "falldamage" || $str == "fd" || $str == "nfd" || $str == "fall"){ + $flag = "falldamage"; } } return $flag; @@ -425,58 +430,62 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.area") || $sender->hasPermission("festival.command.fe.create")){ if(isset($args[1])){ if(isset($this->firstPosition[$playerName], $this->secondPosition[$playerName])){ - if(!isset($this->areas[strtolower($args[1])])){ - // get level default flags - $flags = $this->flagset; - if( isset($this->levels[$sender->getLevel()->getName()]) ){ - if( is_array( $this->levels[$sender->getLevel()->getName()] ) ){ - $flags = $this->levels[$sender->getLevel()->getName()]; + if( $args[1] != '' && $args[1] != ' ' ){ + if( !isset($this->areas[strtolower($args[1])]) ){ + // get level default flags + $flags = $this->flagset; + if( isset($this->levels[$sender->getLevel()->getName()]) ){ + if( is_array( $this->levels[$sender->getLevel()->getName()] ) ){ + $flags = $this->levels[$sender->getLevel()->getName()]; + } + } + // get default whitelisting + $whitelist = []; + if( $this->options["AutoWhitelist"] == "on" ){ + $whitelist = [$playerName]; } - } - // get default whitelisting - $whitelist = []; - if( $this->options["AutoWhitelist"] == "on" ){ - $whitelist = [$playerName]; - } - new Area( - strtolower($args[1]), - "", - [ "edit" => $flags['Edit'], - "god" => $flags['God'], - "pvp" => $flags["PVP"], - "flight"=> $flags["Flight"], - "touch" => $flags['Touch'], - "effects" => $flags['Effects'], - "msg" => $flags['Msg'], - "passage" => $flags['Passage'], - "drop" => $flags['Drop'], - "tnt" => $flags['TNT'], - "shoot" => $flags['Shoot'], - "hunger" => $flags['Hunger'], - "perms" => $flags['Perms'], - "nofalldamage" => $flags['NoFallDamage']], - - $this->firstPosition[$playerName], - $this->secondPosition[$playerName], - $sender->getLevel()->getName(), - $whitelist, - [], - [], - $this - ); - - $this->saveAreas(); - unset($this->firstPosition[$playerName], $this->secondPosition[$playerName]); - $o = TextFormat::AQUA . "Area created!"; - }else{ - $o = TextFormat::RED . "An area with that name already exists."; - } - }else{ - $o = TextFormat::RED . "Please select both positions first."; - } + new Area( + strtolower($args[1]), + "", + [ "edit" => $flags['Edit'], + "god" => $flags['God'], + "pvp" => $flags["PVP"], + "flight"=> $flags["Flight"], + "touch" => $flags['Touch'], + "effects" => $flags['Effects'], + "msg" => $flags['Msg'], + "passage" => $flags['Passage'], + "drop" => $flags['Drop'], + "tnt" => $flags['TNT'], + "shoot" => $flags['Shoot'], + "hunger" => $flags['Hunger'], + "perms" => $flags['Perms'], + "falldamage" => $flags['FallDamage']], + + $this->firstPosition[$playerName], + $this->secondPosition[$playerName], + $sender->getLevel()->getName(), + $whitelist, + [], + [], + $this + ); + + $this->saveAreas(); + unset($this->firstPosition[$playerName], $this->secondPosition[$playerName]); + $o = TextFormat::AQUA . "Area created!"; + }else{ + $o = TextFormat::RED . "An area with that name already exists."; + } + }else{ + $o = TextFormat::RED . "Enter a name for the area (/fe create )."; + } + }else{ + $o = TextFormat::RED . "Please select both positions first."; + } }else{ - $o = TextFormat::RED . "Please specify a name for this area."; + $o = TextFormat::RED . "Please specify a name for this area (/fe create )."; } }else{ $o = TextFormat::RED . "You do not have permission to use this subcommand."; @@ -628,13 +637,13 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "starve": case "tnt": case "explode": - case "shoot"; - case "launch"; + case "shoot": + case "launch": case "drop": - case "nofalldamage"; - case "falldamage"; - case "fall"; - case "nfd"; + case "falldamage": + case "nofalldamage": + case "fall": + case "nfd": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.flag")){ if(isset($args[1])){ @@ -717,10 +726,10 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } $o = TextFormat::GREEN . "Flag " . $flag . " set to " . $status . " for area " . $area->getName() . "!"; }else{ - $o = TextFormat::RED . "Flag not found. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, shoot, hunger, perms, nofalldamage)"; + $o = TextFormat::RED . "Flag not found. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; } }else{ - $o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, shoot, hunger, perms, nofalldamage)"; + $o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; } } }else{ @@ -1121,7 +1130,7 @@ public function hasNoFallDamage(Entity $entity) : bool{ $o = true; if( $entity instanceof Player ){ - $f = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["NoFallDamage"] : $this->nofalldamage); + $f = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["FallDamage"] : $this->falldamage); if($f){ $o = false; } @@ -1129,7 +1138,7 @@ public function hasNoFallDamage(Entity $entity) : bool{ foreach($this->inArea[$playername] as $areaname){ if( isset($this->areaList[ $areaname ]) ){ $area = $this->areaList[$areaname]; - if($area->getFlag("nofalldamage")){ + if($area->getFlag("falldamage")){ $o = false; } if($area->isWhitelisted($playername)){ @@ -1529,7 +1538,7 @@ public function checkPlayerFlying(Player $player){ $fly = true; $sendmsg = false; - $nofalldamage = false; + $falldamage = false; $position = $player->getPosition(); $playername = strtolower($player->getName()); @@ -1549,8 +1558,8 @@ public function checkPlayerFlying(Player $player){ if( !$area->getFlag("msg") ){ $sendmsg = true; } - if( $area->getFlag("nofalldamage") ){ - $nofalldamage = true; + if( $area->getFlag("falldamage") ){ + $falldamage = true; } } } @@ -1563,7 +1572,7 @@ public function checkPlayerFlying(Player $player){ } $msg = ''; if( !$fly && $player->isFlying() ){ - if( $nofalldamage ){ + if( $falldamage ){ $this->playerTP[ strtolower( $player->getName() ) ] = true; // player tp active (fall save) } $player->setFlying(false); From 1ab6159deb72c5be94b58a0f9010ebb1c295794b Mon Sep 17 00:00:00 2001 From: genboy Date: Wed, 22 Aug 2018 01:06:52 +0200 Subject: [PATCH 18/68] Code fix on flag default check (rule order) --- src/genboy/Festival/Main.php | 70 ++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index bd28b02..f3415b8 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -601,7 +601,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $cz = $area->getSecondPosition()->getZ() + ( ( $area->getFirstPosition()->getZ() - $area->getSecondPosition()->getZ() ) / 2 ); $cy1 = min( $area->getSecondPosition()->getY(), $area->getFirstPosition()->getY()); $cy2 = max( $area->getSecondPosition()->getY(), $area->getFirstPosition()->getY()); - if( $this->hasNoFallDamage($sender) ){ + if( !$this->hasFallDamage($sender) ){ $this->playerTP[$playerName] = true; // player tp active $this->areaMessage( 'Fall save on!', $sender ); } $sender->teleport( new Position( $cx, $cy2 - 2, $cz, $area->getLevel() ) ); @@ -1025,8 +1025,8 @@ public function onQuit(PlayerQuitEvent $event){ public function canGetHurt(Entity $entity) : bool{ $o = true; if( $entity instanceof Player){ - $default = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["God"] : $this->god); - if($default){ + $g = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["God"] : $this->god); + if($g){ $o = false; } $playername = strtolower($entity->getName()); @@ -1036,6 +1036,9 @@ public function canGetHurt(Entity $entity) : bool{ if($area->getFlag("god")){ $o = false; } + if(!$area->getFlag("god") && $g ){ + $o = true; + } if($area->isWhitelisted($playername)){ $o = false; } @@ -1067,6 +1070,9 @@ public function canPVP(EntityDamageEvent $ev) : bool{ if($area->getFlag("pvp")){ $o = false; } + if( !$area->getFlag("pvp") && $p){ + $o = true; + } if($area->isWhitelisted($playername)){ $o = false; } @@ -1126,7 +1132,7 @@ public function canDamage(EntityDamageEvent $ev) : bool{ * * @return bool */ - public function hasNoFallDamage(Entity $entity) : bool{ + public function hasFallDamage(Entity $entity) : bool{ $o = true; if( $entity instanceof Player ){ @@ -1141,6 +1147,9 @@ public function hasNoFallDamage(Entity $entity) : bool{ if($area->getFlag("falldamage")){ $o = false; } + if(!$area->getFlag("falldamage") && $f){ + $o = true; + } if($area->isWhitelisted($playername)){ $o = false; } @@ -1188,6 +1197,9 @@ public function canEdit(Player $player, Position $position) : bool{ if($area->getFlag("edit")){ $o = false; } + if(!$area->getFlag("edit") && $e){ + $o = true; + } if($area->isWhitelisted($playername)){ $o = true; } @@ -1217,6 +1229,9 @@ public function canTouch(Player $player, Position $position) : bool{ if($area->getFlag("touch")){ $o = false; } + if(!$area->getFlag("touch") && $t){ + $o = true; + } if($area->isWhitelisted($playername)){ $o = true; } @@ -1260,8 +1275,8 @@ public function canHunger( PlayerExhaustEvent $event ): bool{ $pos = $event->getPlayer()->getPosition(); $playername = strtolower($event->getPlayer()->getName()); $o = true; - $g = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Hunger"] : $this->hunger); - if ($g) { + $h = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Hunger"] : $this->hunger); + if ($h) { $o = false; } foreach($this->inArea[$playername] as $areaname){ @@ -1270,6 +1285,9 @@ public function canHunger( PlayerExhaustEvent $event ): bool{ if ($area->getFlag("hunger")) { $o = false; } + if(!$area->getFlag("hunger") && $h){ + $o = true; + } if($area->isWhitelisted($playername)){ $o = false; } @@ -1299,8 +1317,8 @@ public function onEntityExplode(EntityExplodeEvent $event){ */ 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) { + $e = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["TNT"] : $this->tnt); + if ($e) { $o = false; } // including entities/mobs in any area @@ -1309,6 +1327,9 @@ public function canExplode( Position $pos ): bool{ if ($area->getFlag("tnt")) { $o = false; } + if(!$area->getFlag("tnt") && $e){ + $o = true; + } if (!$area->getFlag("tnt") && $g) { $o = true; } @@ -1342,8 +1363,8 @@ public function canDrop(Player $player, Position $position) : bool{ return true; } $o = true; - $g = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Drop"] : $this->drop); - if($g){ + $d = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Drop"] : $this->drop); + if($d){ $o = false; } $playername = strtolower($player->getName()); @@ -1353,6 +1374,9 @@ public function canDrop(Player $player, Position $position) : bool{ if($area->getFlag("drop")){ $o = false; } + if(!$area->getFlag("drop") && $d){ + $o = true; + } if($area->isWhitelisted($playername)){ $o = true; } @@ -1390,8 +1414,8 @@ public function canShoot( Player $player ) : bool{ $playername = strtolower($player->getName()); $o = true; $m = true; - $g = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Shoot"] : $this->shoot); - if($g){ + $s = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Shoot"] : $this->shoot); + if($s){ $o = false; } @@ -1401,6 +1425,9 @@ public function canShoot( Player $player ) : bool{ if($area->getFlag("shoot")){ $o = false; } + if(!$area->getFlag("shoot") && $s){ + $o = true; + } if($area->isWhitelisted($playername)){ $o = true; } @@ -1481,13 +1508,16 @@ public function useOpPerms(Player $player, Area $area) : bool{ $position = $player->getPosition(); $o = true; - $g = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[ $position->getLevel()->getName() ]["Perms"] : $this->perms); - if($g){ + $p = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[ $position->getLevel()->getName() ]["Perms"] : $this->perms); + if($p){ $o = false; } if( $area->getFlag("perms") ){ $o = false; } + if(!$area->getFlag("perms") && $p){ + $o = true; + } if( $area->isWhitelisted( strtolower( $player->getName() ) ) ){ $o = true; } @@ -1509,8 +1539,8 @@ public function canUseEffects( Player $player ) : bool{ $position = $player->getPosition(); $playername = strtolower($player->getName()); $o = true; - $g = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Effects"] : $this->effects); - if($g){ + $e = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Effects"] : $this->effects); + if($e){ $o = false; } @@ -1520,6 +1550,9 @@ public function canUseEffects( Player $player ) : bool{ if($area->getFlag("effects")){ $o = false; } + if(!$area->getFlag("effects") && $e){ + $o = true; + } if( $area->isWhitelisted( $playername ) ){ $o = true; } @@ -1552,7 +1585,8 @@ public function checkPlayerFlying(Player $player){ $area = $this->areaList[$areaname]; if( $area->getFlag("flight") && !$area->isWhitelisted( $playername ) ){ $fly = false; // flag area - }else{ + } + if(!$area->getFlag("flight") && $f){ $fly = true; } if( !$area->getFlag("msg") ){ @@ -2045,7 +2079,7 @@ public function onFallDisable(EntityDamageEvent $event) : void{ if(!$this->canGetHurt($player)){ $event->setCancelled(); } - if($cause == EntityDamageEvent::CAUSE_FALL && !$this->hasNoFallDamage($player)){ + if($cause == EntityDamageEvent::CAUSE_FALL && $this->hasFallDamage($player)){ $event->setCancelled(true); } } From dc8acca0e9091cb65517f4598939f23b46ddb453 Mon Sep 17 00:00:00 2001 From: genboy Date: Wed, 22 Aug 2018 01:39:15 +0200 Subject: [PATCH 19/68] dev update --- plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.yml b/plugin.yml index a89276d..cd44e62 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: Festival author: Genboy -version: 1.0.7.3-dev +version: 1.0.7.4-dev main: genboy\Festival\Main load: POSTWORLD api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0] From ae23bf48fb13ce2bf5b2b4236f36deae41e33dda Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 26 Aug 2018 00:48:27 +0200 Subject: [PATCH 20/68] buggy test Mobs/spawn flag --- resources/config.yml | 9 +++++ src/genboy/Festival/Main.php | 77 +++++++++++++++++++++++++++++++++--- 2 files changed, 80 insertions(+), 6 deletions(-) diff --git a/resources/config.yml b/resources/config.yml index ddd5b8b..72ee213 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -32,6 +32,9 @@ Default: # Keep players from touching blocks and activating things like chests? (true = NoTouching) Touch: false + # Keep Entities from spawning? (true = NoMobs) + Mobs: false + # Keep players from having effects like speed or night vision? (true = NoEffects) Effects: false @@ -80,6 +83,9 @@ Worlds: # Keep players from touching blocks and activating things like chests? (true = NoTouching) Touch: false + # Keep Entities from spawning? (true = NoMobs) + Mobs: false + # Keep players from having effects like speed or night vision? (true = NoEffects) Effects: false @@ -124,6 +130,9 @@ Worlds: # Keep players from touching blocks and activating things like chests? (true = NoTouching) Touch: false + # Keep Entities from spawning? (true = NoMobs) + Mobs: false + # Keep players from having effects like speed or night vision? (true = NoEffects) Effects: false diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index f3415b8..0def850 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -11,6 +11,8 @@ use pocketmine\entity\Entity; use pocketmine\event\block\BlockBreakEvent; use pocketmine\event\block\BlockPlaceEvent; +use pocketmine\event\entity\EntitySpawnEvent; +use pocketmine\event\entity\EntityDespawnEvent; use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\event\entity\EntityExplodeEvent; @@ -51,6 +53,8 @@ class Main extends PluginBase implements Listener{ /** @var bool */ private $touch = false; /** @var bool */ + private $mobs = false; + /** @var bool */ private $effects = false; /** @var bool */ private $msg = false; @@ -134,6 +138,10 @@ public function onEnable() : void{ $flags["drop"] = false; $newchange['Drop'] = "! Area Drop flag missing, now updated to 'false'; please see /resources/config.yml"; } + if( !isset($datum["flags"]["mobs"]) ){ // new flags v 1.0.7.4 + $flags["mobs"] = false; + $newchange['Mobs'] = "! Area Mobs flag missing, now updated to 'false'; please see /resources/config.yml"; + } if( !isset($datum["flags"]["effects"]) ){ // new flags v 1.0.5-12 $flags["effects"] = false; $newchange['Effects'] = "! Area Effects flag missing, now updated to 'false'; please see /resources/config.yml"; @@ -217,6 +225,9 @@ public function onEnable() : void{ if(!isset($c["Default"]["Drop"])) { // new in v1.0.4-11 $c["Default"]["Drop"] = false; } + if(!isset($c["Default"]["Mobs"])) { // new in v1.0.7.4 + $c["Default"]["Mobs"] = false; + } if(!isset($c["Default"]["Effects"])) { // new in v1.0.5-12 $c["Default"]["Effects"] = false; } @@ -246,6 +257,7 @@ public function onEnable() : void{ $this->passage = $c["Default"]["Passage"]; // changed in v1.0.3-11 $this->perms = $c["Default"]["Perms"]; // new in v1.0.4-11 $this->drop = $c["Default"]["Drop"]; // new in v1.0.4-11 + $this->mobs = $c["Default"]["Mobs"]; // new in v1.0.7.4-dev(1.0.8) $this->effects = $c["Default"]["Effects"]; // new in v1.0.5-12 $this->pvp = $c["Default"]["PVP"]; // new in v1.0.6-13 $this->flight = $c["Default"]["Flight"]; // new in v1.0.6-13 @@ -272,6 +284,9 @@ public function onEnable() : void{ if( !isset($flags["Drop"]) ){ // new v1.0.4-11 $flags["Drop"] = $this->drop; } + if( !isset($flags["Mobs"]) ){ // new v1.0.7.4 + $flags["Mobs"] = $this->effects; + } if( !isset($flags["Effects"]) ){ // new v1.0.5-12 $flags["Effects"] = $this->effects; } @@ -326,6 +341,7 @@ public function isFlag( $str ){ "flight", "fly", "edit","build","break","place", "touch","interact", + "mobs","mob","spawn", "effects","magic","effect", "tnt","explode", "hunger","starve", @@ -349,9 +365,12 @@ public function isFlag( $str ){ if( $str == "build" || $str == "break" || $str == "place" ){ $flag = "edit"; } - if( $str == "interact" ){ + if( $str == "touch" || $str == "interact" ){ $flag = "touch"; } + if( $str == "mob" || $str == "mobs" || $str == "spawn" ){ + $flag = "mobs"; + } if( $str == "magic" || $str == "effect" ){ $flag = "effects"; } @@ -453,6 +472,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar "pvp" => $flags["PVP"], "flight"=> $flags["Flight"], "touch" => $flags['Touch'], + "mobs" => $flags['Mobs'], "effects" => $flags['Effects'], "msg" => $flags['Msg'], "passage" => $flags['Passage'], @@ -623,6 +643,9 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "pvp": case "flight": case "fly": + case "mob": + case "mobs": + case "spawn": case "effect": case "effects": case "edit": @@ -726,10 +749,10 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } $o = TextFormat::GREEN . "Flag " . $flag . " set to " . $status . " for area " . $area->getName() . "!"; }else{ - $o = TextFormat::RED . "Flag not found. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; + $o = TextFormat::RED . "Flag not found. (Flags: god, pvp, flight, edit, touch, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; } }else{ - $o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; + $o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; } } }else{ @@ -1330,9 +1353,6 @@ public function canExplode( Position $pos ): bool{ if(!$area->getFlag("tnt") && $e){ $o = true; } - if (!$area->getFlag("tnt") && $g) { - $o = true; - } } } return $o; @@ -1445,6 +1465,51 @@ public function canShoot( Player $player ) : bool{ } + /** Mob spawning + * @param EntitySpawnEvent $event + * @ignoreCancelled true + */ + public function onEntitySpawn( EntitySpawnEvent $event ): void{ + + $e = $event->getEntity(); + if( !$e instanceof Player && !$this->canEntitySpawn( $e ) ){ + + $e->flagForDespawn(); + // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Entity.php + + //$this->getServer()->getPluginManager()->callEvent(new EntityDespawnEvent($e)); + //$e->close(); + //$event->setCancelled(); + //EntityDespawnEvent(Entity $entity) + } + + } + + public function canEntitySpawn( Entity $e ): bool{ + + $o = true; + $pos = $e->getPosition(); + $m = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Mobs"] : $this->mobs); + if ($m) { + $o = false; + } + // including entities/mobs in any area + foreach ($this->areas as $area) { + if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { + if ($area->getFlag("mobs")) { + $o = false; + } + if(!$area->getFlag("mobs") && $m){ + $o = true; + } + } + } + return $o; + } + + + + /** Block Place * @param BlockPlaceEvent $event * @ignoreCancelled true From 88668ac3247eea19827217fb206f5e1f5c40b882 Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 26 Aug 2018 13:13:56 +0200 Subject: [PATCH 21/68] No mobs flag - no spawning test2: allow leaving droppings & Exporbs --- src/genboy/Festival/Main.php | 48 +++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 0def850..72c79ee 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -9,6 +9,9 @@ use pocketmine\command\CommandSender; use pocketmine\command\ConsoleCommandSender; use pocketmine\entity\Entity; +use pocketmine\entity\object\ExperienceOrb; +use pocketmine\entity\object\ItemEntity; + use pocketmine\event\block\BlockBreakEvent; use pocketmine\event\block\BlockPlaceEvent; use pocketmine\event\entity\EntitySpawnEvent; @@ -1488,23 +1491,44 @@ public function onEntitySpawn( EntitySpawnEvent $event ): void{ public function canEntitySpawn( Entity $e ): bool{ $o = true; - $pos = $e->getPosition(); - $m = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Mobs"] : $this->mobs); - if ($m) { - $o = false; + $pos = false; + + // Is entity a mob (animal = animmal flag, allow non living) + if( $e instanceof ExperienceOrb || $e instanceof ItemEntity){ + return $o; // non living } - // including entities/mobs in any area - foreach ($this->areas as $area) { - if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { - if ($area->getFlag("mobs")) { - $o = false; - } - if(!$area->getFlag("mobs") && $m){ - $o = true; + + if( null !== $e->getPosition() ){ + $pos = $e->getPosition(); + } + + $nm = 'unknown'; + if( null !== $e->getName() ){ + $nm = $e->getName(); + } + //$this->getLogger()->info( 'Spawn: '.$nm ); + if($pos){ + $m = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Mobs"] : $this->mobs); + if ($m) { + $o = false; + } + foreach ($this->areas as $area) { + if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { + + + if ($area->getFlag("mobs")) { + $o = false; + } + if(!$area->getFlag("mobs") && $m){ + $o = true; + } } } } return $o; + + // https://forums.pmmp.io/threads/mobs-spawn-event.6151/ + // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Entity.php } From 7ee5eb675a08d4f6b0dc4ba7f0e470577e0476cd Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 26 Aug 2018 15:24:55 +0200 Subject: [PATCH 22/68] Animals flag and Mobs flag testing --- src/genboy/Festival/Main.php | 119 ++++++++++++++++++++++++----------- 1 file changed, 81 insertions(+), 38 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 72c79ee..a11d9cc 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -58,6 +58,8 @@ class Main extends PluginBase implements Listener{ /** @var bool */ private $mobs = false; /** @var bool */ + private $animals = false; + /** @var bool */ private $effects = false; /** @var bool */ private $msg = false; @@ -141,6 +143,10 @@ public function onEnable() : void{ $flags["drop"] = false; $newchange['Drop'] = "! Area Drop flag missing, now updated to 'false'; please see /resources/config.yml"; } + if( !isset($datum["flags"]["animals"]) ){ // new flags v 1.0.7.4 + $flags["animals"] = false; + $newchange['Animals'] = "! Area Animals flag missing, now updated to 'false'; please see /resources/config.yml"; + } if( !isset($datum["flags"]["mobs"]) ){ // new flags v 1.0.7.4 $flags["mobs"] = false; $newchange['Mobs'] = "! Area Mobs flag missing, now updated to 'false'; please see /resources/config.yml"; @@ -228,6 +234,9 @@ public function onEnable() : void{ if(!isset($c["Default"]["Drop"])) { // new in v1.0.4-11 $c["Default"]["Drop"] = false; } + if(!isset($c["Default"]["Animals"])) { // new in v1.0.7.4 + $c["Default"]["Animals"] = false; + } if(!isset($c["Default"]["Mobs"])) { // new in v1.0.7.4 $c["Default"]["Mobs"] = false; } @@ -260,7 +269,8 @@ public function onEnable() : void{ $this->passage = $c["Default"]["Passage"]; // changed in v1.0.3-11 $this->perms = $c["Default"]["Perms"]; // new in v1.0.4-11 $this->drop = $c["Default"]["Drop"]; // new in v1.0.4-11 - $this->mobs = $c["Default"]["Mobs"]; // new in v1.0.7.4-dev(1.0.8) + $this->animals = $c["Default"]["Animals"]; // new in v1.0.7.5-dev(1.0.8) + $this->mobs = $c["Default"]["Mobs"]; // new in v1.0.7.5-dev(1.0.8) $this->effects = $c["Default"]["Effects"]; // new in v1.0.5-12 $this->pvp = $c["Default"]["PVP"]; // new in v1.0.6-13 $this->flight = $c["Default"]["Flight"]; // new in v1.0.6-13 @@ -287,7 +297,10 @@ public function onEnable() : void{ if( !isset($flags["Drop"]) ){ // new v1.0.4-11 $flags["Drop"] = $this->drop; } - if( !isset($flags["Mobs"]) ){ // new v1.0.7.4 + if( !isset($flags["Animals"]) ){ // new v1.0.7.5 + $flags["Animals"] = $this->animals; + } + if( !isset($flags["Mobs"]) ){ // new v1.0.7.5 $flags["Mobs"] = $this->effects; } if( !isset($flags["Effects"]) ){ // new v1.0.5-12 @@ -344,7 +357,8 @@ public function isFlag( $str ){ "flight", "fly", "edit","build","break","place", "touch","interact", - "mobs","mob","spawn", + "mobs","mob", + "animals","animal", "effects","magic","effect", "tnt","explode", "hunger","starve", @@ -371,7 +385,10 @@ public function isFlag( $str ){ if( $str == "touch" || $str == "interact" ){ $flag = "touch"; } - if( $str == "mob" || $str == "mobs" || $str == "spawn" ){ + if( $str == "animals" || $str == "animal" ){ + $flag = "animals"; + } + if( $str == "mob" || $str == "mobs" ){ $flag = "mobs"; } if( $str == "magic" || $str == "effect" ){ @@ -475,6 +492,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar "pvp" => $flags["PVP"], "flight"=> $flags["Flight"], "touch" => $flags['Touch'], + "animals" => $flags['Animals'], "mobs" => $flags['Mobs'], "effects" => $flags['Effects'], "msg" => $flags['Msg'], @@ -646,9 +664,10 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "pvp": case "flight": case "fly": + case "animal": + case "animals": case "mob": case "mobs": - case "spawn": case "effect": case "effects": case "edit": @@ -752,10 +771,10 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } $o = TextFormat::GREEN . "Flag " . $flag . " set to " . $status . " for area " . $area->getName() . "!"; }else{ - $o = TextFormat::RED . "Flag not found. (Flags: god, pvp, flight, edit, touch, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; + $o = TextFormat::RED . "Flag not found. (Flags: god, pvp, flight, edit, touch, animals, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; } }else{ - $o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; + $o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, animals, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; } } }else{ @@ -1473,62 +1492,86 @@ public function canShoot( Player $player ) : bool{ * @ignoreCancelled true */ public function onEntitySpawn( EntitySpawnEvent $event ): void{ - $e = $event->getEntity(); if( !$e instanceof Player && !$this->canEntitySpawn( $e ) ){ - $e->flagForDespawn(); - // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Entity.php - - //$this->getServer()->getPluginManager()->callEvent(new EntityDespawnEvent($e)); - //$e->close(); - //$event->setCancelled(); - //EntityDespawnEvent(Entity $entity) } - } public function canEntitySpawn( Entity $e ): bool{ $o = true; - $pos = false; - // Is entity a mob (animal = animmal flag, allow non living) - if( $e instanceof ExperienceOrb || $e instanceof ItemEntity){ - return $o; // non living - } - - if( null !== $e->getPosition() ){ - $pos = $e->getPosition(); + if( $e instanceof ExperienceOrb || $e instanceof ItemEntity ){ + return $o; // allowed } $nm = 'unknown'; if( null !== $e->getName() ){ - $nm = $e->getName(); + $nm = $e->getName(); } - //$this->getLogger()->info( 'Spawn: '.$nm ); - if($pos){ - $m = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Mobs"] : $this->mobs); - if ($m) { - $o = false; - } - foreach ($this->areas as $area) { - if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { - - if ($area->getFlag("mobs")) { - $o = false; + $pos = false; + if( null !== $e->getPosition() ){ + $pos = $e->getPosition(); + } + if($pos && $nm != 'unknown'){ + // should extend - taken from PureEntitiesX + // animals bat,chicken,cow,horse,ocelot,parrot,pig,rabbit,sheep + // mobs blaze,cavespider,spider,creeper,enderman,ghast,irongolem,magmacube,pigzombie,skeleton,slime,spider,wolf,zombie + $animals = [ 'bat','chicken','cow','horse','ocelot','parrot','pig','rabbit','sheep']; + if( in_array( strtolower($nm), $animals ) ){ + // check animal flag + // check mob flag + $a = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Animals"] : $this->animals); + if ($a) { + $o = false; + } + foreach ($this->areas as $area) { + if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { + if ($area->getFlag("animals")) { + $o = false; + } + if(!$area->getFlag("animals") && $a){ + $o = true; + } } - if(!$area->getFlag("mobs") && $m){ - $o = true; + } + }else{ + // check mob flag + $m = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Mobs"] : $this->mobs); + if ($m) { + $o = false; + } + foreach ($this->areas as $area) { + if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { + + if ($area->getFlag("mobs")) { + $o = false; + } + if(!$area->getFlag("mobs") && $m){ + $o = true; + } } } } } + /* + if($o){ + $this->getLogger()->info( 'Spawn '.$nm.' entity allowed' ); + }else{ + $this->getLogger()->info( 'Spawn '.$nm.' entity canceled' ); + } + */ return $o; // https://forums.pmmp.io/threads/mobs-spawn-event.6151/ // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Entity.php + //$this->getServer()->getPluginManager()->callEvent(new EntityDespawnEvent($e)); + //$e->close(); + //$event->setCancelled(); + //EntityDespawnEvent(Entity $entity) + } From ae580be1a91e91f950290ae0e5c8865b560f49cc Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 26 Aug 2018 15:44:31 +0200 Subject: [PATCH 23/68] Mobs & Animals Flags dev take1 --- resources/config.yml | 15 ++++++++++++--- src/genboy/Festival/Main.php | 12 ++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/resources/config.yml b/resources/config.yml index 72ee213..c1be134 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -32,7 +32,10 @@ Default: # Keep players from touching blocks and activating things like chests? (true = NoTouching) Touch: false - # Keep Entities from spawning? (true = NoMobs) + # Prevent Animal Entities from spawning? (true = NoAnimals) + Animals: false + + # Prevent Mob Entities from spawning? (true = NoMobs) Mobs: false # Keep players from having effects like speed or night vision? (true = NoEffects) @@ -83,7 +86,10 @@ Worlds: # Keep players from touching blocks and activating things like chests? (true = NoTouching) Touch: false - # Keep Entities from spawning? (true = NoMobs) + # Prevent Animal Entities from spawning? (true = NoAnimals) + Animals: false + + # Prevent Mob Entities from spawning? (true = NoMobs) Mobs: false # Keep players from having effects like speed or night vision? (true = NoEffects) @@ -130,7 +136,10 @@ Worlds: # Keep players from touching blocks and activating things like chests? (true = NoTouching) Touch: false - # Keep Entities from spawning? (true = NoMobs) + # Prevent Animal Entities from spawning? (true = NoAnimals) + Animals: false + + # Prevent Mob Entities from spawning? (true = NoMobs) Mobs: false # Keep players from having effects like speed or night vision? (true = NoEffects) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index a11d9cc..5e32d74 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1517,9 +1517,14 @@ public function canEntitySpawn( Entity $e ): bool{ } if($pos && $nm != 'unknown'){ // should extend - taken from PureEntitiesX - // animals bat,chicken,cow,horse,ocelot,parrot,pig,rabbit,sheep + // animals bat,chicken,cow,horse,squit,ocelot,parrot,pig,rabbit,sheep // mobs blaze,cavespider,spider,creeper,enderman,ghast,irongolem,magmacube,pigzombie,skeleton,slime,spider,wolf,zombie - $animals = [ 'bat','chicken','cow','horse','ocelot','parrot','pig','rabbit','sheep']; + + // see pocketmine enitities id's + //https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/EntityIds.php + + $animals = [ 'bat','chicken','cow','horse','donkey','mule','ocelot','parrot','fish','dolphin','squit','pig','rabbit','sheep','pufferfish','salmon','tropical_fish','balloon']; + if( in_array( strtolower($nm), $animals ) ){ // check animal flag // check mob flag @@ -1567,6 +1572,9 @@ public function canEntitySpawn( Entity $e ): bool{ // https://forums.pmmp.io/threads/mobs-spawn-event.6151/ // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Entity.php + // https://github.com/LeinneSW/EntityManager + //https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/EntityIds.php + //$this->getServer()->getPluginManager()->callEvent(new EntityDespawnEvent($e)); //$e->close(); //$event->setCancelled(); From 6e2427f0199c2c5d252571d6f943f5bf88d8f585 Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 26 Aug 2018 16:01:32 +0200 Subject: [PATCH 24/68] Dev Test version --- plugin.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.yml b/plugin.yml index cd44e62..f961209 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,9 +1,9 @@ name: Festival author: Genboy -version: 1.0.7.4-dev +version: 1.0.7.5-dev main: genboy\Festival\Main load: POSTWORLD -api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0] +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: From a6970001545d8ba795bc70c1a0929890ccea293a Mon Sep 17 00:00:00 2001 From: genboy Date: Mon, 27 Aug 2018 02:10:53 +0200 Subject: [PATCH 25/68] entity quick & clean remove --- src/genboy/Festival/Main.php | 64 +++++++++++++++--------------------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 5e32d74..a2a759e 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -9,9 +9,11 @@ use pocketmine\command\CommandSender; use pocketmine\command\ConsoleCommandSender; use pocketmine\entity\Entity; +use pocketmine\entity\Item; use pocketmine\entity\object\ExperienceOrb; use pocketmine\entity\object\ItemEntity; - +use pocketmine\entity\projectile\Arrow; +use pocketmine\entity\projectile\Projectile; use pocketmine\event\block\BlockBreakEvent; use pocketmine\event\block\BlockPlaceEvent; use pocketmine\event\entity\EntitySpawnEvent; @@ -58,7 +60,7 @@ class Main extends PluginBase implements Listener{ /** @var bool */ private $mobs = false; /** @var bool */ - private $animals = false; + private $animals = false; /** @var bool */ private $effects = false; /** @var bool */ @@ -72,7 +74,7 @@ class Main extends PluginBase implements Listener{ /** @var bool */ private $shoot = false; /** @var bool */ - private $hunger = false; + private $hunger = false; /** @var bool */ private $perms = false; /** @var bool */ @@ -1494,40 +1496,45 @@ public function canShoot( Player $player ) : bool{ public function onEntitySpawn( EntitySpawnEvent $event ): void{ $e = $event->getEntity(); if( !$e instanceof Player && !$this->canEntitySpawn( $e ) ){ - $e->flagForDespawn(); + //$e->flagForDespawn() to slow / ? $e->close(); private.. + $this->getServer()->getPluginManager()->callEvent(new EntityDespawnEvent($e)); + $e->despawnFromAll(); + if($e->chunk !== null){ + $e->chunk->removeEntity($e); + $e->chunk = null; + } + if($e->isValid()){ + $e->level->removeEntity($e); + $e->setLevel(null); + } } } public function canEntitySpawn( Entity $e ): bool{ + // see pocketmine & PureEntitiesX enitities id's + // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/EntityIds.php + // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Entity.php + // https://forums.pmmp.io/threads/mobs-spawn-event.6151/ + // https://github.com/LeinneSW/EntityManager $o = true; - - if( $e instanceof ExperienceOrb || $e instanceof ItemEntity ){ + if( $e instanceof ExperienceOrb || $e instanceof ItemEntity || $e instanceof Projectile){ return $o; // allowed } - - $nm = 'unknown'; + $nm = 'unknown'; // $nm = $e instanceof Item ? $e->getItem()->getName() : $e->getName(); if( null !== $e->getName() ){ $nm = $e->getName(); } - $pos = false; if( null !== $e->getPosition() ){ $pos = $e->getPosition(); } if($pos && $nm != 'unknown'){ - // should extend - taken from PureEntitiesX - // animals bat,chicken,cow,horse,squit,ocelot,parrot,pig,rabbit,sheep - // mobs blaze,cavespider,spider,creeper,enderman,ghast,irongolem,magmacube,pigzombie,skeleton,slime,spider,wolf,zombie - // see pocketmine enitities id's - //https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/EntityIds.php - - $animals = [ 'bat','chicken','cow','horse','donkey','mule','ocelot','parrot','fish','dolphin','squit','pig','rabbit','sheep','pufferfish','salmon','tropical_fish','balloon']; + $animals =[ 'bat','chicken','cow','horse','donkey','mule','ocelot','parrot','fish','dolphin','squit','pig','rabbit','sheep','pufferfish','salmon','tropical_fish','balloon']; if( in_array( strtolower($nm), $animals ) ){ // check animal flag - // check mob flag $a = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Animals"] : $this->animals); if ($a) { $o = false; @@ -1561,30 +1568,14 @@ public function canEntitySpawn( Entity $e ): bool{ } } } - /* - if($o){ + /* if($o){ $this->getLogger()->info( 'Spawn '.$nm.' entity allowed' ); }else{ $this->getLogger()->info( 'Spawn '.$nm.' entity canceled' ); - } - */ + } */ return $o; - - // https://forums.pmmp.io/threads/mobs-spawn-event.6151/ - // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Entity.php - // https://github.com/LeinneSW/EntityManager - //https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/EntityIds.php - - //$this->getServer()->getPluginManager()->callEvent(new EntityDespawnEvent($e)); - //$e->close(); - //$event->setCancelled(); - //EntityDespawnEvent(Entity $entity) - } - - - /** Block Place * @param BlockPlaceEvent $event * @ignoreCancelled true @@ -1664,8 +1655,6 @@ public function useOpPerms(Player $player, Area $area) : bool{ return $o; } - - /** Effects * @param Player $player * @return bool @@ -1703,7 +1692,6 @@ public function canUseEffects( Player $player ) : bool{ } - /** Flight * @param Player $player */ From dcd23801a01cbd04f89f6f310ac8bb756a9f1b85 Mon Sep 17 00:00:00 2001 From: genboy Date: Wed, 29 Aug 2018 19:34:53 +0200 Subject: [PATCH 26/68] edit flag now includes farm land and item frame (touch) events --- src/genboy/Festival/Main.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index a2a759e..c4b7552 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -236,10 +236,10 @@ public function onEnable() : void{ if(!isset($c["Default"]["Drop"])) { // new in v1.0.4-11 $c["Default"]["Drop"] = false; } - if(!isset($c["Default"]["Animals"])) { // new in v1.0.7.4 + if(!isset($c["Default"]["Animals"])) { // new in v1.0.7.5 $c["Default"]["Animals"] = false; } - if(!isset($c["Default"]["Mobs"])) { // new in v1.0.7.4 + if(!isset($c["Default"]["Mobs"])) { // new in v1.0.7.5 $c["Default"]["Mobs"] = false; } if(!isset($c["Default"]["Effects"])) { // new in v1.0.5-12 @@ -261,7 +261,7 @@ public function onEnable() : void{ $c["Default"]["Hunger"] = false; } if(!isset($c["Default"]["FallDamage"])) { - $c["Default"]["FallDamage"] = false; // new in v1.0.8 + $c["Default"]["FallDamage"] = false; // new in v1.0.7.3 } $this->god = $c["Default"]["God"]; @@ -276,8 +276,8 @@ public function onEnable() : void{ $this->effects = $c["Default"]["Effects"]; // new in v1.0.5-12 $this->pvp = $c["Default"]["PVP"]; // new in v1.0.6-13 $this->flight = $c["Default"]["Flight"]; // new in v1.0.6-13 - $this->tnt = $c["Default"]["TNT"]; // new in v1.0.7 - $this->hunger = $c["Default"]["Hunger"]; // new in v1.0.7 + $this->tnt = $c["Default"]["TNT"]; // new in v1.0.7.3 + $this->hunger = $c["Default"]["Hunger"]; // new in v1.0.7.3 $this->falldamage = $c["Default"]["FallDamage"]; // new in 1.0.7.2-dev(1.0.8) $this->shoot = $c["Default"]["Shoot"]; // new in 1.0.7.2-dev(1.0.8) @@ -1294,6 +1294,22 @@ public function canTouch(Player $player, Position $position) : bool{ public function onBlockTouch(PlayerInteractEvent $event) : void{ $block = $event->getBlock(); $player = $event->getPlayer(); + $item = $event->getItem(); + + //$player->sendMessage("TOUCHED " . $block->getName() . "(". $block->getID() . ") with ". $item->getName() ."(".$item->getID().") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"); + + // touch & block events controlled by edit flag + $b = $block->getID(); + $i = $item->getID(); + if( + ( $b == 199 ) // item frame + || ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) // no farm event + ){ + if(!$this->canEdit($player, $block)){ + $event->setCancelled(); + } + } + if(!$this->canTouch($player, $block)){ $event->setCancelled(); } From 1a97c1a4b6396a64fabc905abebe27d9f5eb2c81 Mon Sep 17 00:00:00 2001 From: genboy Date: Fri, 31 Aug 2018 22:40:36 +0200 Subject: [PATCH 27/68] info #_# --- README.md | 15 +++++++++------ src/genboy/Festival/Main.php | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 0120209..595f9e5 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ Create a festival with this custom area events plugin for Pocketmine Server: - 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. + - animals: no animal spawning (including spawners & eggs) + - mobs: no mobs spawning (including spawners & eggs) - 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) @@ -60,7 +62,7 @@ Create a festival with this custom area events plugin for Pocketmine Server: - shoot: player can not shoot (bow) - perms: player permissions are used to determine area command execution (experiment) - hunger: player does not exhaust / hunger - - nfd: player will not have fall damage (no fall damage) + - falldamage: player will not have fall damage (no fall damage) **Events & Commands** @@ -69,7 +71,8 @@ Create a festival with this custom area events plugin for Pocketmine Server: - assign commands to area events - enter, center or leave. - - add/edit/delete area event commands + - variable player in commands with {player} or @p + - add/edit/delete area event command - list area commands (ordered by event) - change event of area commands @@ -95,7 +98,7 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). ### Install & Configure - - Standard Plugin installation; Upload .phar file (or .zip if you have latest devtools installed), restart the server, go to folder plugins/Festival; + - Standard Plugin installation; Upload .phar file to server 'plugin' folder (or upload .zip if you have latest devtools installed), restart the server, go to folder plugins/Festival; - Edit config.yml; set the defaults for options, default area flags and the default area flags for specific worlds. @@ -139,9 +142,9 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). - new Hunger flag - Fire is now extinguished when player does not get damage (aka. in area with god flag on) - new shoot flag (experimental no shooting/launching) - - new nofalldamage flag (nfd) - - + - new falldamage flag + - new animals and mobs (spawning) flag + - Fixes itemframe and farmland edit #### Usage Graphic diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index c4b7552..3ae4dea 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -111,9 +111,8 @@ class Main extends PluginBase implements Listener{ */ public function onEnable() : void{ - // Load data & configurations + $this->getServer()->getPluginManager()->registerEvents($this, $this); // Load data & configurations $newchange = []; // list of missing config flags/options - $this->getServer()->getPluginManager()->registerEvents($this, $this); if(!is_dir($this->getDataFolder())){ mkdir($this->getDataFolder()); } @@ -145,11 +144,11 @@ public function onEnable() : void{ $flags["drop"] = false; $newchange['Drop'] = "! Area Drop flag missing, now updated to 'false'; please see /resources/config.yml"; } - if( !isset($datum["flags"]["animals"]) ){ // new flags v 1.0.7.4 + if( !isset($datum["flags"]["animals"]) ){ // new flags v 1.0.7.5-dev $flags["animals"] = false; $newchange['Animals'] = "! Area Animals flag missing, now updated to 'false'; please see /resources/config.yml"; } - if( !isset($datum["flags"]["mobs"]) ){ // new flags v 1.0.7.4 + if( !isset($datum["flags"]["mobs"]) ){ // new flags v 1.0.7.5-dev $flags["mobs"] = false; $newchange['Mobs'] = "! Area Mobs flag missing, now updated to 'false'; please see /resources/config.yml"; } @@ -178,11 +177,11 @@ public function onEnable() : void{ unset($flags["nofalldamage"]); $newchange['FallDamage'] = "! Old NoFallDamage config was used, now set to 'false'; please rename 'NoFallDamage' to 'FallDamage' in config.yml"; } - if( !isset($datum["flags"]["falldamage"]) ){ //new in v1.0.7.2 + if( !isset($datum["flags"]["falldamage"]) ){ //new in v1.0.7.3 $flags["falldamage"] = false; $newchange['FallDamage'] = "! Area FallDamage flag missing, now updated to 'false'; please see /resources/config.yml"; } - if( !isset($datum["flags"]["shoot"]) ){ //new in v1.0.7.2 + if( !isset($datum["flags"]["shoot"]) ){ //new in v1.0.7.4 $flags["shoot"] = false; $newchange['Shoot'] = "! Area Shoot flag missing (alias launch), now updated to 'false'; please see /resources/config.yml"; } @@ -236,10 +235,10 @@ public function onEnable() : void{ if(!isset($c["Default"]["Drop"])) { // new in v1.0.4-11 $c["Default"]["Drop"] = false; } - if(!isset($c["Default"]["Animals"])) { // new in v1.0.7.5 + if(!isset($c["Default"]["Animals"])) { // new in v1.0.7.5-dev $c["Default"]["Animals"] = false; } - if(!isset($c["Default"]["Mobs"])) { // new in v1.0.7.5 + if(!isset($c["Default"]["Mobs"])) { // new in v1.0.7.5-dev $c["Default"]["Mobs"] = false; } if(!isset($c["Default"]["Effects"])) { // new in v1.0.5-12 @@ -271,8 +270,8 @@ public function onEnable() : void{ $this->passage = $c["Default"]["Passage"]; // changed in v1.0.3-11 $this->perms = $c["Default"]["Perms"]; // new in v1.0.4-11 $this->drop = $c["Default"]["Drop"]; // new in v1.0.4-11 - $this->animals = $c["Default"]["Animals"]; // new in v1.0.7.5-dev(1.0.8) - $this->mobs = $c["Default"]["Mobs"]; // new in v1.0.7.5-dev(1.0.8) + $this->animals = $c["Default"]["Animals"]; // new in v1.0.7.5-dev + $this->mobs = $c["Default"]["Mobs"]; // new in v1.0.7.5-dev $this->effects = $c["Default"]["Effects"]; // new in v1.0.5-12 $this->pvp = $c["Default"]["PVP"]; // new in v1.0.6-13 $this->flight = $c["Default"]["Flight"]; // new in v1.0.6-13 @@ -299,10 +298,10 @@ public function onEnable() : void{ if( !isset($flags["Drop"]) ){ // new v1.0.4-11 $flags["Drop"] = $this->drop; } - if( !isset($flags["Animals"]) ){ // new v1.0.7.5 + if( !isset($flags["Animals"]) ){ // new v1.0.7.5-dev $flags["Animals"] = $this->animals; } - if( !isset($flags["Mobs"]) ){ // new v1.0.7.5 + if( !isset($flags["Mobs"]) ){ // new v1.0.7.5-dev $flags["Mobs"] = $this->effects; } if( !isset($flags["Effects"]) ){ // new v1.0.5-12 @@ -2242,6 +2241,7 @@ public function saveAreas() : void{ } file_put_contents($this->getDataFolder() . "areas.json", json_encode($areas)); } + /** Festival Console Sign Flag for developers * makes it easy to find Festival console output fast */ From 85af721c0422248f323f1b6366664f95882b3651 Mon Sep 17 00:00:00 2001 From: genboy Date: Fri, 31 Aug 2018 22:42:29 +0200 Subject: [PATCH 28/68] img --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 595f9e5..dae9373 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ 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/08/festival_usage_1.0.7-2-dev.png) +![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/08/festival_usage_1.0.7.5-dev.png) ###### Copyright [Genboy](https://genboy.net) 2018 From 63fa21edb6a577b7b45970d9b8c5613c1f5df1fa Mon Sep 17 00:00:00 2001 From: genboy Date: Fri, 7 Sep 2018 20:19:33 +0200 Subject: [PATCH 29/68] Reverse Fix canPVP --- src/genboy/Festival/Main.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 3ae4dea..ffaa23a 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1109,9 +1109,9 @@ public function canPVP(EntityDamageEvent $ev) : bool{ $o = false; } $playername = $entity->getName(); - foreach($this->inArea[$playername] as $areaname){ - if( isset($this->areaList[ $areaname ]) ){ - $area = $this->areaList[$areaname]; + $pos = $entity->getPosition(); + foreach ($this->areas as $area) { + if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { $god = $area->getFlag("god"); if($area->getFlag("pvp")){ $o = false; @@ -1297,14 +1297,22 @@ public function onBlockTouch(PlayerInteractEvent $event) : void{ //$player->sendMessage("TOUCHED " . $block->getName() . "(". $block->getID() . ") with ". $item->getName() ."(".$item->getID().") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"); + + // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/item/ItemIds.php + // touch & block events controlled by edit flag $b = $block->getID(); $i = $item->getID(); + + + //|| ( $i == 259 ) // flint and steel + if( ( $b == 199 ) // item frame - || ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) // no farm event + || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) // no farm event ){ if(!$this->canEdit($player, $block)){ + //$block->extinguish(); $event->setCancelled(); } } @@ -1504,7 +1512,7 @@ public function canShoot( Player $player ) : bool{ } - /** Mob spawning + /** Mob / Animal spawning * @param EntitySpawnEvent $event * @ignoreCancelled true */ @@ -1546,7 +1554,7 @@ public function canEntitySpawn( Entity $e ): bool{ } if($pos && $nm != 'unknown'){ - $animals =[ 'bat','chicken','cow','horse','donkey','mule','ocelot','parrot','fish','dolphin','squit','pig','rabbit','sheep','pufferfish','salmon','tropical_fish','balloon']; + $animals =[ 'bat','chicken','cow','horse','llama','donkey','mule','ocelot','parrot','fish','dolphin','squit','pig','rabbit','sheep','pufferfish','salmon','turtle','tropical_fish','cod','balloon']; if( in_array( strtolower($nm), $animals ) ){ // check animal flag From ad4d3c00ed19d831f15219ece3a2651502264d80 Mon Sep 17 00:00:00 2001 From: genboy Date: Fri, 7 Sep 2018 23:27:24 +0200 Subject: [PATCH 30/68] cleaning --- src/genboy/Festival/Main.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index ffaa23a..ead56b9 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1296,23 +1296,16 @@ public function onBlockTouch(PlayerInteractEvent $event) : void{ $item = $event->getItem(); //$player->sendMessage("TOUCHED " . $block->getName() . "(". $block->getID() . ") with ". $item->getName() ."(".$item->getID().") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"); - - // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/item/ItemIds.php // touch & block events controlled by edit flag $b = $block->getID(); $i = $item->getID(); - - - //|| ( $i == 259 ) // flint and steel - if( ( $b == 199 ) // item frame || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) // no farm event ){ if(!$this->canEdit($player, $block)){ - //$block->extinguish(); $event->setCancelled(); } } From 05785bbb26de8d4f01c4a9e3412df8aa637ec23d Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 8 Sep 2018 00:31:58 +0200 Subject: [PATCH 31/68] Fix empty areas data --- src/genboy/Festival/Main.php | 122 ++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 58 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index ead56b9..cf29120 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -129,64 +129,70 @@ public function onEnable() : void{ // innitialize default flags & update data $data = json_decode(file_get_contents($this->getDataFolder() . "areas.json"), true); - foreach($data as $datum){ - $flags = $datum["flags"]; - if( isset($datum["flags"]["barrier"]) ){ - $flags["passage"] = $datum["flags"]["barrier"]; // replaced in v1.0.5-11 can use both - unset($flags["barrier"]); - $newchange['Passage'] = "! Old Barrier config was used, now set to 'false'; please rename 'Barrier' to 'Passage' in config.yml"; - } - if( !isset($datum["flags"]["perms"]) ){ // new flags v 1.0.5-12 - $flags["perms"] = false; - $newchange['Perms'] = "! Area Perms flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["drop"]) ){ // new flags v 1.0.5-12 - $flags["drop"] = false; - $newchange['Drop'] = "! Area Drop flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["animals"]) ){ // new flags v 1.0.7.5-dev - $flags["animals"] = false; - $newchange['Animals'] = "! Area Animals flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["mobs"]) ){ // new flags v 1.0.7.5-dev - $flags["mobs"] = false; - $newchange['Mobs'] = "! Area Mobs flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["effects"]) ){ // new flags v 1.0.5-12 - $flags["effects"] = false; - $newchange['Effects'] = "! Area Effects flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["pvp"]) ){ //new flags v 1.0.6-13 - $flags["pvp"] = false; - $newchange['PVP'] = "! Area PVP flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["flight"]) ){ //new flags v 1.0.6-13 - $flags["flight"] = false; - $newchange['Flight'] = "! Area Flight flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["tnt"]) ){ // new flags v 1.0.7 - $flags["tnt"] = false; - $newchange['TNT'] = "! Area TNT flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["hunger"]) ){ // new flags v 1.0.7 - $flags["hunger"] = false; - $newchange['Hunger'] = "! Area Hunger flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( isset($datum["flags"]["nofalldamage"]) ){ - $flags["falldamage"] = $datum["flags"]["nofalldamage"]; // replaced in v1.0.5-11 can use both - unset($flags["nofalldamage"]); - $newchange['FallDamage'] = "! Old NoFallDamage config was used, now set to 'false'; please rename 'NoFallDamage' to 'FallDamage' in config.yml"; - } - if( !isset($datum["flags"]["falldamage"]) ){ //new in v1.0.7.3 - $flags["falldamage"] = false; - $newchange['FallDamage'] = "! Area FallDamage flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["shoot"]) ){ //new in v1.0.7.4 - $flags["shoot"] = false; - $newchange['Shoot'] = "! Area Shoot flag missing (alias launch), 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); - } + + + if( isset( $data ) && is_array( $data ) ){ + + foreach($data as $datum){ + $flags = $datum["flags"]; + if( isset($datum["flags"]["barrier"]) ){ + $flags["passage"] = $datum["flags"]["barrier"]; // replaced in v1.0.5-11 can use both + unset($flags["barrier"]); + $newchange['Passage'] = "! Old Barrier config was used, now set to 'false'; please rename 'Barrier' to 'Passage' in config.yml"; + } + if( !isset($datum["flags"]["perms"]) ){ // new flags v 1.0.5-12 + $flags["perms"] = false; + $newchange['Perms'] = "! Area Perms flag missing, now updated to 'false'; please see /resources/config.yml"; + } + if( !isset($datum["flags"]["drop"]) ){ // new flags v 1.0.5-12 + $flags["drop"] = false; + $newchange['Drop'] = "! Area Drop flag missing, now updated to 'false'; please see /resources/config.yml"; + } + if( !isset($datum["flags"]["animals"]) ){ // new flags v 1.0.7.5-dev + $flags["animals"] = false; + $newchange['Animals'] = "! Area Animals flag missing, now updated to 'false'; please see /resources/config.yml"; + } + if( !isset($datum["flags"]["mobs"]) ){ // new flags v 1.0.7.5-dev + $flags["mobs"] = false; + $newchange['Mobs'] = "! Area Mobs flag missing, now updated to 'false'; please see /resources/config.yml"; + } + if( !isset($datum["flags"]["effects"]) ){ // new flags v 1.0.5-12 + $flags["effects"] = false; + $newchange['Effects'] = "! Area Effects flag missing, now updated to 'false'; please see /resources/config.yml"; + } + if( !isset($datum["flags"]["pvp"]) ){ //new flags v 1.0.6-13 + $flags["pvp"] = false; + $newchange['PVP'] = "! Area PVP flag missing, now updated to 'false'; please see /resources/config.yml"; + } + if( !isset($datum["flags"]["flight"]) ){ //new flags v 1.0.6-13 + $flags["flight"] = false; + $newchange['Flight'] = "! Area Flight flag missing, now updated to 'false'; please see /resources/config.yml"; + } + if( !isset($datum["flags"]["tnt"]) ){ // new flags v 1.0.7 + $flags["tnt"] = false; + $newchange['TNT'] = "! Area TNT flag missing, now updated to 'false'; please see /resources/config.yml"; + } + if( !isset($datum["flags"]["hunger"]) ){ // new flags v 1.0.7 + $flags["hunger"] = false; + $newchange['Hunger'] = "! Area Hunger flag missing, now updated to 'false'; please see /resources/config.yml"; + } + if( isset($datum["flags"]["nofalldamage"]) ){ + $flags["falldamage"] = $datum["flags"]["nofalldamage"]; // replaced in v1.0.5-11 can use both + unset($flags["nofalldamage"]); + $newchange['FallDamage'] = "! Old NoFallDamage config was used, now set to 'false'; please rename 'NoFallDamage' to 'FallDamage' in config.yml"; + } + if( !isset($datum["flags"]["falldamage"]) ){ //new in v1.0.7.3 + $flags["falldamage"] = false; + $newchange['FallDamage'] = "! Area FallDamage flag missing, now updated to 'false'; please see /resources/config.yml"; + } + if( !isset($datum["flags"]["shoot"]) ){ //new in v1.0.7.4 + $flags["shoot"] = false; + $newchange['Shoot'] = "! Area Shoot flag missing (alias launch), 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); + } + + } $c = yaml_parse_file($this->getDataFolder() . "config.yml"); From 6261ad7f9e6b0eb49a3b38950f510b6f9725c0b2 Mon Sep 17 00:00:00 2001 From: Genboy <30810841+genboy@users.noreply.github.com> Date: Sat, 8 Sep 2018 22:39:14 +0200 Subject: [PATCH 32/68] Add flint & steel protection + moving actions to checks in onInteract event --- src/genboy/Festival/Main.php | 42 ++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index cf29120..cfb3539 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1,7 +1,7 @@ getDataFolder() . "areas.json"), true); - if( isset( $data ) && is_array( $data ) ){ foreach($data as $datum){ @@ -1299,34 +1299,43 @@ public function canTouch(Player $player, Position $position) : bool{ public function onBlockTouch(PlayerInteractEvent $event) : void{ $block = $event->getBlock(); $player = $event->getPlayer(); + if(!$this->canTouch($player, $block)){ + $event->setCancelled(); + } + } + + + /** on Interact + * @param PlayerInteractEvent $event + * @ignoreCancelled true + */ + public function onInteract( PlayerInteractEvent $event ): void{ + $item = $event->getItem(); - - //$player->sendMessage("TOUCHED " . $block->getName() . "(". $block->getID() . ") with ". $item->getName() ."(".$item->getID().") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"); - // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/item/ItemIds.php - - // touch & block events controlled by edit flag + $block = $event->getBlock(); + $player = $event->getPlayer(); $b = $block->getID(); $i = $item->getID(); - if( - ( $b == 199 ) // item frame + + /* + $player->sendMessage("Action on " . $block->getName() . "(". $block->getID() . ") with ". $item->getName() ."(".$item->getID().") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"); + */ + if( + $b == 199 // item frame || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) // no farm event + || $i == 259 // flint & steel ){ if(!$this->canEdit($player, $block)){ - $event->setCancelled(); + $event->setCancelled(true); } } - - if(!$this->canTouch($player, $block)){ - $event->setCancelled(); - } - } + } /** hunger * PlayerExhaustEvent * @param PlayerExhaustEvent $event * @return void */ - public function Hunger(PlayerExhaustEvent $event){ if ( !$this->canHunger( $event ) ) { $event->setCancelled(); @@ -1543,6 +1552,7 @@ public function canEntitySpawn( Entity $e ): bool{ if( $e instanceof ExperienceOrb || $e instanceof ItemEntity || $e instanceof Projectile){ return $o; // allowed } + $nm = 'unknown'; // $nm = $e instanceof Item ? $e->getItem()->getName() : $e->getName(); if( null !== $e->getName() ){ $nm = $e->getName(); From 680faa374a74131b843cb224e471f996ff1ab019 Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 9 Sep 2018 02:05:56 +0200 Subject: [PATCH 33/68] Update dev version --- README.md | 2 +- plugin.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dae9373..4cd610c 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Create a festival with this custom area events plugin for Pocketmine Server: - 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. + - touch: area is save from player interaction with doors/chests/signs etc. - animals: no animal spawning (including spawners & eggs) - mobs: no mobs spawning (including spawners & eggs) - effects: player can not keep using effects in the area diff --git a/plugin.yml b/plugin.yml index f961209..0272fc1 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: Festival author: Genboy -version: 1.0.7.5-dev +version: 1.0.7.6-dev main: genboy\Festival\Main load: POSTWORLD api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0,4.0.0] From 940aaf7ce93cba07c12cf44ea2fd219f0f2748b2 Mon Sep 17 00:00:00 2001 From: genboy Date: Thu, 13 Sep 2018 08:05:36 +0200 Subject: [PATCH 34/68] Enhancement TNT Flag --- src/genboy/Festival/Main.php | 37 ++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index cfb3539..4204390 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -12,6 +12,7 @@ use pocketmine\entity\Item; use pocketmine\entity\object\ExperienceOrb; use pocketmine\entity\object\ItemEntity; +use pocketmine\entity\object\PrimedTNT; use pocketmine\entity\projectile\Arrow; use pocketmine\entity\projectile\Projectile; use pocketmine\event\block\BlockBreakEvent; @@ -1320,13 +1321,20 @@ public function onInteract( PlayerInteractEvent $event ): void{ /* $player->sendMessage("Action on " . $block->getName() . "(". $block->getID() . ") with ". $item->getName() ."(".$item->getID().") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"); */ + if( $b == 46 // tnt + && $i == 259 // flint & steel + && !$this->canExplode( $player->getPosition() ) ){ + $event->setCancelled(true); + $player->sendMessage("TNT explosions not allowed in this area"); + } + if( $b == 199 // item frame || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) // no farm event - || $i == 259 // flint & steel + || $i == 259 // flint & steel fire ){ if(!$this->canEdit($player, $block)){ - $event->setCancelled(true); + $event->setCancelled(true); } } } @@ -1553,15 +1561,20 @@ public function canEntitySpawn( Entity $e ): bool{ return $o; // allowed } - $nm = 'unknown'; // $nm = $e instanceof Item ? $e->getItem()->getName() : $e->getName(); - if( null !== $e->getName() ){ + if( $e instanceof PrimedTNT && !$this->canExplode( $e->getPosition() )){ // Prevent PrimedTNT (experiment) + return false; + } + + $nm = ''; // $nm = $e instanceof Item ? $e->getItem()->getName() : $e->getName(); + if( isset($e->getName()) && null !== $e->getName() ){ $nm = $e->getName(); } + $pos = false; - if( null !== $e->getPosition() ){ + if( isset( $e->getPosition() ) && null !== $e->getPosition() ){ $pos = $e->getPosition(); } - if($pos && $nm != 'unknown'){ + if($pos && $nm != ''){ $animals =[ 'bat','chicken','cow','horse','llama','donkey','mule','ocelot','parrot','fish','dolphin','squit','pig','rabbit','sheep','pufferfish','salmon','turtle','tropical_fish','cod','balloon']; @@ -1616,20 +1629,32 @@ public function onBlockPlace(BlockPlaceEvent $event) : void{ $block = $event->getBlock(); $player = $event->getPlayer(); $playerName = strtolower($player->getName()); + if(isset($this->selectingFirst[$playerName])){ + unset($this->selectingFirst[$playerName]); $this->firstPosition[$playerName] = $block->asVector3(); $player->sendMessage(TextFormat::GREEN . "Position 1 set to: (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); $event->setCancelled(); + }elseif(isset($this->selectingSecond[$playerName])){ + unset($this->selectingSecond[$playerName]); $this->secondPosition[$playerName] = $block->asVector3(); $player->sendMessage(TextFormat::GREEN . "Position 2 set to: (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); $event->setCancelled(); + }else{ + // tnt block + if( $block->getID() == 46 && !$this->canExplode( $player->getPosition() ) ){ + $event->setCancelled(); + $player->sendMessage("TNT explosions not allowed in this area"); + } + if(!$this->canEdit($player, $block)){ $event->setCancelled(); } + } } From 261c8026231212943affe2a266da57fb14fe6784 Mon Sep 17 00:00:00 2001 From: genboy Date: Thu, 13 Sep 2018 08:07:29 +0200 Subject: [PATCH 35/68] fix check --- src/genboy/Festival/Main.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 4204390..a0e7f96 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1566,12 +1566,12 @@ public function canEntitySpawn( Entity $e ): bool{ } $nm = ''; // $nm = $e instanceof Item ? $e->getItem()->getName() : $e->getName(); - if( isset($e->getName()) && null !== $e->getName() ){ + if( null !== $e->getName() ){ $nm = $e->getName(); } $pos = false; - if( isset( $e->getPosition() ) && null !== $e->getPosition() ){ + if( null !== $e->getPosition() ){ $pos = $e->getPosition(); } if($pos && $nm != ''){ From d4ed5328d7c34e60389a5be1dfd35582759e10ef Mon Sep 17 00:00:00 2001 From: genboy Date: Thu, 13 Sep 2018 09:33:04 +0200 Subject: [PATCH 36/68] testing permissions & msg --- src/genboy/Festival/Main.php | 41 +++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index a0e7f96..0bbc774 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1315,17 +1315,37 @@ public function onInteract( PlayerInteractEvent $event ): void{ $item = $event->getItem(); $block = $event->getBlock(); $player = $event->getPlayer(); + $playername = strtolower($player->getName()); $b = $block->getID(); $i = $item->getID(); /* $player->sendMessage("Action on " . $block->getName() . "(". $block->getID() . ") with ". $item->getName() ."(".$item->getID().") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"); */ + + /* + if( $player->isOp() || $player->hasPermission("festival") || $player->hasPermission("festival.access")){ + return true; + } + + */ + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + } + } + + if( $b == 46 // tnt && $i == 259 // flint & steel - && !$this->canExplode( $player->getPosition() ) ){ - $event->setCancelled(true); - $player->sendMessage("TNT explosions not allowed in this area"); + && !$this->canExplode( $player->getPosition() ) + && !$player->isOp() ){ + $event->setCancelled(true); + + if( isset($area) && ( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ) ){ + $player->sendMessage("TNT explosions not allowed in this area"); + } + } if( @@ -1335,6 +1355,9 @@ public function onInteract( PlayerInteractEvent $event ): void{ ){ if(!$this->canEdit($player, $block)){ $event->setCancelled(true); + if( isset($area) && ( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ) ){ + $player->sendMessage("Can not use this block or item in this area"); + } } } } @@ -1647,6 +1670,18 @@ public function onBlockPlace(BlockPlaceEvent $event) : void{ }else{ // tnt block if( $block->getID() == 46 && !$this->canExplode( $player->getPosition() ) ){ + + /* + if( $player->isOp() || $player->hasPermission("festival") || $player->hasPermission("festival.access")){ + return true; + } + + if( $area->getFlag("msg") ){ + $m = false; + }*/ + + + $event->setCancelled(); $player->sendMessage("TNT explosions not allowed in this area"); } From bc51eff659af7254cc8672d07bd929e0dfff442b Mon Sep 17 00:00:00 2001 From: genboy Date: Thu, 13 Sep 2018 20:24:07 +0200 Subject: [PATCH 37/68] no TNT block placing with TNT flag --- src/genboy/Festival/Main.php | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 0bbc774..32d8da1 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1343,7 +1343,7 @@ public function onInteract( PlayerInteractEvent $event ): void{ $event->setCancelled(true); if( isset($area) && ( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ) ){ - $player->sendMessage("TNT explosions not allowed in this area"); + $player->sendMessage("TNT not allowed here"); } } @@ -1356,7 +1356,7 @@ public function onInteract( PlayerInteractEvent $event ): void{ if(!$this->canEdit($player, $block)){ $event->setCancelled(true); if( isset($area) && ( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ) ){ - $player->sendMessage("Can not use this block or item in this area"); + $player->sendMessage("Can not do this here"); } } } @@ -1584,11 +1584,17 @@ public function canEntitySpawn( Entity $e ): bool{ return $o; // allowed } - if( $e instanceof PrimedTNT && !$this->canExplode( $e->getPosition() )){ // Prevent PrimedTNT (experiment) - return false; + // catch more spawning entities without (get)Name + if( $e instanceof PrimedTNT ){ + if( $this->canExplode( $e->getPosition() )){ // Prevent PrimedTNT (experiment) + return true; + }else{ + return false; + } } - $nm = ''; // $nm = $e instanceof Item ? $e->getItem()->getName() : $e->getName(); + $nm = ''; + //$nm = $e instanceof Item ? $e->getItem()->getName() : $e->getName(); if( null !== $e->getName() ){ $nm = $e->getName(); } @@ -1668,22 +1674,18 @@ public function onBlockPlace(BlockPlaceEvent $event) : void{ $event->setCancelled(); }else{ - // tnt block - if( $block->getID() == 46 && !$this->canExplode( $player->getPosition() ) ){ - /* - if( $player->isOp() || $player->hasPermission("festival") || $player->hasPermission("festival.access")){ - return true; - } - if( $area->getFlag("msg") ){ - $m = false; - }*/ + // tnt block + if( $block->getID() == 46 && !$this->canExplode( $player->getPosition() ) ){ + if( $player->isOp() || $player->hasPermission("festival") || $player->hasPermission("festival.access")){ - $event->setCancelled(); - $player->sendMessage("TNT explosions not allowed in this area"); + }else{ + $event->setCancelled(); + //$player->sendMessage("TNT not allowed here"); + } } if(!$this->canEdit($player, $block)){ From 87509d1c594b733a00c996776d0db3b995abdb20 Mon Sep 17 00:00:00 2001 From: genboy Date: Thu, 13 Sep 2018 22:12:47 +0200 Subject: [PATCH 38/68] Round up TNT / Flint Steel - TNT/Touch(Edit) Flag --- src/genboy/Festival/Main.php | 52 +++++++++++------------------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 32d8da1..0ec468c 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1322,44 +1322,28 @@ public function onInteract( PlayerInteractEvent $event ): void{ /* $player->sendMessage("Action on " . $block->getName() . "(". $block->getID() . ") with ". $item->getName() ."(".$item->getID().") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"); */ + if( $player->isOp() || $player->hasPermission("festival") || $player->hasPermission("festival.access")){ - /* - if( $player->isOp() || $player->hasPermission("festival") || $player->hasPermission("festival.access")){ - return true; - } + }else{ - */ - foreach($this->inArea[$playername] as $areaname){ - if( isset($this->areaList[ $areaname ]) ){ - $area = $this->areaList[$areaname]; + if( $b == 46 // tnt + && $i == 259 // flint & steel + && !$this->canExplode( $player->getPosition() ) + && !$player->isOp() ){ + $event->setCancelled(true); } - } - - if( $b == 46 // tnt - && $i == 259 // flint & steel - && !$this->canExplode( $player->getPosition() ) - && !$player->isOp() ){ - $event->setCancelled(true); - - if( isset($area) && ( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ) ){ - $player->sendMessage("TNT not allowed here"); + if( + $b == 199 // item frame + || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) // no farm event + || $i == 259 // flint & steel fire + ){ + if(!$this->canEdit($player, $block)){ + $event->setCancelled(true); + } } } - - if( - $b == 199 // item frame - || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) // no farm event - || $i == 259 // flint & steel fire - ){ - if(!$this->canEdit($player, $block)){ - $event->setCancelled(true); - if( isset($area) && ( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ) ){ - $player->sendMessage("Can not do this here"); - } - } - } } /** hunger @@ -1593,12 +1577,10 @@ public function canEntitySpawn( Entity $e ): bool{ } } - $nm = ''; - //$nm = $e instanceof Item ? $e->getItem()->getName() : $e->getName(); + $nm = ''; //$nm = $e instanceof Item ? $e->getItem()->getName() : $e->getName(); if( null !== $e->getName() ){ $nm = $e->getName(); } - $pos = false; if( null !== $e->getPosition() ){ $pos = $e->getPosition(); @@ -1675,8 +1657,6 @@ public function onBlockPlace(BlockPlaceEvent $event) : void{ }else{ - - // tnt block if( $block->getID() == 46 && !$this->canExplode( $player->getPosition() ) ){ From a4ee01652c55ee071f049f914cac3a7699044d80 Mon Sep 17 00:00:00 2001 From: genboy Date: Fri, 14 Sep 2018 01:28:40 +0200 Subject: [PATCH 39/68] Translation test setup with json resource and ingame player permission --- plugin.yml | 7 +- resources/config.yml | 2 + resources/en.json | 77 ++++++++++++++++++++++ resources/nl.json | 15 +++++ src/genboy/Festival/Main.php | 92 +++++++++++++++++++++++---- src/genboy/Festival/lang/Language.php | 33 ++++++++++ 6 files changed, 210 insertions(+), 16 deletions(-) create mode 100644 resources/en.json create mode 100644 resources/nl.json create mode 100644 src/genboy/Festival/lang/Language.php diff --git a/plugin.yml b/plugin.yml index 0272fc1..efe3dd6 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: Festival author: Genboy -version: 1.0.7.6-dev +version: 1.0.7.7-dev main: genboy\Festival\Main load: POSTWORLD api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0,4.0.0] @@ -24,8 +24,11 @@ permissions: children: festival.command.fe: description: "Allows access to the Festival area command." - default: op + default: true children: + festival.command.fe.lang: + description: "Allows access to the Festival lang subcommand." + default: true festival.command.fe.pos1: description: "Allows access to the Festival pos1 subcommand." default: op diff --git a/resources/config.yml b/resources/config.yml index c1be134..5dea8a5 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -2,6 +2,8 @@ # Festival options Options: + # select a language: English = en, Dutch = nl, translate please ! + language: en # Area Messages Display position (tip/pop) Msgtype: pop diff --git a/resources/en.json b/resources/en.json new file mode 100644 index 0000000..2acb69d --- /dev/null +++ b/resources/en.json @@ -0,0 +1,77 @@ +{ + "language-name": "English", + "language-selected": "Now selected English.", + + "enabled-console-msg": "Festival now enabled, testing in English.", + + "cmd-ingameonly-msg": "Festival command only to be used in-game.", + "cmd-unknown-msg": "Unknown Festival command", + "cmd-noperms-msg": "You can not use this Festival command", + "cmd-noperms-subcommand": "You do not have permission to use this subcommand.", + + + "pos-select-active": "You're already selecting a position!", + "select-both-pos-first":"Please select both positions first.", + "pos1": "position 1", + "pos2": "position 2", + "make-pos1": "Please place or break the first position.", + "make-pos2": "Please place or break the first position.", + "give-area-name": "Please specify a name for this area.", + + "in-unknown-area": "You are in an unknown area", + + "area": "Area", + "area": "areas", + "level": "level", + "level": "levels", + "the-area": "The area", + "the-level": "The level", + "area-created": "Area created!", + "created-by":"created by", + "area-no-area-available": "No area available", + "area-no-area-to-edit": "There are no areas that you can edit", + "area-name-excist": "An area with that name already exists.", + "area-not-excist": "Area does not exist.", + "cannot-be-found": "cannot be found.", + "area-list" : "Area list", + + "desc-saved": "description saved.", + "desc-write-usage": "Please write the description. Usage /fe desc <..>", + "desc-specify-area": "Please specify an area to edit the description. Usage: /fe desc ", + + "area-deleted": "Area deleted!", + "deleted-by":"deleted by", + "specify-to-delete":"Please specify an area to delete.", + + + "flag": "Flag", + "flags": "flags", + "flag-not-found-list": "Flag not found. (Flags: edit, god, touch, effects, msg, passage, perms, drop)", + "specify-to-flag": "Please specify the area you would like to flag.", + + "tp-to-area-active": "You are teleporting to Area", + "specify-excisting-area-name": "Please specify an existing Area name.", + + "cmd": "Command", + "cmds": "Commands", + "cmd-id": "Command id", + "cmd-list": "Command list", + "-event": "-event", + "set-for-area": "set for area", + "added-to-area": "added to area", + "allready-used-for": "allready used for", + "allready-set-for-area": "allready set for area", + "edit-id-or-other": ", edit this id or use another id", + "cmd-specify-id-and-command-usage": "Please specify the command ID and command string to add. Usage: /fe command add ", + + "event": "event", + "event-is-now": "event is now", + "change-failed": "change-failed!", + + "select-yes": "Yes", + "select-no": "No", + "status-on": "on", + "status-off": "off", + "set-to": "set to", + "for-area": "for area" +} diff --git a/resources/nl.json b/resources/nl.json new file mode 100644 index 0000000..6ec09e1 --- /dev/null +++ b/resources/nl.json @@ -0,0 +1,15 @@ +{ + "language-name": "Nederlands", + "language-selected": "Nederlands geselecteerd.", + + "enabled-console-msg": "Festival opgestart, test in het Nederlands.", + + "cmd-ingameonly-msg": "Commando alleen voor gebruik in het spel.", + "cmd-unknown-msg": "Onbekend Festival commando", + "cmd-noperms-msg": "Jij mag dit Festival commando niet gebruiken", + + "area-no-area-available": "Geen gebied beschikbaar", + + "select-yes": "Yes", + "select-no": "No" +} diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 0ec468c..5cf9ef3 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -5,6 +5,8 @@ */ namespace genboy\Festival; +use genboy\Festival\lang\Language; + use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\command\ConsoleCommandSender; @@ -199,7 +201,10 @@ public function onEnable() : void{ // innitialize configurations & update options if( isset( $c["Options"] ) && is_array( $c["Options"] ) ){ - + if(!isset($c["Options"]["Language"])){ + $c["Options"]["Language"] = 'en'; + $newchange['Language'] = "! Language option missing in config.yml, now set to 'en' (english); please see latest version of /resources/config.yml"; + } if(!isset($c["Options"]["Msgtype"])){ $c["Options"]["Msgtype"] = 'pop'; $newchange['Msgtype'] = "! Msgtype option missing in config.yml, now set to 'pop'; please see /resources/config.yml"; @@ -214,8 +219,8 @@ public function onEnable() : void{ } $this->options = $c["Options"]; }else{ - $this->options = array("Msgtype"=>"pop", "Msgdisplay"=>"off", "AutoWhitelist"=>"on"); // Fallback defaults - $newchange['Options'] = "! Config Options missing in config.yml, defautls are set for now; please see /resources/config.yml"; + $this->options = array("Language"=>"en", "Msgtype"=>"pop", "Msgdisplay"=>"off", "AutoWhitelist"=>"on"); // Fallback defaults + $newchange['Options'] = "! Config Options missing in config.yml, defaults are set for now; please see /resources/config.yml"; } // set defaults @@ -339,12 +344,18 @@ public function onEnable() : void{ $this->saveAreas(); // all save $this->areaList available :) /** console output */ + $this->loadLanguage(); + + $this->getLogger()->info( Language::translate("enabled-console-msg") ); + $this->codeSigned(); // codesign $ca = 0; // plugin area info foreach( $this->areas as $a ){ $ca = $ca + count( $a->getCommands() ); } + $this->getLogger()->info( " ". $ca ." commands in " . count($this->areas) . " areas" ); + // warnings changes if( count($newchange) > 0 ){ foreach($newchange as $ttl => $txt){ @@ -353,6 +364,45 @@ public function onEnable() : void{ } } + + + /** load language ( experiment v1.0.7.7-dev ) + * @var plugin config[] + * @file resources en.json + * @file resources nl.json + * @var obj Language + */ + public function loadLanguage(){ + $languageCode = $this->options["language"]; + $resources = $this->getResources(); // read files in resources folder + foreach($resources as $resource){ + if($resource->getFilename() === "en.json"){ + $default = json_decode(file_get_contents($resource->getPathname(), true), true); + } + if($resource->getFilename() === $languageCode.".json"){ + $setting = json_decode(file_get_contents($resource->getPathname(), true), true); + } + } + if(isset($setting)){ + $langJson = $setting; + }else{ + $langJson = $default; + } + new Language($this, $langJson); + } + + + public function setLanguage( $lang, $player ){ + + $this->options["language"] = $lang; + $this->loadLanguage(); + // Area Flag text colors GREEN, AQUA, BLUE, RED, WHITE, YELLOW, LIGHT_PURPLE, DARK_PURPLE, GOLD, GRAY + $msg = TextFormat::AQUA . Language::translate("language-selected"); + $player->sendMessage( $msg ); + + } + + /** Flag check experimental (synonym to original name) * @param string $flag * @return str $flag @@ -438,10 +488,13 @@ public function isFlag( $str ){ * @return bool */ public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool{ + if(!($sender instanceof Player)){ - $sender->sendMessage(TextFormat::RED . "Command must be used in-game."); + //$sender->sendMessage(TextFormat::RED . "Command must be used in-game."); + $sender->sendMessage( TextFormat::RED . Language::translate("cmd-ingameonly-msg") ); return true; } + if(!isset($args[0])){ return false; } @@ -449,8 +502,19 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $action = strtolower($args[0]); $o = ""; switch($action){ + + + case "lang": // experiment v1.0.7.7-dev + if( isset($args[1]) ){ + if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.lang")){ + $lang = $args[1]; + $this->setLanguage( $lang, $sender ); + } + } + break; + case "pos1": - if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.pos1")){ + if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.pos1")){ if(isset($this->selectingFirst[$playerName]) || isset($this->selectingSecond[$playerName])){ $o = TextFormat::RED . "You're already selecting a position!"; }else{ @@ -462,7 +526,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } break; case "pos2": - if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.pos2")){ + if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.pos2")){ if(isset($this->selectingFirst[$playerName]) || isset($this->selectingSecond[$playerName])){ $o = TextFormat::RED . "You're already selecting a position!"; }else{ @@ -542,7 +606,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar break; case "desc": - if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.desc")){ + if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.desc")){ if(isset($args[1])){ if(isset($this->areas[strtolower($args[1])])){ if(isset($args[2])){ @@ -569,7 +633,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar break; case "list": - if( $sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.list")){ + if( $sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.list")){ $levelNamesArray = scandir($this->getServer()->getDataPath() . "worlds/"); foreach($levelNamesArray as $levelName) { if($levelName === "." || $levelName === "..") { @@ -613,7 +677,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar break; case "here": - if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.here")){ + if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.here")){ $o = ""; $playername = strtolower($sender->getName()); foreach($this->inArea[$playername] as $areaname){ @@ -641,7 +705,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $position = $sender->getPosition(); $perms = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[ $position->getLevel()->getName() ]["Perms"] : $this->perms); - if( $perms || $area->isWhitelisted($playerName) || $sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.tp")){ + if( $perms || $area->isWhitelisted($playerName) || $sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.tp")){ $levelName = $area->getLevelName(); if(isset($levelName) && Server::getInstance()->loadLevel($levelName) != false){ @@ -698,7 +762,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "fall": case "nfd": - if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.flag")){ + if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.flag")){ if(isset($args[1])){ /** @@ -799,7 +863,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "del": case "delete": case "remove": - if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.delete")){ + if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.delete")){ if(isset($args[1])){ if(isset($this->areas[strtolower($args[1])])){ $area = $this->areas[strtolower($args[1])]; @@ -817,7 +881,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar break; case "whitelist": - if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.whitelist")){ + if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.whitelist")){ if(isset($args[1], $this->areas[strtolower($args[1])])){ $area = $this->areas[strtolower($args[1])]; if(isset($args[2])){ @@ -867,7 +931,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "c": case "cmd": case "command": /** /fe command */ - if( isset($args[1]) && ( $sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe") || $sender->hasPermission("festival.command.fe.command") ) ){ + if( isset($args[1]) && ( $sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.command") ) ){ if( isset( $this->areas[strtolower($args[1])] ) ){ if( isset($args[2]) ){ $do = strtolower($args[2]); diff --git a/src/genboy/Festival/lang/Language.php b/src/genboy/Festival/lang/Language.php new file mode 100644 index 0000000..87ae515 --- /dev/null +++ b/src/genboy/Festival/lang/Language.php @@ -0,0 +1,33 @@ +owner = $owner; + $this->trans = $langjson; + self::$instance = $this; + + } + + static function translate($key){ + + $txt = self::$instance->trans[$key]; + if (strpos($txt, "%n") != false) { + $text = str_replace("%n", "\n", $txt); + } else { + $text = $txt; + } + return $text; + + } + +} + +?> From 43f709502be66478f6d9a5aeaf9d66ae96d9813d Mon Sep 17 00:00:00 2001 From: genboy Date: Fri, 14 Sep 2018 22:12:38 +0200 Subject: [PATCH 40/68] Partly translated --- resources/en.json | 10 +-- resources/nl.json | 68 +++++++++++++++- src/genboy/Festival/Main.php | 153 ++++++++++++++++++++++------------- 3 files changed, 165 insertions(+), 66 deletions(-) diff --git a/resources/en.json b/resources/en.json index 2acb69d..68d782c 100644 --- a/resources/en.json +++ b/resources/en.json @@ -15,13 +15,13 @@ "pos1": "position 1", "pos2": "position 2", "make-pos1": "Please place or break the first position.", - "make-pos2": "Please place or break the first position.", + "make-pos2": "Please place or break the second position.", "give-area-name": "Please specify a name for this area.", "in-unknown-area": "You are in an unknown area", "area": "Area", - "area": "areas", + "areas": "areas", "level": "level", "level": "levels", "the-area": "The area", @@ -52,9 +52,9 @@ "tp-to-area-active": "You are teleporting to Area", "specify-excisting-area-name": "Please specify an existing Area name.", - "cmd": "Command", - "cmds": "Commands", - "cmd-id": "Command id", + "cmd": "command", + "cmds": "commands", + "cmd-id": "command id", "cmd-list": "Command list", "-event": "-event", "set-for-area": "set for area", diff --git a/resources/nl.json b/resources/nl.json index 6ec09e1..89d288b 100644 --- a/resources/nl.json +++ b/resources/nl.json @@ -6,10 +6,72 @@ "cmd-ingameonly-msg": "Commando alleen voor gebruik in het spel.", "cmd-unknown-msg": "Onbekend Festival commando", - "cmd-noperms-msg": "Jij mag dit Festival commando niet gebruiken", + "cmd-noperms-msg": "Je kunt dit commando niet gebruiken", + "cmd-noperms-subcommand": "Je hebt geen toestemming om dit subcommando te gebruiken.", + + "pos-select-active": "Je bent al een coordinaat aan het selecteren!", + "select-both-pos-first":"Je moet eerst allebei de coordinaten selecteren.", + "pos1": "coordinaat 1", + "pos2": "coordinaat 2", + "make-pos1": "Breek of plaats een blok voor het eerste coordinaat.", + "make-pos2": "Breek of plaats een blok voor het tweede coordinaat.", + "give-area-name": "Geef het gebied een naam.", + + "in-unknown-area": "Je ben in onbekend gebied", + + "area": "gebied", + "areas": "gebieden", + "level": "level", + "level": "levels", + "the-area": "Het gebied", + "the-level": "Het level", + "area-created": "Gebied gemaakt!", + "created-by":"gemaakt door", "area-no-area-available": "Geen gebied beschikbaar", + "area-no-area-to-edit": "Er zijn geen gebieden die je kunt bewerken", + "area-name-excist": "Een gebied met die naam bestaat al.", + "area-not-excist": "Gebied bestaat niet.", + "cannot-be-found": "kan niet gevonden worden.", + "area-list" : "Lijst met gebieden", + + "desc-saved": "omschrijving opgeslagen.", + "desc-write-usage": "Schrijf de beschrijving. Gebruik /fe desc <..>", + "desc-specify-area": "Geef een gebied aan om de omschrijving aan te passen. Gebruik: /fe desc ", + + "area-deleted": "Geied verwijderd!", + "deleted-by":"verwijderd door", + "specify-to-delete":"Geef een gebied aan om te verwijderen.", + + + "flag": "Flag", + "flags": "flaggen", + "flag-not-found-list": "Flag niet gevonden. (Flaggen: edit, god, touch, effects, msg, passage, perms, drop)", + "specify-to-flag": "Geef het geid aan om te vlaggen.", + + "tp-to-area-active": "Je teleporteerd naar gebied", + "specify-excisting-area-name": "Geef een bestaande naam van een gebied.", + + "cmd": "Commando", + "cmds": "Commando's", + "cmd-id": "Commanod id", + "cmd-list": "Commando lijst", + "-event": "-event", + "set-for-area": "gebruikt vor gebied", + "added-to-area": "toegevoegd aan gebied", + "allready-used-for": "al in gebruik voor", + "allready-set-for-area": "al toegevoegd aan gebied", + "edit-id-or-other": ", bewerk deze id of bewerk een andere id", + "cmd-specify-id-and-command-usage": "Geef een uniek id en commando regel om toe te voegen. Gebruik: /fe command add ", + + "event": "event", + "event-is-now": "event is nu", + "change-failed": "change-failed!", - "select-yes": "Yes", - "select-no": "No" + "select-yes": "Ja", + "select-no": "Nee", + "status-on": "aan", + "status-off": "uit", + "set-to": "aangepast naar", + "for-area": "voor gebied" } diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 5cf9ef3..2c2883c 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -343,18 +343,20 @@ public function onEnable() : void{ $this->saveAreas(); // all save $this->areaList available :) - /** console output */ + /** load language translation class */ $this->loadLanguage(); + /** console output */ $this->getLogger()->info( Language::translate("enabled-console-msg") ); $this->codeSigned(); // codesign + $ca = 0; // plugin area info foreach( $this->areas as $a ){ $ca = $ca + count( $a->getCommands() ); } - - $this->getLogger()->info( " ". $ca ." commands in " . count($this->areas) . " areas" ); + $this->getLogger()->info( $ca .' '. Language::translate("cmds") .' in '. count($this->areas) .' '. Language::translate("areas")); + //$this->getLogger()->info( " ". $ca ." commands in " . count($this->areas) . " areas" ); // warnings changes if( count($newchange) > 0 ){ @@ -373,7 +375,7 @@ public function onEnable() : void{ * @var obj Language */ public function loadLanguage(){ - $languageCode = $this->options["language"]; + $languageCode = $this->options["Language"]; $resources = $this->getResources(); // read files in resources folder foreach($resources as $resource){ if($resource->getFilename() === "en.json"){ @@ -394,7 +396,7 @@ public function loadLanguage(){ public function setLanguage( $lang, $player ){ - $this->options["language"] = $lang; + $this->options["Language"] = $lang; $this->loadLanguage(); // Area Flag text colors GREEN, AQUA, BLUE, RED, WHITE, YELLOW, LIGHT_PURPLE, DARK_PURPLE, GOLD, GRAY $msg = TextFormat::AQUA . Language::translate("language-selected"); @@ -516,25 +518,31 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "pos1": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.pos1")){ if(isset($this->selectingFirst[$playerName]) || isset($this->selectingSecond[$playerName])){ - $o = TextFormat::RED . "You're already selecting a position!"; + //$o = TextFormat::RED . "You're already selecting a position!"; + $o = TextFormat::RED . Language::translate("pos-select-active"); }else{ $this->selectingFirst[$playerName] = true; - $o = TextFormat::GREEN . "Please place or break the first position."; + //$o = TextFormat::GREEN . "Please place or break the first position."; + $o = TextFormat::GREEN . Language::translate("make-pos1"); } }else{ - $o = TextFormat::RED . "You do not have permission to use this subcommand."; + //$o = TextFormat::RED . "You do not have permission to use this subcommand."; + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); } break; case "pos2": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.pos2")){ if(isset($this->selectingFirst[$playerName]) || isset($this->selectingSecond[$playerName])){ - $o = TextFormat::RED . "You're already selecting a position!"; + //$o = TextFormat::RED . "You're already selecting a position!"; + $o = TextFormat::RED . Language::translate("pos-select-active"); }else{ $this->selectingSecond[$playerName] = true; - $o = TextFormat::GREEN . "Please place or break the second position."; + //$o = TextFormat::GREEN . "Please place or break the second position."; + $o = TextFormat::GREEN . Language::translate("make-pos2"); } }else{ - $o = TextFormat::RED . "You do not have permission to use this subcommand."; + //$o = TextFormat::RED . "You do not have permission to use this subcommand."; + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); } break; case "create": @@ -587,21 +595,27 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $this->saveAreas(); unset($this->firstPosition[$playerName], $this->secondPosition[$playerName]); - $o = TextFormat::AQUA . "Area created!"; + //$o = TextFormat::AQUA . "Area created!"; + $o = TextFormat::AQUA . Language::translate("area-created"); }else{ - $o = TextFormat::RED . "An area with that name already exists."; + //$o = TextFormat::RED . "An area with that name already exists."; + $o = TextFormat::RED . Language::translate("area-name-excist"); } }else{ - $o = TextFormat::RED . "Enter a name for the area (/fe create )."; + //$o = TextFormat::RED . "Enter a name for the area (/fe create )."; + $o = TextFormat::RED . Language::translate("give-area-name") . ' (/fe create )' ; } }else{ - $o = TextFormat::RED . "Please select both positions first."; + //$o = TextFormat::RED . "Please select both positions first."; + $o = TextFormat::RED . Language::translate("select-both-pos-first"); } }else{ - $o = TextFormat::RED . "Please specify a name for this area (/fe create )."; + //$o = TextFormat::RED . "Please specify a name for this area (/fe create )."; + $o = TextFormat::RED . Language::translate("give-area-name") . ' (/fe create )'; } }else{ - $o = TextFormat::RED . "You do not have permission to use this subcommand."; + //$o = TextFormat::RED . "You do not have permission to use this subcommand."; + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); } break; @@ -610,6 +624,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar if(isset($args[1])){ if(isset($this->areas[strtolower($args[1])])){ if(isset($args[2])){ + $ar = $args[1]; unset($args[0]); unset($args[1]); @@ -617,18 +632,24 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $area = $this->areas[strtolower($ar)]; $area->desc = $desc; $this->saveAreas(); - $o = TextFormat::GREEN . "Area ". TextFormat::LIGHT_PURPLE . $area->getName() . TextFormat::GREEN . " description saved"; + //$o = TextFormat::GREEN . "Area ". TextFormat::LIGHT_PURPLE . $area->getName() . TextFormat::GREEN . " description saved"; + $o = TextFormat::GREEN . Language::translate("area") . ' ' . TextFormat::LIGHT_PURPLE . $area->getName() . ' ' . TextFormat::GREEN . Language::translate("desc-saved"); + }else{ - $o = TextFormat::RED . "Please write the description. Usage /fe desc <..>"; + //$o = TextFormat::RED . "Please write the description. Usage /fe desc <..>"; + $o = TextFormat::RED . Language::translate("desc-write-usage"); } }else{ - $o = TextFormat::RED . "Area does not exist."; + //$o = TextFormat::RED . "Area does not exist."; + $o = TextFormat::RED . Language::translate("area-not-excist"); } }else{ - $o = TextFormat::RED . "Please specify an area to edit the description. Usage: /fe desc "; + //$o = TextFormat::RED . "Please specify an area to edit the description. Usage: /fe desc "; + $o = TextFormat::RED . Language::translate("desc-specify-area"); } }else{ - $o = TextFormat::RED . "You do not have permission to use this subcommand."; + //$o = TextFormat::RED . "You do not have permission to use this subcommand."; + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); } break; @@ -664,14 +685,15 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } if( $i > 0 ){ $o .= TextFormat::DARK_PURPLE ."---- Area list ----\n"; - $o .= TextFormat::GRAY . "level " . TextFormat::YELLOW . $lvl->getName() .":\n". $t; + $o .= TextFormat::GRAY . Language::translate("level") .' ' . TextFormat::YELLOW . $lvl->getName() .":\n". $t; } } if($o != ''){ $o .= TextFormat::DARK_PURPLE ."----------------\n"; } if($o == ''){ - $o = "There are no areas that you can edit"; + //$o = "There are no areas that you can edit"; + $o = TextFormat::GRAY . Language::translate("area-no-area-to-edit"); } } break; @@ -689,14 +711,16 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } } if($o === "") { - $o = TextFormat::RED . "You are in an unknown area"; + //$o = TextFormat::RED . "You are in an unknown area"; + $o = TextFormat::RED . Language::translate("in-unknown-area"); } } break; case "tp": if (!isset($args[1])){ - $o = TextFormat::RED . "You must specify an existing Area name"; + //$o = TextFormat::RED . "You must specify an existing Area name"; + $o = TextFormat::RED . Language::translate("specify-excisting-area-name"); break; } if( isset( $this->areas[strtolower($args[1])] ) ){ @@ -709,7 +733,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $levelName = $area->getLevelName(); if(isset($levelName) && Server::getInstance()->loadLevel($levelName) != false){ - $o = TextFormat::GREEN . "You are teleporting to Area " . $args[1]; + $o = TextFormat::GREEN . Language::translate("tp-to-area-active") .' ' . $args[1]; $cx = $area->getSecondPosition()->getX() + ( ( $area->getFirstPosition()->getX() - $area->getSecondPosition()->getX() ) / 2 ); $cz = $area->getSecondPosition()->getZ() + ( ( $area->getFirstPosition()->getZ() - $area->getSecondPosition()->getZ() ) / 2 ); $cy1 = min( $area->getSecondPosition()->getY(), $area->getFirstPosition()->getY()); @@ -719,14 +743,14 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } $sender->teleport( new Position( $cx, $cy2 - 2, $cz, $area->getLevel() ) ); }else{ - $o = TextFormat::RED . "The level " . $levelName . " for Area ". $args[1] ." cannot be found"; + $o = TextFormat::RED . Language::translate("the-level") . " " . $levelName . " " . Language::translate("for-area") ." ". $args[1] ." ". Language::translate("cannot-be-found"); } }else{ - $o = TextFormat::RED . "You do not have permission to use this subcommand."; + $o = TextFormat::RED .Language::translate("cmd-noperms-subcommand"); } }else{ $list = $this->listAllAreas(); - $o = TextFormat::RED . "The Area " . $args[1] . " could not be found. ". $list; + $o = TextFormat::RED . Language::translate("the-area"). " " . $args[1] . " ". Language::translate("cannot-be-found"). $list; } break; @@ -806,20 +830,20 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar }else{ $status = "off"; } - $o = TextFormat::GREEN . "Flag " . $flag . " set to " . $status . " for area " . $area->getName() . "!"; + $o = TextFormat::GREEN . Language::translate("flag") . " " . $flag . " ". Language::translate("set-to") . " " . $status . " ". Language::translate("for-area") . " " . $area->getName() . "!"; }else{ if(isset($args[2])){ // excute long (old) notation if( $args[2] == "list" ){ $flgs = $area->getFlags(); - $l = $area->getName() . TextFormat::GRAY . " flags:"; + $l = $area->getName() . TextFormat::GRAY . " " . Language::translate("flags"). ":"; foreach($flgs as $fi => $flg){ $l .= "\n". TextFormat::GOLD . " ". $fi . ": "; if( $flg ){ - $l .= TextFormat::GREEN . "on"; + $l .= TextFormat::GREEN . Language::translate("status-on"); }else{ - $l .= TextFormat::RED . "off"; + $l .= TextFormat::RED . Language::translate("status-off"); } } $o = $l; @@ -841,22 +865,29 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar }else{ $status = "off"; } - $o = TextFormat::GREEN . "Flag " . $flag . " set to " . $status . " for area " . $area->getName() . "!"; + //$o = TextFormat::GREEN . "Flag " . $flag . " set to " . $status . " for area " . $area->getName() . "!"; + $o = TextFormat::GREEN . Language::translate("flag") . " " . $flag . " ". Language::translate("set-to") . " " . $status . " ". Language::translate("for-area") . " " . $area->getName() . "!"; }else{ - $o = TextFormat::RED . "Flag not found. (Flags: god, pvp, flight, edit, touch, animals, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; + + //$o = TextFormat::RED . "Flag not found. (Flags: god, pvp, flight, edit, touch, animals, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; + $o = TextFormat::RED . Language::translate("flag-not-found-list"); } }else{ - $o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, animals, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; + //$o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, animals, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; + $o = TextFormat::RED . Language::translate("flag-not-found-list"); } } }else{ - $o = TextFormat::RED . "Area doesn't exist."; + //$o = TextFormat::RED . "Area doesn't exist."; + $o = TextFormat::RED . Language::translate("area-not-excist"); } }else{ - $o = TextFormat::RED . "Please specify the area you would like to flag."; + //$o = TextFormat::RED . "Please specify the area you would like to flag."; + $o = TextFormat::RED . Language::translate("specify-to-flag"); } }else{ - $o = TextFormat::RED . "You do not have permission to use this subcommand."; + //$o = TextFormat::RED . "You do not have permission to use this subcommand."; + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); } break; @@ -868,15 +899,19 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar if(isset($this->areas[strtolower($args[1])])){ $area = $this->areas[strtolower($args[1])]; $area->delete(); - $o = TextFormat::GREEN . "Area deleted!"; + //$o = TextFormat::GREEN . "Area deleted!"; + $o = TextFormat::GREEN . Language::translate("area-deleted"); }else{ - $o = TextFormat::RED . "Area does not exist."; + //$o = TextFormat::RED . "Area does not exist."; + $o = TextFormat::RED . Language::translate("area-not-excist"); } }else{ - $o = TextFormat::RED . "Please specify an area to delete."; + //$o = TextFormat::RED . "Please specify an area to delete."; + $o = TextFormat::RED . Language::translate("specify-to-delete"); } }else{ - $o = TextFormat::RED . "You do not have permission to use this subcommand."; + //$o = TextFormat::RED . "You do not have permission to use this subcommand."; + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); } break; @@ -924,7 +959,8 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o = TextFormat::RED . "Area doesn't exist. Usage: /area whitelist [player]"; } }else{ - $o = TextFormat::RED . "You do not have permission to use this subcommand."; + //$o = TextFormat::RED . "You do not have permission to use this subcommand."; + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); } break; @@ -955,35 +991,36 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar if( isset($area->events[$do]) ){ $eventarr = explode(",", $area->events[$do] ); if(in_array($cid,$eventarr)){ - $o = TextFormat::RED .'Command id:'.$cid.' allready set for area '.$do.'-event.'; + $o = TextFormat::RED . Language::translate("cmd-id").': ' . $cid . ' ' . Language::translate("allready-set-for-area") . ' ' . $do . Language::translate("-event") ; }else{ $eventarr[] = $cid; $eventstr = implode(",", $eventarr ); $area->events[$do] = $eventstr; - $o = TextFormat::RED .'Command id:'.$cid.' set for area '.$do.'-event'; + $o = TextFormat::GREEN . Language::translate("cmd-id") .': ' . $cid . ' ' . Language::translate("set-for-area") . ' ' . $do . Language::translate("-event"); } }else{ $area->events[$do] = $cid; - $o = TextFormat::RED .'Command id:'.$cid.' set for area '.$do.'-event'; + $o = TextFormat::RED .Language::translate("cmd-id").': ' . $cid . ' ' . Language::translate("set-for-area") . ' ' . $do . Language::translate("-event"); } + $area->commands[$cid] = $commandstring; $this->saveAreas(); - $o = TextFormat::GREEN .'Command (id:'.$cid.') added to area '.$ar; + $o = TextFormat::GREEN . Language::translate("cmd-id") .' ' . $cid . ' ' . Language::translate("added-to-area") . ' ' .$ar; }else{ - $o = TextFormat::RED .'Command id:'.$cid.' allready used for '.$ar.', edit this id or use another id.'; + $o = TextFormat::RED . Language::translate("cmd-id").': ' . $cid . ' ' . Language::translate("allready-set-for-area") . ' ' . $ar. ', ' . Language::translate("edit-id-or-other"); } }else{ - $o = TextFormat::RED .'Please specify the command ID and command string to add. Usage: /fe command add '; + $o = TextFormat::RED . Language::translate("cmd-specify-id-and-command-usage"); } break; case "list": $ar = $this->areas[strtolower($args[1])]; if( isset($ar->commands) ){ - $o = TextFormat::WHITE . $args[1] . TextFormat::AQUA .' command list:'; + $o = TextFormat::WHITE . $args[1] . TextFormat::AQUA .' '. Language::translate("cmd-list").': '; foreach($ar->events as $type => $list){ if( trim($list,",") != "" ){ - $o .= "\n". TextFormat::YELLOW ."On ". $type . ":"; + $o .= "\n". TextFormat::YELLOW . $type . ": "; $cmds = explode(",", trim($list,",") ); foreach($cmds as $cmdid){ if(isset($ar->commands[$cmdid])){ @@ -1032,9 +1069,9 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } if($ts == 1){ $this->saveAreas(); - $o = TextFormat::GREEN .'Command (id:'.$cid.') event is now '.$evt; + $o = TextFormat::GREEN . Language::translate("cmd-id") .' '.$cid.' '. Language::translate("event-is-now").' '.$evt; }else{ - $o = TextFormat::RED .'Command (id:'.$cid.') event '.$evt.' change failed'; + $o = TextFormat::RED . Language::translate("cmd-id") .' '.$cid.' '.Language::translate("event").' '.$evt.' '. Language::translate("change-failed"); } } } @@ -1054,12 +1091,12 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar if( isset($cmds[$cid]) ){ $area->commands[$cid] = $commandstring; $this->saveAreas(); - $o = TextFormat::GREEN .'Command (id:'.$cid.') edited'; + $o = TextFormat::GREEN . Language::translate("cmd-id"). ' '.$cid.' edited'; }else{ - $o = TextFormat::RED .'Command id:'.$cid.' could not be found. Check the command id with /fe command list'; + $o = TextFormat::RED .Language::translate("cmd-id"). ' '.$cid.' '. Language::tranlate("cannot-be-found") .' ( /fe command list)'; } }else{ - $o = TextFormat::RED .'Please specify the command ID and command string to add. Usage: /fe command add '; + $o = TextFormat::RED .Language::tranlate("cmd-specify-id-and-command-usage"); } break; From d93897757b3845f021e7205d729414d9ffe8eec1 Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 16 Sep 2018 23:42:51 +0200 Subject: [PATCH 41/68] Translations complete (english/dutch) --- config.yml | 172 +++++++++++++++++++++++ resources/config.yml | 4 +- resources/en.json | 47 ++++++- resources/nl.json | 53 ++++++-- src/genboy/Festival/Main.php | 257 +++++++++++++++++++---------------- 5 files changed, 401 insertions(+), 132 deletions(-) create mode 100644 config.yml diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..0fbbc20 --- /dev/null +++ b/config.yml @@ -0,0 +1,172 @@ +# Config file for Festival + +# Festival options +Options: + # select a language: English = en, Dutch = nl, translate please ! + Language: en + + # Area Messages Display position (msg/title/tip/pop) + Msgtype: msg + + # Area Messages persist display to ops (off/op/on) + Msgdisplay: off + + # Auto whitelist area creator (on/off) + AutoWhitelist: on + +# Flag settings for unprotected areas +# Flag rule: a flag protects the area and the players in it +# These are the default flags, default flags for new worlds and defaults for individual worlds: +Default: + + # Keep players from getting hurt? (true = Player god mode) + God: false + + # Keep players from getting hurt by other players? (true = NoPVP) + PVP: false + + # Keep players from flying? (true = NoFlight) + Flight: true + + # Keep players from editing the world? (true = NoEdit) + Edit: true + + # Keep players from touching blocks and activating things like chests? (true = NoTouching) + Touch: false + + # Prevent Animal Entities from spawning? (true = NoAnimals) + Animals: false + + # Prevent Mob Entities from spawning? (true = NoMobs) + Mobs: false + + # Keep players from having effects like speed or night vision? (true = NoEffects) + Effects: false + + # Keep players from seeing enter/leave/description messages? (true = NoMessages) + Msg: false + + # Prevent players from enter/leaving the area? (barrier) (true = NoPassage) + Passage: false + + # Keep players from dropping items in the area? (true = NoDropping) + Drop: false + + # No explosions allowed in the area? (true = NoExplosions) + TNT: false + + # No shooting allowed in the area? (true = NoShooting) + Shoot: false + + # Keep players from hunger(exhaust) in the area? (true = NoExhaust) + Hunger: false + + # Keep players from executing area event commands without specific perms (true = No Op Permissons) + Perms: false + + # Keep players from taking fall damage (true = NoFallDamage) + FallDamage: true + +# Settings for unprotected areas in individual worlds: +Worlds: + + # New worlds (ie. automatic generated) + DEFAULT: + + # Keep players from getting hurt? (true = Player god mode) + God: false + + # Keep players from getting hurt by other players? (true = NoPVP) + PVP: false + + # Keep players from flying? (true = NoFlight) + Flight: true + + # Keep players from editing the world? (true = NoEdit) + Edit: true + + # Keep players from touching blocks and activating things like chests? (true = NoTouching) + Touch: false + + # Prevent Animal Entities from spawning? (true = NoAnimals) + Animals: false + + # Prevent Mob Entities from spawning? (true = NoMobs) + Mobs: false + + # Keep players from having effects like speed or night vision? (true = NoEffects) + Effects: false + + # Keep players from seeing enter/leave/description messages? (true = NoMessages) + Msg: false + + # Prevent players from enter/leaving the area? (barrier) (true = NoPassage) + Passage: false + + # Keep players from dropping items in the area? (true = NoDropping) + Drop: false + + # No explosions allowed in the area? (true = NoExplosions) + TNT: false + + # No shooting allowed in the area? (true = NoShooting) + Shoot: false + + # Keep players from hunger(exhaust) in the area? (true = NoExhaust) + Hunger: false + + # Keep players from executing area event commands without specific perms (true = No Op Permissons) + Perms: false + + # Keep players from taking fall damage (true = NoFallDamage) + FallDamage: true + + world: + + # Keep players from getting hurt? (true = Player god mode) + God: false + + # Keep players from getting hurt by other players? (true = NoPVP) + PVP: false + + # Keep players from flying? (true = NoFlight) + Flight: true + + # Keep players from editing the world? (true = NoEdit) + Edit: true + + # Keep players from touching blocks and activating things like chests? (true = NoTouching) + Touch: false + + # Prevent Animal Entities from spawning? (true = NoAnimals) + Animals: false + + # Prevent Mob Entities from spawning? (true = NoMobs) + Mobs: false + + # Keep players from having effects like speed or night vision? (true = NoEffects) + Effects: false + + # Keep players from seeing enter/leave/description messages? (true = NoMessages) + Msg: false + + # Prevent players from enter/leaving the area? (barrier) (true = NoPassage) + Passage: false + + # Keep players from dropping items in the area? (true = NoDropping) + Drop: false + + # No explosions allowed in the area? (true = NoExplosions) + TNT: false + + # No shooting allowed in the area? (true = NoShooting) + Shoot: false + + # Keep players from hunger(exhaust) in the area? (true = NoExhaust) + Hunger: false + + # Keep players from executing area event commands without specific perms (true = No Op Permissons) + Perms: false + + # Keep players from taking fall damage (true = NoFallDamage) + FallDamage: true diff --git a/resources/config.yml b/resources/config.yml index 5dea8a5..3641258 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -5,8 +5,8 @@ Options: # select a language: English = en, Dutch = nl, translate please ! language: en - # Area Messages Display position (tip/pop) - Msgtype: pop + # Area Messages Display position (msg/title/tip/pop) + Msgtype: msg # Area Messages persist display to ops (off/op/on) Msgdisplay: off diff --git a/resources/en.json b/resources/en.json index 68d782c..9087189 100644 --- a/resources/en.json +++ b/resources/en.json @@ -2,7 +2,7 @@ "language-name": "English", "language-selected": "Now selected English.", - "enabled-console-msg": "Festival now enabled, testing in English.", + "enabled-console-msg": "Festival now enabled, English selected (adjust with /fe lang ).", "cmd-ingameonly-msg": "Festival command only to be used in-game.", "cmd-unknown-msg": "Unknown Festival command", @@ -24,21 +24,33 @@ "areas": "areas", "level": "level", "level": "levels", + "player": "player", + "players": "players", "the-area": "The area", "the-level": "The level", "area-created": "Area created!", "created-by":"created by", + "area-here": "Area here", "area-no-area-available": "No area available", "area-no-area-to-edit": "There are no areas that you can edit", "area-name-excist": "An area with that name already exists.", "area-not-excist": "Area does not exist.", "cannot-be-found": "cannot be found.", "area-list" : "Area list", + "players-in-area": "players in area", + "area-whitelist": "whitelist", + "area-no-commands": "no commands attachted", + "player-has-been-whitelisted": "has been whitelisted in area", + "player-allready-whitelisted": "is allready whitelisted in area", + "player-has-been-unwhitelisted": "has been unwhitelisted from area", + "player-allready-unwhitelisted": "is allready unwhitelisted from area", + "whitelist-specify-action": "Please specify a valid action. Usage: /area whitelist ", "desc-saved": "description saved.", "desc-write-usage": "Please write the description. Usage /fe desc <..>", "desc-specify-area": "Please specify an area to edit the description. Usage: /fe desc ", + "area-deleted": "Area deleted!", "deleted-by":"deleted by", "specify-to-delete":"Please specify an area to delete.", @@ -46,7 +58,8 @@ "flag": "Flag", "flags": "flags", - "flag-not-found-list": "Flag not found. (Flags: edit, god, touch, effects, msg, passage, perms, drop)", + "flag-not-found-list": "Flag not found. (Flags: god, pvp, flight, edit, touch, animals, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)", + "flag-not-specified-list": "Please specify a flag. (Flags: god, pvp, flight, edit, touch, animals, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)", "specify-to-flag": "Please specify the area you would like to flag.", "tp-to-area-active": "You are teleporting to Area", @@ -54,7 +67,7 @@ "cmd": "command", "cmds": "commands", - "cmd-id": "command id", + "cmd-id": "Command id", "cmd-list": "Command list", "-event": "-event", "set-for-area": "set for area", @@ -63,6 +76,12 @@ "allready-set-for-area": "allready set for area", "edit-id-or-other": ", edit this id or use another id", "cmd-specify-id-and-command-usage": "Please specify the command ID and command string to add. Usage: /fe command add ", + "cmd-valid-areaname": "Area not found, please submit a valid name. Usage: /fe command .", + + + "cmd-id-not-found": "Command ID not found. See the commands with /fe event command list'", + "cmd-specify-id-to-delete": "Please specify the command ID to delete. Usage /fe event command del ", + "cmd-specify-action": "Please add an action to perform with command. Usage: /fe command .", "event": "event", "event-is-now": "event is now", @@ -73,5 +92,25 @@ "status-on": "on", "status-off": "off", "set-to": "set to", - "for-area": "for area" + "for-area": "for area", + + "all-players-are-god": "All players are God in this Area!", + "no-pvp-area": "You are in a No-PVP Area!", + "no-flight-area": "NO Flying here!", + "flight-area": "Flying allowed here!", + + "leaving-area": "leaving", + "enter-area": "enter", + "leaving-center-area": "Leaving the center of area", + "enter-center-area": "Enter the center of area", + "cannot-enter-area": "You can not enter area", + "cannot-leave-area": "You can not leave area", + "enter-barrier-area": "just past a barrier!", + + "option-missing-in-config": "option missing in config.yml, now set to", + "flag-missing-in-config": "flag defaults missing, now set to", + "barrier-is-passage-flag": "Old Barrier config was used, now set to 'false'; please rename 'Barrier' to 'Passage' in config.yml", + "no-is-falldamage-flag": "Old Barrier config was used, now set to 'false'; please rename 'Barrier' to 'Passage' in config.yml", + "option-see-configfile": "please see original configs in /resources/config.yml" + } diff --git a/resources/nl.json b/resources/nl.json index 89d288b..47c0d34 100644 --- a/resources/nl.json +++ b/resources/nl.json @@ -2,14 +2,13 @@ "language-name": "Nederlands", "language-selected": "Nederlands geselecteerd.", - "enabled-console-msg": "Festival opgestart, test in het Nederlands.", + "enabled-console-msg": "Festival opgestart, Nederlands geselecteerd (pas aan met /fe lang )", "cmd-ingameonly-msg": "Commando alleen voor gebruik in het spel.", "cmd-unknown-msg": "Onbekend Festival commando", "cmd-noperms-msg": "Je kunt dit commando niet gebruiken", "cmd-noperms-subcommand": "Je hebt geen toestemming om dit subcommando te gebruiken.", - "pos-select-active": "Je bent al een coordinaat aan het selecteren!", "select-both-pos-first":"Je moet eerst allebei de coordinaten selecteren.", "pos1": "coordinaat 1", @@ -24,33 +23,44 @@ "areas": "gebieden", "level": "level", "level": "levels", + "player": "speler", + "players": "spelers", "the-area": "Het gebied", "the-level": "Het level", "area-created": "Gebied gemaakt!", "created-by":"gemaakt door", + "area-here": "Gebied hier", "area-no-area-available": "Geen gebied beschikbaar", "area-no-area-to-edit": "Er zijn geen gebieden die je kunt bewerken", "area-name-excist": "Een gebied met die naam bestaat al.", "area-not-excist": "Gebied bestaat niet.", "cannot-be-found": "kan niet gevonden worden.", "area-list" : "Lijst met gebieden", + "players-in-area": "spelers in gebied", + "area-whitelist": "whitelist", + "area-no-commands": "geen commando's gekoppeld", + "player-has-been-whitelisted": "is whitelisted in gebied", + "player-allready-whitelisted": "is al whitelisted in gebied", + "player-has-been-unwhitelisted": "is unwhitelisted van gebied", + "player-allready-unwhitelisted": "is al unwhitelisted van gebied", + "whitelist-specify-action": "Geef een actie op. Gebruik: /area whitelist ", "desc-saved": "omschrijving opgeslagen.", "desc-write-usage": "Schrijf de beschrijving. Gebruik /fe desc <..>", "desc-specify-area": "Geef een gebied aan om de omschrijving aan te passen. Gebruik: /fe desc ", - "area-deleted": "Geied verwijderd!", + "area-deleted": "Gebied verwijderd!", "deleted-by":"verwijderd door", - "specify-to-delete":"Geef een gebied aan om te verwijderen.", - + "specify-to-delete":"Geef de naam van het gebied aan om te verwijderen. (zie /fe list)", "flag": "Flag", "flags": "flaggen", - "flag-not-found-list": "Flag niet gevonden. (Flaggen: edit, god, touch, effects, msg, passage, perms, drop)", - "specify-to-flag": "Geef het geid aan om te vlaggen.", + "flag-not-found-list": "Flag niet gevonden. (Flaggen: god, pvp, flight, edit, touch, animals, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)", + "flag-not-specified-list": "Specificeer een vlag. (Flaggen: god, pvp, flight, edit, touch, animals, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)", + "specify-to-flag": "Geef de naam van het gebied op om te vlaggen.", "tp-to-area-active": "Je teleporteerd naar gebied", - "specify-excisting-area-name": "Geef een bestaande naam van een gebied.", + "specify-excisting-area-name": "Geef een bestaande naam van een gebied. (zie /fe list)", "cmd": "Commando", "cmds": "Commando's", @@ -64,6 +74,11 @@ "edit-id-or-other": ", bewerk deze id of bewerk een andere id", "cmd-specify-id-and-command-usage": "Geef een uniek id en commando regel om toe te voegen. Gebruik: /fe command add ", + "cmd-valid-areaname": "Gebier niet gevinden, geef een bestande naam op. Gebruik: /fe command .", + "cmd-id-not-found": "Command ID niet gevonden. Bekijk de commando's met /fe event command list", + "cmd-specify-id-to-delete": "Geef het comando ID om het te verwijderen. Gebruik /fe event command del ", + "cmd-specify-action": "Voeg een actie toe voor het commando. Geruik: /fe command .", + "event": "event", "event-is-now": "event is nu", "change-failed": "change-failed!", @@ -73,5 +88,25 @@ "status-on": "aan", "status-off": "uit", "set-to": "aangepast naar", - "for-area": "voor gebied" + "for-area": "voor gebied", + + "all-players-are-god": "Alle spelers zajin in god-mode in dit gebied!", + "no-pvp-area": "Dit is geen PVP area!", + "no-flight-area": "Vliegen is hier niet toegstaan!", + "flight-area": "Vliegen is hier toegestaand!", + + "leaving-area": "verlaat", + "enter-area": "betreedt", + "leaving-center-area": "Verlaat het midden van gebied", + "enter-center-area": "Betreedt het midden van gebied", + "cannot-enter-area": "Je kunt dit gebied niet betreden", + "cannot-leave-area": "Je kunt dit gebied niet verlaten", + "enter-barrier-area": "passeerde net een grens van een geblokeerd gebied!", + + "option-missing-in-config": "optie mist in config.yml, nu aangepast naar", + "flag-missing-in-config": "vlag default ontbreekt, nu aangepast naar", + "barrier-is-passage-flag": "Oude Barrier config gebruikt, nu aangepast naar 'false'; Hernoem 'Barrier' naar 'Passage' in config.yml", + "no-is-falldamage-flag": "Oude Nofalldamge config gebruikt, nu aangepast naar 'false'; Hernoem 'Nofalldamage' naar 'falldamage' in config.yml", + "option-see-configfile": "zie originele configs in /resources/config.yml" + } diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 2c2883c..5a51af2 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -131,96 +131,42 @@ public function onEnable() : void{ $newchange['Config'] = 'Festival setup..'; } - // innitialize default flags & update data - $data = json_decode(file_get_contents($this->getDataFolder() . "areas.json"), true); - - if( isset( $data ) && is_array( $data ) ){ - foreach($data as $datum){ - $flags = $datum["flags"]; - if( isset($datum["flags"]["barrier"]) ){ - $flags["passage"] = $datum["flags"]["barrier"]; // replaced in v1.0.5-11 can use both - unset($flags["barrier"]); - $newchange['Passage'] = "! Old Barrier config was used, now set to 'false'; please rename 'Barrier' to 'Passage' in config.yml"; - } - if( !isset($datum["flags"]["perms"]) ){ // new flags v 1.0.5-12 - $flags["perms"] = false; - $newchange['Perms'] = "! Area Perms flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["drop"]) ){ // new flags v 1.0.5-12 - $flags["drop"] = false; - $newchange['Drop'] = "! Area Drop flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["animals"]) ){ // new flags v 1.0.7.5-dev - $flags["animals"] = false; - $newchange['Animals'] = "! Area Animals flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["mobs"]) ){ // new flags v 1.0.7.5-dev - $flags["mobs"] = false; - $newchange['Mobs'] = "! Area Mobs flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["effects"]) ){ // new flags v 1.0.5-12 - $flags["effects"] = false; - $newchange['Effects'] = "! Area Effects flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["pvp"]) ){ //new flags v 1.0.6-13 - $flags["pvp"] = false; - $newchange['PVP'] = "! Area PVP flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["flight"]) ){ //new flags v 1.0.6-13 - $flags["flight"] = false; - $newchange['Flight'] = "! Area Flight flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["tnt"]) ){ // new flags v 1.0.7 - $flags["tnt"] = false; - $newchange['TNT'] = "! Area TNT flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["hunger"]) ){ // new flags v 1.0.7 - $flags["hunger"] = false; - $newchange['Hunger'] = "! Area Hunger flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( isset($datum["flags"]["nofalldamage"]) ){ - $flags["falldamage"] = $datum["flags"]["nofalldamage"]; // replaced in v1.0.5-11 can use both - unset($flags["nofalldamage"]); - $newchange['FallDamage'] = "! Old NoFallDamage config was used, now set to 'false'; please rename 'NoFallDamage' to 'FallDamage' in config.yml"; - } - if( !isset($datum["flags"]["falldamage"]) ){ //new in v1.0.7.3 - $flags["falldamage"] = false; - $newchange['FallDamage'] = "! Area FallDamage flag missing, now updated to 'false'; please see /resources/config.yml"; - } - if( !isset($datum["flags"]["shoot"]) ){ //new in v1.0.7.4 - $flags["shoot"] = false; - $newchange['Shoot'] = "! Area Shoot flag missing (alias launch), 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); - } + /** load default language translation class */ + $this->loadLanguage(); - } $c = yaml_parse_file($this->getDataFolder() . "config.yml"); // innitialize configurations & update options if( isset( $c["Options"] ) && is_array( $c["Options"] ) ){ if(!isset($c["Options"]["Language"])){ + $c["Options"]["Language"] = 'en'; - $newchange['Language'] = "! Language option missing in config.yml, now set to 'en' (english); please see latest version of /resources/config.yml"; + $newchange['Msgtype'] = "! Language ".Language::translate("option-missing-in-config")." 'en'; ". Language::translate("option-see-configfile"); + + }else if(isset($c["Options"]["Language"])){ + + $this->loadLanguage($c["Options"]["Language"]); + } if(!isset($c["Options"]["Msgtype"])){ $c["Options"]["Msgtype"] = 'pop'; - $newchange['Msgtype'] = "! Msgtype option missing in config.yml, now set to 'pop'; please see /resources/config.yml"; + $newchange['Msgtype'] = "! Msgtype ".Language::translate("option-missing-in-config")." 'pop'; ". Language::translate("option-see-configfile"); } + if(!isset($c["Options"]["Msgdisplay"])){ $c["Options"]["Msgdisplay"] = 'off'; - $newchange['Msgdisplay'] = "! Msgdisplay option missing in config.yml, now set to 'off'; please see /resources/config.yml"; + $newchange['Msgtype'] = "! Msgdisplay ".Language::translate("option-missing-in-config")." 'off'; ". Language::translate("option-see-configfile"); } if(!isset($c["Options"]["AutoWhitelist"])){ // check since v1.0.5-12 $c["Options"]["AutoWhitelist"] = 'on'; - $newchange['AutoWhitelist'] = "! AutoWhitelist option missing in config.yml, now set to 'on'; please see /resources/config.yml"; + $newchange['Msgtype'] = "! AutoWhitelist ".Language::translate("option-missing-in-config")." 'on'; ". Language::translate("option-see-configfile"); } $this->options = $c["Options"]; }else{ $this->options = array("Language"=>"en", "Msgtype"=>"pop", "Msgdisplay"=>"off", "AutoWhitelist"=>"on"); // Fallback defaults - $newchange['Options'] = "! Config Options missing in config.yml, defaults are set for now; please see /resources/config.yml"; + $newchange['Options'] = "! ".Language::translate("option-missing-in-config")."; ". Language::translate("option-see-configfile"); } // set defaults @@ -341,10 +287,78 @@ public function onEnable() : void{ } } + + // innitialize default flags & update data + $data = json_decode(file_get_contents($this->getDataFolder() . "areas.json"), true); + + if( isset( $data ) && is_array( $data ) ){ + + foreach($data as $datum){ + $flags = $datum["flags"]; + if( isset($datum["flags"]["barrier"]) ){ + $flags["passage"] = $datum["flags"]["barrier"]; // replaced in v1.0.5-11 can use both + unset($flags["barrier"]); + $newchange['Passage'] = "! " . Language::translate("barrier-is-passage-flag"); + } + if( !isset($datum["flags"]["perms"]) ){ // new flags v 1.0.5-12 + $flags["perms"] = false; + $newchange['Msgtype'] = "! Perms ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + if( !isset($datum["flags"]["drop"]) ){ // new flags v 1.0.5-12 + $flags["drop"] = false; + $newchange['Msgtype'] = "! Drop ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + if( !isset($datum["flags"]["animals"]) ){ // new flags v 1.0.7.5-dev + $flags["animals"] = false; + $newchange['Msgtype'] = "! Animals ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + if( !isset($datum["flags"]["mobs"]) ){ // new flags v 1.0.7.5-dev + $flags["mobs"] = false; + $newchange['Msgtype'] = "! Mobs ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + if( !isset($datum["flags"]["effects"]) ){ // new flags v 1.0.5-12 + $flags["effects"] = false; + $newchange['Msgtype'] = "! Effects ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + if( !isset($datum["flags"]["pvp"]) ){ //new flags v 1.0.6-13 + $flags["pvp"] = false; + $newchange['Msgtype'] = "! PVP ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + if( !isset($datum["flags"]["flight"]) ){ //new flags v 1.0.6-13 + $flags["flight"] = false; + $newchange['Msgtype'] = "! Flight ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + if( !isset($datum["flags"]["tnt"]) ){ // new flags v 1.0.7 + $flags["tnt"] = false; + $newchange['Msgtype'] = "! TNT ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + if( !isset($datum["flags"]["hunger"]) ){ // new flags v 1.0.7 + $flags["hunger"] = false; + $newchange['Msgtype'] = "! Hunger ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + if( isset($datum["flags"]["nofalldamage"]) ){ + $flags["falldamage"] = $datum["flags"]["nofalldamage"]; // replaced in v1.0.5-11 can use both + unset($flags["nofalldamage"]); + $newchange['FallDamage'] = "! " . Language::translate("no-is-falldamage-flag"); + } + if( !isset($datum["flags"]["falldamage"]) ){ //new in v1.0.7.3 + $flags["falldamage"] = false; + $newchange['Msgtype'] = "! FallDamage ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + if( !isset($datum["flags"]["shoot"]) ){ //new in v1.0.7.4 + $flags["shoot"] = false; + $newchange['Msgtype'] = "! Shoot ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + 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); + } + + } + + $this->saveAreas(); // all save $this->areaList available :) /** load language translation class */ - $this->loadLanguage(); + $this->loadLanguage( $languageCode = $this->options["Language"] ); /** console output */ $this->getLogger()->info( Language::translate("enabled-console-msg") ); @@ -356,7 +370,6 @@ public function onEnable() : void{ $ca = $ca + count( $a->getCommands() ); } $this->getLogger()->info( $ca .' '. Language::translate("cmds") .' in '. count($this->areas) .' '. Language::translate("areas")); - //$this->getLogger()->info( " ". $ca ." commands in " . count($this->areas) . " areas" ); // warnings changes if( count($newchange) > 0 ){ @@ -374,8 +387,7 @@ public function onEnable() : void{ * @file resources nl.json * @var obj Language */ - public function loadLanguage(){ - $languageCode = $this->options["Language"]; + public function loadLanguage($languageCode = 'en' ){ $resources = $this->getResources(); // read files in resources folder foreach($resources as $resource){ if($resource->getFilename() === "en.json"){ @@ -400,7 +412,7 @@ public function setLanguage( $lang, $player ){ $this->loadLanguage(); // Area Flag text colors GREEN, AQUA, BLUE, RED, WHITE, YELLOW, LIGHT_PURPLE, DARK_PURPLE, GOLD, GRAY $msg = TextFormat::AQUA . Language::translate("language-selected"); - $player->sendMessage( $msg ); + $player->areaMessage( $msg ); } @@ -684,7 +696,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } } if( $i > 0 ){ - $o .= TextFormat::DARK_PURPLE ."---- Area list ----\n"; + $o .= TextFormat::DARK_PURPLE ."---- ".Language::tanslate("area-list")." ----\n"; $o .= TextFormat::GRAY . Language::translate("level") .' ' . TextFormat::YELLOW . $lvl->getName() .":\n". $t; } } @@ -705,7 +717,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar foreach($this->inArea[$playername] as $areaname){ if( isset($this->areaList[ $areaname ]) ){ $area = $this->areaList[$areaname]; - $o .= TextFormat::DARK_PURPLE ."---- Area here ----\n"; + $o .= TextFormat::DARK_PURPLE ."---- ".Language::translate("area-here")." ----\n"; $o .= $this->areaInfoDisplayList( $area ); $o .= TextFormat::DARK_PURPLE ."----------------\n"; } @@ -874,7 +886,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } }else{ //$o = TextFormat::RED . "Please specify a flag. (Flags: god, pvp, flight, edit, touch, animals, mobs, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage)"; - $o = TextFormat::RED . Language::translate("flag-not-found-list"); + $o = TextFormat::RED . Language::translate("flag-not-specified-list"); } } }else{ @@ -926,13 +938,13 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $w = ($this->getServer()->getPlayer($args[3]) instanceof Player ? strtolower($this->getServer()->getPlayer($args[3])->getName()) : strtolower($args[3])); if(!$area->isWhitelisted($w)){ $area->setWhitelisted($w); - $o = TextFormat::GREEN . "Player $w has been whitelisted in area " . $area->getName() . "."; + $o = TextFormat::GREEN . Language::translate("player"). " $w ". Language::translate("player-has-been-whitelisted")." " . $area->getName() . "."; }else{ - $o = TextFormat::RED . "Player $w is already whitelisted in area " . $area->getName() . "."; + $o = TextFormat::RED . "Player $w ". Language::translate("player-allready-whitelisted")." " . $area->getName() . "."; } break; case "list": - $o = TextFormat::AQUA . "Area " . $area->getName() . "'s whitelist:" . TextFormat::RESET; + $o = TextFormat::AQUA . Language::translate("area") . " " . $area->getName() . " ".Language::translate("area-whitelist").":" . TextFormat::RESET; foreach($area->getWhitelist() as $w){ $o .= " $w;"; } @@ -943,20 +955,20 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $w = ($this->getServer()->getPlayer($args[3]) instanceof Player ? strtolower($this->getServer()->getPlayer($args[3])->getName()) : strtolower($args[3])); if($area->isWhitelisted($w)){ $area->setWhitelisted($w, false); - $o = TextFormat::GREEN . "Player $w has been unwhitelisted in area " . $area->getName() . "."; + $o = TextFormat::GREEN . Language::translate("player"). " $w ". Language::translate("player-has-been-unwhitelisted")." " . $area->getName() . "."; }else{ - $o = TextFormat::RED . "Player $w is already unwhitelisted in area " . $area->getName() . "."; + $o = TextFormat::RED . Language::translate("player"). " $w ". Language::translate("player-allready-unwhitelisted")." " . $area->getName() . "."; } break; default: - $o = TextFormat::RED . "Please specify a valid action. Usage: /area whitelist " . $area->getName() . " [player]"; + $o = TextFormat::RED . Language::translate("whitelist-specify-action"); break; } }else{ - $o = TextFormat::RED . "Please specify an action. Usage: /area whitelist " . $area->getName() . " [player]"; + $o = TextFormat::RED . Language::translate("whitelist-specify-action"); } }else{ - $o = TextFormat::RED . "Area doesn't exist. Usage: /area whitelist [player]"; + $o = TextFormat::RED . Language::translate("area-not-excist") . " ( /area whitelist [player] )"; } }else{ //$o = TextFormat::RED . "You do not have permission to use this subcommand."; @@ -1128,10 +1140,12 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $this->saveAreas(); $o = TextFormat::GREEN .'Command (id:'.$cid.') deleted'; }else{ - $o = TextFormat::RED .'Command ID not found. See the commands with /fe event command list'; + //$o = TextFormat::RED .'Command ID not found. See the commands with /fe event command list'; + $o = TextFormat::RED . Language::translate("cmd-id-not-found") . '.'; } }else{ - $o = TextFormat::RED .'Please specify the command ID to delete. Usage /fe event command del '; + //$o = TextFormat::RED .'Please specify the command ID to delete. Usage /fe event command del '; + $o = TextFormat::RED . Language::translate("cmd-specify-id-to-delete") . '.'; } break; @@ -1139,16 +1153,20 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar return false; } }else{ - $o = TextFormat::RED . "Please add an action to perform with command. Usage: /fe command ."; + //$o = TextFormat::RED . "Please add an action to perform with command. Usage: /fe command ."; + $o = TextFormat::RED . Language::translate("cmd-specify-action") . '.'; } }else{ - $o = TextFormat::RED . "Area not found, please submit a valid name. Usage: /fe command ."; + //$o = TextFormat::RED . "Area not found, please submit a valid name. Usage: /fe command ."; + $o = TextFormat::RED . Language::translate("cmd-valid-areaname") . '.'; } }else{ if(!isset($args[1])){ - $o = TextFormat::RED . "Area not found, please submit a valid name. Usage: /fe command ."; + //$o = TextFormat::RED . "Area not found, please submit a valid name. Usage: /fe command ."; + $o = TextFormat::RED . Language::translate("cmd-valid-areaname") . '.'; }else{ - $o = TextFormat::RED . "You do not have permission to use this subcommand."; + //$o = TextFormat::RED . "You do not have permission to use this subcommand."; + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); } } break; @@ -1238,9 +1256,9 @@ public function canPVP(EntityDamageEvent $ev) : bool{ $player = $ev->getDamager(); if( $this->skippTime( 2, strtolower($player->getName()) ) ){ if( $god ){ - $this->areaMessage( 'All players are God in this Area!', $player ); + $this->areaMessage( Language::tranlate("all-players-are-god"), $player ); }else{ - $this->areaMessage( 'You are in a No-PVP Area!', $player ); + $this->areaMessage( Language::tranlate("no-pvp-area"), $player ); } } } @@ -1630,7 +1648,7 @@ public function canShoot( Player $player ) : bool{ if( $m && !$o ){ // 'ínline' message method $msg = TextFormat::RED . "NO Shooting here!"; - $player->sendMessage( $msg ); + $player->areaMessage( $msg ); } return $o; @@ -1746,14 +1764,14 @@ public function onBlockPlace(BlockPlaceEvent $event) : void{ unset($this->selectingFirst[$playerName]); $this->firstPosition[$playerName] = $block->asVector3(); - $player->sendMessage(TextFormat::GREEN . "Position 1 set to: (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); + $player->sendMessage(TextFormat::GREEN . language::translate("pos1")." ". language::translate("set-to"). ": (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); $event->setCancelled(); }elseif(isset($this->selectingSecond[$playerName])){ unset($this->selectingSecond[$playerName]); $this->secondPosition[$playerName] = $block->asVector3(); - $player->sendMessage(TextFormat::GREEN . "Position 2 set to: (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); + $player->sendMessage(TextFormat::GREEN . language::translate("pos2")." ". language::translate("set-to"). ": (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); $event->setCancelled(); }else{ @@ -1787,12 +1805,12 @@ public function onBlockBreak(BlockBreakEvent $event) : void{ if(isset($this->selectingFirst[$playerName])){ unset($this->selectingFirst[$playerName]); $this->firstPosition[$playerName] = $block->asVector3(); - $player->sendMessage(TextFormat::GREEN . "Position 1 set to: (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); + $player->sendMessage(TextFormat::GREEN . language::translate("pos1")." ". language::translate("set-to"). ": (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); $event->setCancelled(); }elseif(isset($this->selectingSecond[$playerName])){ unset($this->selectingSecond[$playerName]); $this->secondPosition[$playerName] = $block->asVector3(); - $player->sendMessage(TextFormat::GREEN . "Position 2 set to: (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); + $player->sendMessage(TextFormat::GREEN . language::translate("pos2")." ". language::translate("set-to"). ": (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); $event->setCancelled(); }else{ if(!$this->canEdit($player, $block)){ @@ -1915,13 +1933,13 @@ public function checkPlayerFlying(Player $player){ $player->setFlying(false); //$player->sendMessage( TextFormat::RED . "NO Flying here!" ); if( $sendmsg ){ - $msg = TextFormat::RED . "NO Flying here!"; + $msg = TextFormat::RED . Language::translate("no-flight-area"); $player->sendMessage( $msg ); } } if( $fly && !$player->isFlying() && !$player->getAllowFlight() ){ if( $sendmsg ){ - $msg = TextFormat::GREEN . "Flying allowed here!"; + $msg = TextFormat::GREEN . Language::translate("flight-area"); $player->sendMessage( $msg ); } } @@ -2034,8 +2052,8 @@ public function AreaPlayerMonitor( Area $area, PlayerMoveEvent $ev ): void{ public function barrierCrossByOp(Area $area, PlayerMoveEvent $ev): void{ $player = $ev->getPlayer(); if( $this->msgOpDsp( $area, $player ) ){ - $msg = TextFormat::WHITE . $area->getName(). TextFormat::RED . " passage barrier detected!"; - $player->sendMessage( $msg ); + $msg = TextFormat::WHITE . $area->getName(). TextFormat::RED . " " . Language::translate("enter-barrier-area"); + $player->areaMessage( $msg ); } return; } @@ -2051,7 +2069,7 @@ public function barrierEnterArea(Area $area, PlayerMoveEvent $ev): void{ $ev->getPlayer()->teleport($ev->getFrom()); if( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ){ if( $this->skippTime( 2, strtolower($player->getName()) ) ){ - $msg = TextFormat::YELLOW . "You can not Enter area " . $area->getName(); + $msg = TextFormat::YELLOW . Language::translate("cannot-enter-area") . " " . $area->getName(); $this->areaMessage( $msg, $player ); } } @@ -2069,7 +2087,7 @@ public function barrierLeaveArea(Area $area, PlayerMoveEvent $ev): void{ $ev->getPlayer()->teleport($ev->getFrom()); if( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ){ if( $this->skippTime( 2, strtolower($player->getName()) ) ){ - $msg = TextFormat::YELLOW . "You can not leave area " . $area->getName(); + $msg = TextFormat::YELLOW . Language::translate("cannot-leave-area") . " " . $area->getName(); } if( $msg != ''){ $this->areaMessage( $msg, $player ); @@ -2088,7 +2106,7 @@ public function enterArea(Area $area, PlayerMoveEvent $ev): void{ $player = $ev->getPlayer(); $msg = ''; if( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ){ - $msg = TextFormat::AQUA . $player->getName() . " enter " . $area->getName(); + $msg = TextFormat::AQUA . $player->getName() . " " .Language::translate("enter-area") . " " . $area->getName(); if( $area->getDesc() ){ $msg .= "\n". TextFormat::WHITE . $area->getDesc(); } @@ -2120,7 +2138,7 @@ public function leaveArea(Area $area, PlayerMoveEvent $ev): void{ $player = $ev->getPlayer(); $msg = ''; if( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ){ - $msg .= TextFormat::YELLOW . $player->getName() . " leaving " . $area->getName(); + $msg .= TextFormat::YELLOW . $player->getName() . " " .Language::translate("leaving-area") . " " . $area->getName(); } if( $msg != ''){ $this->areaMessage( $msg, $player ); @@ -2145,7 +2163,7 @@ public function enterAreaCenter(Area $area, PlayerMoveEvent $ev): void{ $player = $ev->getPlayer(); $msg = ''; if( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ){ - $msg = TextFormat::WHITE . "Enter the center of area " . $area->getName(); + $msg = TextFormat::WHITE . Language::translate("enter-center-area") . " " . $area->getName(); } if( $msg != ''){ $this->areaMessage( $msg, $player ); @@ -2168,7 +2186,7 @@ public function leaveAreaCenter(Area $area, PlayerMoveEvent $ev): void{ $playerName = strtolower( $player->getName() ); $msg = ''; if( !$area->getFlag("msg") || $this->msgOpDsp( $area, $player ) ){ - $msg = TextFormat::WHITE . "Leaving the center of area " . $area->getName(); + $msg = TextFormat::WHITE . Language::translate("leaving-center-area"). " " . $area->getName(); } if( $msg != ''){ $this->areaMessage( $msg, $player ); @@ -2261,7 +2279,12 @@ public function skippTime($sec, $nm){ * @return true function */ public function areaMessage( $msg , $player ){ - if($this->options['Msgtype'] == 'tip'){ + if($this->options['Msgtype'] == 'msg'){ + $player->sendMessage($msg); + }else if( $this->options['Msgtype'] == 'title'){ + $player->addTitle($msg); + // $player->addTitle("Title", "Subtitle", $fadeIn = 20, $duration = 60, $fadeOut = 20); + }else if($this->options['Msgtype'] == 'tip'){ $player->sendTip($msg); }else{ $player->sendPopup($msg); @@ -2314,7 +2337,7 @@ public function listAllAreas(){ } return rtrim($t,','); }else{ - return 'No area available..'; + return Language::translate("area-no-area-available"); } } /** List Area Info @@ -2322,7 +2345,7 @@ public function listAllAreas(){ */ public function areaInfoDisplayList( $area ){ - $l = TextFormat::GRAY . " area " . TextFormat::AQUA . $area->getName(); + $l = TextFormat::GRAY . " " . Language::translate("area") . " " . TextFormat::AQUA . $area->getName(); // Players in area $ap = []; foreach( $this->inArea as $p => $playerAreas ){ @@ -2340,24 +2363,24 @@ public function areaInfoDisplayList( $area ){ } } if(count($ap) > 0 ){ - $l .= "\n". TextFormat::GRAY . " - players in area: \n " . TextFormat::GOLD . implode(", ", $ap ); + $l .= "\n". TextFormat::GRAY . " - ". Language::translate("players-in-area") .": \n " . TextFormat::GOLD . implode(", ", $ap ); } // Area Flag text colors GREEN, AQUA, BLUE, RED, WHITE, YELLOW, LIGHT_PURPLE, DARK_PURPLE, GOLD, GRAY $flgs = $area->getFlags(); - $l .= "\n". TextFormat::GRAY . " - flags:"; + $l .= "\n". TextFormat::GRAY . " - ". Language::translate("flags") ." :"; foreach($flgs as $fi => $flg){ $l .= "\n". TextFormat::GOLD . " ". $fi . ": "; if( $flg ){ - $l .= TextFormat::GREEN . "on"; + $l .= TextFormat::GREEN . Language::translate("status-on"); }else{ - $l .= TextFormat::RED . "off"; + $l .= TextFormat::RED . Language::translate("status-off"); } } // Area Commands by event if( $cmds = $area->getCommands() && count( $area->getCommands() ) > 0 ){ - $l.= "\n". TextFormat::GRAY . " - commands:"; + $l.= "\n". TextFormat::GRAY . " - ".Language::translate("cmds").":"; foreach( $area->getEvents() as $type => $list ){ $ids = explode(",",$list); $l .= "\n". TextFormat::GOLD . " On ". $type; @@ -2368,9 +2391,9 @@ public function areaInfoDisplayList( $area ){ } } }else{ - $l .= TextFormat::GRAY . "\n - no commands attachted"; + $l .= TextFormat::GRAY . "\n - ". Language::translate("area-no-commands"); } - $l .= "\n". TextFormat::GRAY . " - whitelist: " . TextFormat::WHITE . implode(", ", $area->getWhitelist()) . "\n"; + $l .= "\n". TextFormat::GRAY . " - ".Language::translate("area-whitelist").": " . TextFormat::WHITE . implode(", ", $area->getWhitelist()) . "\n"; return $l; } From 35b7eb39403a7acfb67a0ff50c6d3be64f501ec1 Mon Sep 17 00:00:00 2001 From: genboy Date: Mon, 17 Sep 2018 02:17:13 +0200 Subject: [PATCH 42/68] Area Floating Header Test --- src/genboy/Festival/Main.php | 47 +++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 5a51af2..8fec1fb 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -26,6 +26,8 @@ use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\event\entity\EntityExplodeEvent; use pocketmine\event\entity\EntityShootBowEvent; +use pocketmine\event\entity\EntityLevelChangeEvent; +use pocketmine\level\particle\FloatingTextParticle; use pocketmine\event\Listener; use pocketmine\level\Position; use pocketmine\math\Vector3; @@ -33,6 +35,7 @@ use pocketmine\plugin\PluginBase; use pocketmine\utils\TextFormat; use pocketmine\Server; +use pocketmine\event\player\PlayerJoinEvent; use pocketmine\event\player\PlayerMoveEvent; use pocketmine\event\player\PlayerInteractEvent; use pocketmine\event\player\PlayerCommandPreprocessEvent; @@ -494,6 +497,8 @@ public function isFlag( $str ){ return $flag; } + + /** Commands * @param CommandSender $sender * @param Command $cmd @@ -1683,7 +1688,7 @@ public function canEntitySpawn( Entity $e ): bool{ // https://github.com/LeinneSW/EntityManager $o = true; - if( $e instanceof ExperienceOrb || $e instanceof ItemEntity || $e instanceof Projectile){ + if( $e instanceof ExperienceOrb || $e instanceof ItemEntity || $e instanceof Projectile || $e instanceof FloatingTextParticle){ return $o; // allowed } @@ -2425,6 +2430,46 @@ public function saveAreas() : void{ file_put_contents($this->getDataFolder() . "areas.json", json_encode($areas)); } + + + /** onJoin Area Titles for Player ( FloatingTextParticle ) + * @param PlayerJoinEvent $event + */ + public function onJoin(PlayerJoinEvent $event){ + $player = $event->getPlayer(); + $level = $this->getServer()->getDefaultLevel(); + $this->placeAreaTitles( $player, $level ); + } + + /** levelChange Area Titles for Player ( FloatingTextParticle ) + * @param EntityLevelChangeEvent $event + */ + public function levelChange(EntityLevelChangeEvent $event) { + $entity = $event->getEntity(); + if ($entity instanceof Player) { + $level = $event->getTarget(); + $this->placeAreaTitles( $entity, $level ); + } + } + + + /** Set Floating Area Title ( FloatingTextParticle ) + * @param Vector3 $pos + * @param string $text + * @param string $title + */ + public function placeAreaTitles( $player, $level ) : void{ + foreach($this->areas as $area){ + $cx = $area->getSecondPosition()->getFloorX() + ( ( $area->getFirstPosition()->getFloorX() - $area->getSecondPosition()->getFloorX() ) / 2 ); + $cz = $area->getSecondPosition()->getFloorZ() + ( ( $area->getFirstPosition()->getFloorZ() - $area->getSecondPosition()->getFloorZ() ) / 2 ); + $cy = max( $area->getSecondPosition()->getFloorY(), $area->getFirstPosition()->getFloorY()) - 2; + // area set title pos (off, number) + // color TextFormat::DARK_PURPLE . + $areainfotext = new FloatingTextParticle( new Position($cx, $cy, $cz, $area->getLevel() ), "", $area->getName() ); + + $level->addParticle($areainfotext, [$player]); + } + } /** Festival Console Sign Flag for developers * makes it easy to find Festival console output fast */ From f8b3b97f47eeb466fdbd6abbe99216a7bf0a52d2 Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 22 Sep 2018 17:30:27 +0200 Subject: [PATCH 43/68] Area title floating display + info & version update --- README.md | 39 ++++++-- config.yml | 172 ----------------------------------- plugin.yml | 2 +- resources/config.yml | 3 + src/genboy/Festival/Area.php | 1 + src/genboy/Festival/Main.php | 33 +++++-- 6 files changed, 61 insertions(+), 189 deletions(-) delete mode 100644 config.yml diff --git a/README.md b/README.md index 4cd610c..2051b52 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,22 @@ Create a festival with this custom area events plugin for Pocketmine Server: [![](https://poggit.pmmp.io/shield.dl/Festival)](https://poggit.pmmp.io/p/Festival) [issues @ github](https://github.com/genboy/Festival/issues) and/or [reviews @ poggit](https://poggit.pmmp.io/p/Festival) + +!Please before asking first double-check your server basic world configurations, other plugins configurations (ie. worldguard) and the used player permissions incl. Festival whitelistings. #### Features +**Config** +- set default options in config.yml; + - language: en - select language English = en, Dutch = nl, translate please ! + - Msgtype: msg - Area Messages Display position (msg/title/tip/pop) + - Msgdisplay: off - Area Messages persist display to ops (off/op/on) + - Areadisplay: op - Area Floating Title display to ops (off/op/on) + - AutoWhitelist: on - Auto whitelist area creator (on/off) + **Area** -- Create and manage area’s +- Create and manage area’s ingame (like WorldGuard/iProtector) - Define cuboid area by tapping 2 positions @@ -42,11 +52,12 @@ Create a festival with this custom area events plugin for Pocketmine Server: - tp to an area - show area’s info at current position - **Flags** -- Set area flags true means - +- Set area flags ingame + Flags: Any flag true will protect the area and the players in it. + ie. edit: true (on) means no breaking/building by players. shoot: true (on) means no shooting by players. + - 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 @@ -83,6 +94,9 @@ Create a festival with this custom area events plugin for Pocketmine Server: - 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 or, if perms flag true: area uses the player permissions +!Please first check festival and other plugins configs (ie. worldguard) and the used player permissions incl. Festival whitelistings. + + ###### Created by [Genboy](https://genboy.net) 2018 @@ -100,6 +114,8 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). - Standard Plugin installation; Upload .phar file to server 'plugin' folder (or upload .zip if you have latest devtools installed), restart the server, go to folder plugins/Festival; + - read [wiki on configurations](https://github.com/genboy/Festival/wiki/2.-Install,-Configure-&-Update) + - Edit config.yml; set the defaults for options, default area flags and the default area flags for specific worlds. - ##### Read the config comments carefully about how the flags work! @@ -146,7 +162,14 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). - new animals and mobs (spawning) flag - Fixes itemframe and farmland edit - + **New in v1.0.8** + - /fe lang - set Festival language + - Edit flag includes No Farmland creation + - Edit flag includes No Fire from Flint & Steel + - Edit flag includes No TNT placing + - Edit flag includes No TNT ignition with Flint & Steel + - Edit flag includes protect item in frame use + #### Usage Graphic ##### A visualisation of Festival command usage @@ -186,10 +209,12 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). /fe - Area flag defaults are set in the config.yml), server defaults and world specific default flag. + 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 diff --git a/config.yml b/config.yml deleted file mode 100644 index 0fbbc20..0000000 --- a/config.yml +++ /dev/null @@ -1,172 +0,0 @@ -# Config file for Festival - -# Festival options -Options: - # select a language: English = en, Dutch = nl, translate please ! - Language: en - - # Area Messages Display position (msg/title/tip/pop) - Msgtype: msg - - # Area Messages persist display to ops (off/op/on) - Msgdisplay: off - - # Auto whitelist area creator (on/off) - AutoWhitelist: on - -# Flag settings for unprotected areas -# Flag rule: a flag protects the area and the players in it -# These are the default flags, default flags for new worlds and defaults for individual worlds: -Default: - - # Keep players from getting hurt? (true = Player god mode) - God: false - - # Keep players from getting hurt by other players? (true = NoPVP) - PVP: false - - # Keep players from flying? (true = NoFlight) - Flight: true - - # Keep players from editing the world? (true = NoEdit) - Edit: true - - # Keep players from touching blocks and activating things like chests? (true = NoTouching) - Touch: false - - # Prevent Animal Entities from spawning? (true = NoAnimals) - Animals: false - - # Prevent Mob Entities from spawning? (true = NoMobs) - Mobs: false - - # Keep players from having effects like speed or night vision? (true = NoEffects) - Effects: false - - # Keep players from seeing enter/leave/description messages? (true = NoMessages) - Msg: false - - # Prevent players from enter/leaving the area? (barrier) (true = NoPassage) - Passage: false - - # Keep players from dropping items in the area? (true = NoDropping) - Drop: false - - # No explosions allowed in the area? (true = NoExplosions) - TNT: false - - # No shooting allowed in the area? (true = NoShooting) - Shoot: false - - # Keep players from hunger(exhaust) in the area? (true = NoExhaust) - Hunger: false - - # Keep players from executing area event commands without specific perms (true = No Op Permissons) - Perms: false - - # Keep players from taking fall damage (true = NoFallDamage) - FallDamage: true - -# Settings for unprotected areas in individual worlds: -Worlds: - - # New worlds (ie. automatic generated) - DEFAULT: - - # Keep players from getting hurt? (true = Player god mode) - God: false - - # Keep players from getting hurt by other players? (true = NoPVP) - PVP: false - - # Keep players from flying? (true = NoFlight) - Flight: true - - # Keep players from editing the world? (true = NoEdit) - Edit: true - - # Keep players from touching blocks and activating things like chests? (true = NoTouching) - Touch: false - - # Prevent Animal Entities from spawning? (true = NoAnimals) - Animals: false - - # Prevent Mob Entities from spawning? (true = NoMobs) - Mobs: false - - # Keep players from having effects like speed or night vision? (true = NoEffects) - Effects: false - - # Keep players from seeing enter/leave/description messages? (true = NoMessages) - Msg: false - - # Prevent players from enter/leaving the area? (barrier) (true = NoPassage) - Passage: false - - # Keep players from dropping items in the area? (true = NoDropping) - Drop: false - - # No explosions allowed in the area? (true = NoExplosions) - TNT: false - - # No shooting allowed in the area? (true = NoShooting) - Shoot: false - - # Keep players from hunger(exhaust) in the area? (true = NoExhaust) - Hunger: false - - # Keep players from executing area event commands without specific perms (true = No Op Permissons) - Perms: false - - # Keep players from taking fall damage (true = NoFallDamage) - FallDamage: true - - world: - - # Keep players from getting hurt? (true = Player god mode) - God: false - - # Keep players from getting hurt by other players? (true = NoPVP) - PVP: false - - # Keep players from flying? (true = NoFlight) - Flight: true - - # Keep players from editing the world? (true = NoEdit) - Edit: true - - # Keep players from touching blocks and activating things like chests? (true = NoTouching) - Touch: false - - # Prevent Animal Entities from spawning? (true = NoAnimals) - Animals: false - - # Prevent Mob Entities from spawning? (true = NoMobs) - Mobs: false - - # Keep players from having effects like speed or night vision? (true = NoEffects) - Effects: false - - # Keep players from seeing enter/leave/description messages? (true = NoMessages) - Msg: false - - # Prevent players from enter/leaving the area? (barrier) (true = NoPassage) - Passage: false - - # Keep players from dropping items in the area? (true = NoDropping) - Drop: false - - # No explosions allowed in the area? (true = NoExplosions) - TNT: false - - # No shooting allowed in the area? (true = NoShooting) - Shoot: false - - # Keep players from hunger(exhaust) in the area? (true = NoExhaust) - Hunger: false - - # Keep players from executing area event commands without specific perms (true = No Op Permissons) - Perms: false - - # Keep players from taking fall damage (true = NoFallDamage) - FallDamage: true diff --git a/plugin.yml b/plugin.yml index efe3dd6..b233c90 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: Festival author: Genboy -version: 1.0.7.7-dev +version: 1.0.7.8-dev main: genboy\Festival\Main load: POSTWORLD api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0,4.0.0] diff --git a/resources/config.yml b/resources/config.yml index 3641258..abe0451 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -8,6 +8,9 @@ Options: # Area Messages Display position (msg/title/tip/pop) Msgtype: msg + # Area Floatingtext title display (off/op/on) + Areadisplay: op + # Area Messages persist display to ops (off/op/on) Msgdisplay: off diff --git a/src/genboy/Festival/Area.php b/src/genboy/Festival/Area.php index 3ee0f93..571a1fd 100644 --- a/src/genboy/Festival/Area.php +++ b/src/genboy/Festival/Area.php @@ -162,6 +162,7 @@ public function setEvent( string $type, string $cmdid) : array{ return true; } + /** * @param Vector3 $pos * @param string $levelName diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 8fec1fb..0b96500 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -6,6 +6,7 @@ namespace genboy\Festival; use genboy\Festival\lang\Language; +use genboy\Festival\settings; use pocketmine\command\Command; use pocketmine\command\CommandSender; @@ -162,6 +163,13 @@ public function onEnable() : void{ $c["Options"]["Msgdisplay"] = 'off'; $newchange['Msgtype'] = "! Msgdisplay ".Language::translate("option-missing-in-config")." 'off'; ". Language::translate("option-see-configfile"); } + + + if(!isset($c["Options"]["Areadisplay"])){ + $c["Options"]["Areadisplay"] = 'off'; + $newchange['Areadisplay'] = "! Areadisplay ".Language::translate("option-missing-in-config")." 'off'; ". Language::translate("option-see-configfile"); + } + if(!isset($c["Options"]["AutoWhitelist"])){ // check since v1.0.5-12 $c["Options"]["AutoWhitelist"] = 'on'; $newchange['Msgtype'] = "! AutoWhitelist ".Language::translate("option-missing-in-config")." 'on'; ". Language::translate("option-see-configfile"); @@ -352,6 +360,7 @@ public function onEnable() : void{ $flags["shoot"] = false; $newchange['Msgtype'] = "! Shoot ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } + 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); } @@ -701,7 +710,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } } if( $i > 0 ){ - $o .= TextFormat::DARK_PURPLE ."---- ".Language::tanslate("area-list")." ----\n"; + $o .= TextFormat::DARK_PURPLE ."---- ".Language::translate("area-list")." ----\n"; $o .= TextFormat::GRAY . Language::translate("level") .' ' . TextFormat::YELLOW . $lvl->getName() .":\n". $t; } } @@ -2460,14 +2469,20 @@ public function levelChange(EntityLevelChangeEvent $event) { */ public function placeAreaTitles( $player, $level ) : void{ foreach($this->areas as $area){ - $cx = $area->getSecondPosition()->getFloorX() + ( ( $area->getFirstPosition()->getFloorX() - $area->getSecondPosition()->getFloorX() ) / 2 ); - $cz = $area->getSecondPosition()->getFloorZ() + ( ( $area->getFirstPosition()->getFloorZ() - $area->getSecondPosition()->getFloorZ() ) / 2 ); - $cy = max( $area->getSecondPosition()->getFloorY(), $area->getFirstPosition()->getFloorY()) - 2; - // area set title pos (off, number) - // color TextFormat::DARK_PURPLE . - $areainfotext = new FloatingTextParticle( new Position($cx, $cy, $cz, $area->getLevel() ), "", $area->getName() ); - - $level->addParticle($areainfotext, [$player]); + + if( ( $this->options["Areadisplay"] == 'on' && !$area->getFlag("msg") ) || + ( $this->options["Areadisplay"] == 'op' && $player->isOp() ) ){ + + $cx = $area->getSecondPosition()->getFloorX() + ( ( $area->getFirstPosition()->getFloorX() - $area->getSecondPosition()->getFloorX() ) / 2 ); + $cz = $area->getSecondPosition()->getFloorZ() + ( ( $area->getFirstPosition()->getFloorZ() - $area->getSecondPosition()->getFloorZ() ) / 2 ); + $cy = max( $area->getSecondPosition()->getFloorY(), $area->getFirstPosition()->getFloorY()) - 2; + + // area set title pos + $areainfotext = new FloatingTextParticle( new Position($cx, $cy, $cz, $area->getLevel() ), "", TextFormat::AQUA . $area->getName() ); + + $level->addParticle($areainfotext, [$player]); + + } } } /** Festival Console Sign Flag for developers From 8aece5b88748badfca0f712b398128ee6673b01d Mon Sep 17 00:00:00 2001 From: Genboy <30810841+genboy@users.noreply.github.com> Date: Sat, 22 Sep 2018 18:00:00 +0200 Subject: [PATCH 44/68] Update README.md --- README.md | 89 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 2051b52..9b9c435 100644 --- a/README.md +++ b/README.md @@ -128,57 +128,17 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). ##### !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 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: - off = hidden for all players - op = only ops see all area enter/leave messages - on = all players see the area messages - - **Since v1.0.4-11** - - areas are updated with the new flags, configuration should be updated manually; example [resources/config.yml](https://github.com/genboy/Festival/blob/master/resources/config.yml) - - **Since v1.0.5-12** - - - configuration should be updated with AutoWhitelist option & new Effects flag; example [resources/config.yml](https://github.com/genboy/Festival/blob/master/resources/config.yml) - - **Since v1.0.6-13** - - - new PVP flag - - new Flight flag - - /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) - - new shoot flag (experimental no shooting/launching) - - new falldamage flag - - new animals and mobs (spawning) flag - - Fixes itemframe and farmland edit - - **New in v1.0.8** - - /fe lang - set Festival language - - Edit flag includes No Farmland creation - - Edit flag includes No Fire from Flint & Steel - - Edit flag includes No TNT placing - - Edit flag includes No TNT ignition with Flint & Steel - - Edit flag includes protect item in frame use + #### Usage Graphic ##### A visualisation of Festival command usage - ![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/08/festival_usage_1.0.7.2-dev.png) + ![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/08/festival_usage_1.0.7.5-dev.png) ###### Copyright [Genboy](https://genboy.net) 2018 - #### Create area First command '/fe pos1' and tab a block for position 1, @@ -350,8 +310,53 @@ Thank you - [x] Fire (animation) extinguished when player is save - [x] No shooting (bow) - [x] No Fall Damage flag (was implemented as effect for TP dropping and flight break) + + + + ### History + + **Since v1.0.3-11+** + - 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: + off = hidden for all players + op = only ops see all area enter/leave messages + on = all players see the area messages + **Since v1.0.4-11** + + - areas are updated with the new flags, configuration should be updated manually; example [resources/config.yml](https://github.com/genboy/Festival/blob/master/resources/config.yml) + + **Since v1.0.5-12** + + - configuration should be updated with AutoWhitelist option & new Effects flag; example [resources/config.yml](https://github.com/genboy/Festival/blob/master/resources/config.yml) + + **Since v1.0.6-13** + + - new PVP flag + - new Flight flag + - /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) + + **Since 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) + - new shoot flag (experimental no shooting/launching) + - new falldamage flag + - new animals and mobs (spawning) flag + - Fixes itemframe and farmland edit + + **Since v1.0.8** + - /fe lang - set Festival language + - Edit flag includes No Farmland creation + - Edit flag includes No Fire from Flint & Steel + - Edit flag includes No TNT placing + - Edit flag includes No TNT ignition with Flint & Steel + - Edit flag includes protect item in frame use + ------ From feeae5984296f5b4c398940782a18337ea2149ba Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 22 Sep 2018 19:12:54 +0200 Subject: [PATCH 45/68] Areadisplay: op makes floating title also visible for whitelisted players --- src/genboy/Festival/Main.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 0b96500..7923370 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -2470,8 +2470,8 @@ public function levelChange(EntityLevelChangeEvent $event) { public function placeAreaTitles( $player, $level ) : void{ foreach($this->areas as $area){ - if( ( $this->options["Areadisplay"] == 'on' && !$area->getFlag("msg") ) || - ( $this->options["Areadisplay"] == 'op' && $player->isOp() ) ){ + if( ( $this->options["Areadisplay"] == 'on' && ( !$area->getFlag("msg") || $area->isWhitelisted( strtolower( $player->getName() ) ) ) ) || + ( $this->options["Areadisplay"] == 'op' && ( $player->isOp() || $area->isWhitelisted( strtolower( $player->getName() ) ) ) ) ){ $cx = $area->getSecondPosition()->getFloorX() + ( ( $area->getFirstPosition()->getFloorX() - $area->getSecondPosition()->getFloorX() ) / 2 ); $cz = $area->getSecondPosition()->getFloorZ() + ( ( $area->getFirstPosition()->getFloorZ() - $area->getSecondPosition()->getFloorZ() ) / 2 ); From 129d6d7fd37b114064d76e52548f050d3e443477 Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 23 Sep 2018 03:02:43 +0200 Subject: [PATCH 46/68] Area Floating Title ingame toggle for ops and whitelisted players --- src/genboy/Festival/Main.php | 99 ++++++++++++++++++++++++++++++++---- 1 file changed, 89 insertions(+), 10 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 7923370..35b2d6d 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -106,6 +106,10 @@ class Main extends PluginBase implements Listener{ */ private $areaList = []; /** @var array[] + * list of areanames with active floatingtextparticle objects + */ + private $areaTitles = []; + /** @var array[] * list of playernames in a global delay counter per player (skipptime) */ private $skipsec = []; @@ -541,6 +545,28 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } break; + case "titles": + if( $sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->isOp() || $this->isWhitelisted($sender) ){ + if( $this->options["Areadisplay"] == 'op' || $this->options["Areadisplay"] == 'on' ){ + if( isset($this->areaTitles[strtolower($sender->getName())]) && count($this->areaTitles[strtolower($sender->getName())]) > 0 ){ + foreach($this->areas as $area){ + $this->hideAreaTitle( $sender, $sender->getPosition()->getLevel(), $area ); + } + $this->areaTitles = []; + $o = TextFormat::RED . "Area floating titles off!"; + }else{ + $this->checkAreaTitles( $sender, $sender->getPosition()->getLevel() ); + $o = TextFormat::GREEN . "Area floating titles on!"; + } + }else{ + $o = TextFormat::YELLOW . "Area floating titles not available"; + } + }else{ + //$o = TextFormat::RED . "You do not have permission to use this subcommand."; + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); + } + + break; case "pos1": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.pos1")){ if(isset($this->selectingFirst[$playerName]) || isset($this->selectingSecond[$playerName])){ @@ -1899,6 +1925,7 @@ public function canUseEffects( Player $player ) : bool{ } + /** Flight * @param Player $player */ @@ -2447,7 +2474,8 @@ public function saveAreas() : void{ public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $level = $this->getServer()->getDefaultLevel(); - $this->placeAreaTitles( $player, $level ); + $this->areaTitles[strtolower($player->getName())] = []; + $this->checkAreaTitles( $player, $level ); } /** levelChange Area Titles for Player ( FloatingTextParticle ) @@ -2457,34 +2485,85 @@ public function levelChange(EntityLevelChangeEvent $event) { $entity = $event->getEntity(); if ($entity instanceof Player) { $level = $event->getTarget(); - $this->placeAreaTitles( $entity, $level ); + $this->checkAreaTitles( $entity, $level ); } } - /** Set Floating Area Title ( FloatingTextParticle ) + /** Check Floating Area Title placement( FloatingTextParticle ) * @param Vector3 $pos * @param string $text * @param string $title */ - public function placeAreaTitles( $player, $level ) : void{ + public function checkAreaTitles( $player, $level ) : void{ foreach($this->areas as $area){ if( ( $this->options["Areadisplay"] == 'on' && ( !$area->getFlag("msg") || $area->isWhitelisted( strtolower( $player->getName() ) ) ) ) || ( $this->options["Areadisplay"] == 'op' && ( $player->isOp() || $area->isWhitelisted( strtolower( $player->getName() ) ) ) ) ){ - $cx = $area->getSecondPosition()->getFloorX() + ( ( $area->getFirstPosition()->getFloorX() - $area->getSecondPosition()->getFloorX() ) / 2 ); - $cz = $area->getSecondPosition()->getFloorZ() + ( ( $area->getFirstPosition()->getFloorZ() - $area->getSecondPosition()->getFloorZ() ) / 2 ); - $cy = max( $area->getSecondPosition()->getFloorY(), $area->getFirstPosition()->getFloorY()) - 2; + $this->placeAreaTitle( $player, $level, $area ); + + } + } + return; + } - // area set title pos - $areainfotext = new FloatingTextParticle( new Position($cx, $cy, $cz, $area->getLevel() ), "", TextFormat::AQUA . $area->getName() ); - $level->addParticle($areainfotext, [$player]); + /** isWhitelisted global or specific area + * @param Player $player + * @param Area $area + */ + public function isWhitelisted( $player, $area = false ): bool{ + if( $area instanceof Area && $area->isWhitelisted( strtolower( $player->getName() ) ) && $area->getLevel() == $player->getPosition()->getLevel() ){ + return true; + }else{ + foreach($this->areas as $area){ + if( $area->isWhitelisted( strtolower( $player->getName() ) ) && $area->getLevel() == $player->getPosition()->getLevel() ){ + return true; + } } } + return false; + } + + /** Set Floating Area Title ( FloatingTextParticle ) + * @param Player $player + * @param Level $level + * @param Area $area + */ + public function placeAreaTitle( $player, $level, $area ) : void{ + + if( isset($this->areaTitles[strtolower($player->getName())][ $area->getName() ]) ){ + // activate particle + $this->areaTitles[strtolower($player->getName())][ $area->getName() ]->setInvisible(false); + }else{ + $cx = $area->getSecondPosition()->getFloorX() + ( ( $area->getFirstPosition()->getFloorX() - $area->getSecondPosition()->getFloorX() ) / 2 ); + $cz = $area->getSecondPosition()->getFloorZ() + ( ( $area->getFirstPosition()->getFloorZ() - $area->getSecondPosition()->getFloorZ() ) / 2 ); + $cy = max( $area->getSecondPosition()->getFloorY(), $area->getFirstPosition()->getFloorY()) - 2; + // area set title pos + $this->areaTitles[strtolower($player->getName())][ $area->getName() ] = new FloatingTextParticle( new Position($cx, $cy, $cz, $area->getLevel() ), "", TextFormat::AQUA . $area->getName() ); + } + $level->addParticle( $this->areaTitles[strtolower($player->getName())][ $area->getName() ], [$player]); + return; } + + /** Hide Floating Area Title ( FloatingTextParticle ) + * @param Player $player + * @param Level $level + * @param Area $area + */ + public function hideAreaTitle( $player, $level, $area ) : void{ + + if( isset($this->areaTitles[strtolower($player->getName())][ $area->getName() ]) ){ + // hide particle + $this->areaTitles[strtolower($player->getName())][ $area->getName() ]->setInvisible(true); + $level->addParticle( $this->areaTitles[strtolower($player->getName())][ $area->getName() ], [$player]); + } + return; + } + + /** Festival Console Sign Flag for developers * makes it easy to find Festival console output fast */ From 9a0801c50e250152bd3a7f4fc602969f2fe63091 Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 23 Sep 2018 03:19:27 +0200 Subject: [PATCH 47/68] ?>0 --- src/genboy/Festival/lang/Language.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/genboy/Festival/lang/Language.php b/src/genboy/Festival/lang/Language.php index 87ae515..cf191ab 100644 --- a/src/genboy/Festival/lang/Language.php +++ b/src/genboy/Festival/lang/Language.php @@ -29,5 +29,3 @@ static function translate($key){ } } - -?> From a818962d4497317fc1bb3558949ba49afd007cee Mon Sep 17 00:00:00 2001 From: genboy Date: Fri, 28 Sep 2018 23:39:11 +0200 Subject: [PATCH 48/68] fix level area floating titles & reset permissions --- plugin.yml | 9 ++++++--- src/genboy/Festival/Main.php | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/plugin.yml b/plugin.yml index b233c90..29d9aa9 100644 --- a/plugin.yml +++ b/plugin.yml @@ -8,7 +8,7 @@ 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 event for command: /fe command event " + usage: "\n§bset lang: §f/fe lang §bToggle floating titles §f/fe titles §bSee list or present area info: §f/fe \n§5Create area: §6select 2 positions §f/fe §6, then createarea by naming it §f/fe create \n§9Toggle area flags: §f/fe §9Flags: §fgod, pvp, flight, edit, touch, mobs, animals, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage \n§5Set commands: \n§f/fe command \n§5(Edit)del command: \n§f/fe command <(edit)/del> () \n§5Change event for command: \n§f/fe command event \n§5Whitelist players: \n§f/fe whitelist " permission: festival.command.fe permissions: festival: @@ -24,11 +24,14 @@ permissions: children: festival.command.fe: description: "Allows access to the Festival area command." - default: true + default: op children: festival.command.fe.lang: description: "Allows access to the Festival lang subcommand." - default: true + default: op + festival.command.fe.titles: + description: "Allows access to the Festival titles subcommand." + default: op festival.command.fe.pos1: description: "Allows access to the Festival pos1 subcommand." default: op diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 35b2d6d..9b95517 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -428,7 +428,7 @@ public function setLanguage( $lang, $player ){ $this->loadLanguage(); // Area Flag text colors GREEN, AQUA, BLUE, RED, WHITE, YELLOW, LIGHT_PURPLE, DARK_PURPLE, GOLD, GRAY $msg = TextFormat::AQUA . Language::translate("language-selected"); - $player->areaMessage( $msg ); + $this->areaMessage( $msg, $player ); } @@ -552,7 +552,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar foreach($this->areas as $area){ $this->hideAreaTitle( $sender, $sender->getPosition()->getLevel(), $area ); } - $this->areaTitles = []; + $this->areaTitles[strtolower($sender->getName())] = []; $o = TextFormat::RED . "Area floating titles off!"; }else{ $this->checkAreaTitles( $sender, $sender->getPosition()->getLevel() ); @@ -1228,6 +1228,11 @@ public function onQuit(PlayerQuitEvent $event){ $lvl = $event->getPlayer()->getLevel()->getName(); unset($this->inArea[$playerName]); + foreach($this->areas as $area){ + $this->hideAreaTitle( $event->getPlayer(), $event->getPlayer()->getPosition()->getLevel(), $area ); + } + unset( $this->areaTitles[$playerName] ); + } /** Hurt @@ -2498,11 +2503,12 @@ public function levelChange(EntityLevelChangeEvent $event) { public function checkAreaTitles( $player, $level ) : void{ foreach($this->areas as $area){ - if( ( $this->options["Areadisplay"] == 'on' && ( !$area->getFlag("msg") || $area->isWhitelisted( strtolower( $player->getName() ) ) ) ) || - ( $this->options["Areadisplay"] == 'op' && ( $player->isOp() || $area->isWhitelisted( strtolower( $player->getName() ) ) ) ) ){ - - $this->placeAreaTitle( $player, $level, $area ); + if( $level->getName() == $area->getLevelName() && + (( $this->options["Areadisplay"] == 'on' && ( !$area->getFlag("msg") || $area->isWhitelisted( strtolower( $player->getName() ) ) ) ) || + ( $this->options["Areadisplay"] == 'op' && ( $player->isOp() || $area->isWhitelisted( strtolower( $player->getName() ) ) ) + ))){ + $this->placeAreaTitle( $player, $level, $area ); } } return; From f3fb699da3681d09dbbef724c564942ab265081f Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 29 Sep 2018 15:39:00 +0200 Subject: [PATCH 49/68] New CDMmode flag for testing commands (ops only) --- resources/config.yml | 10 ++ src/genboy/Festival/Main.php | 290 +++++++++++++++++------------------ 2 files changed, 152 insertions(+), 148 deletions(-) diff --git a/resources/config.yml b/resources/config.yml index abe0451..1052bb2 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -69,6 +69,9 @@ Default: # Keep players from taking fall damage (true = NoFallDamage) FallDamage: true + + # Keep area event commands from executing for non-ops (command test mode) + CMDmode: false # Settings for unprotected areas in individual worlds: Worlds: @@ -124,6 +127,10 @@ Worlds: # Keep players from taking fall damage (true = NoFallDamage) FallDamage: true + # Keep area event commands from executing for non-ops (command test mode) + CMDmode: false + + # Example specific level default flags (copy and replace 'world' with your levelname) world: # Keep players from getting hurt? (true = Player god mode) @@ -173,3 +180,6 @@ Worlds: # Keep players from taking fall damage (true = NoFallDamage) FallDamage: true + + # Keep area event commands from executing for non-ops (command test mode) + CMDmode: false diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 9b95517..5e2dee6 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -6,7 +6,6 @@ namespace genboy\Festival; use genboy\Festival\lang\Language; -use genboy\Festival\settings; use pocketmine\command\Command; use pocketmine\command\CommandSender; @@ -47,13 +46,13 @@ class Main extends PluginBase implements Listener{ /** @var array[] */ - private $levels = []; + private $levels = []; // list of level flags /** @var Area[] */ - public $areas = []; + public $areas = []; // list of area objects /** @var array[] */ - public $flagset = []; + public $flagset = []; // list of area flags /** @var array[] */ - public $options = []; + public $options = []; // config options /** @var bool */ private $god = false; @@ -87,6 +86,8 @@ class Main extends PluginBase implements Listener{ private $perms = false; /** @var bool */ private $falldamage = false; + /** @var bool */ + private $cmdmode = false; /** @var bool[] */ private $selectingFirst = []; @@ -139,41 +140,31 @@ public function onEnable() : void{ $newchange['Config'] = 'Festival setup..'; } - /** load default language translation class */ $this->loadLanguage(); - $c = yaml_parse_file($this->getDataFolder() . "config.yml"); // innitialize configurations & update options if( isset( $c["Options"] ) && is_array( $c["Options"] ) ){ if(!isset($c["Options"]["Language"])){ - $c["Options"]["Language"] = 'en'; $newchange['Msgtype'] = "! Language ".Language::translate("option-missing-in-config")." 'en'; ". Language::translate("option-see-configfile"); - }else if(isset($c["Options"]["Language"])){ - $this->loadLanguage($c["Options"]["Language"]); - } if(!isset($c["Options"]["Msgtype"])){ $c["Options"]["Msgtype"] = 'pop'; $newchange['Msgtype'] = "! Msgtype ".Language::translate("option-missing-in-config")." 'pop'; ". Language::translate("option-see-configfile"); } - if(!isset($c["Options"]["Msgdisplay"])){ $c["Options"]["Msgdisplay"] = 'off'; $newchange['Msgtype'] = "! Msgdisplay ".Language::translate("option-missing-in-config")." 'off'; ". Language::translate("option-see-configfile"); } - - if(!isset($c["Options"]["Areadisplay"])){ $c["Options"]["Areadisplay"] = 'off'; $newchange['Areadisplay'] = "! Areadisplay ".Language::translate("option-missing-in-config")." 'off'; ". Language::translate("option-see-configfile"); } - if(!isset($c["Options"]["AutoWhitelist"])){ // check since v1.0.5-12 $c["Options"]["AutoWhitelist"] = 'on'; $newchange['Msgtype'] = "! AutoWhitelist ".Language::translate("option-missing-in-config")." 'on'; ". Language::translate("option-see-configfile"); @@ -235,11 +226,15 @@ public function onEnable() : void{ if(!isset($c["Default"]["FallDamage"])) { $c["Default"]["FallDamage"] = false; // new in v1.0.7.3 } + if(!isset($c["Default"]["CMDmode"])) { + $c["Default"]["CMDmode"] = false; // new in v1.0.7.8 + } - $this->god = $c["Default"]["God"]; - $this->edit = $c["Default"]["Edit"]; - $this->touch = $c["Default"]["Touch"]; - $this->msg = $c["Default"]["Msg"]; + // world default flag settings + $this->god = $c["Default"]["God"]; // original + $this->edit = $c["Default"]["Edit"]; // original + $this->touch = $c["Default"]["Touch"]; // original + $this->msg = $c["Default"]["Msg"]; // new in v1.0.2 $this->passage = $c["Default"]["Passage"]; // changed in v1.0.3-11 $this->perms = $c["Default"]["Perms"]; // new in v1.0.4-11 $this->drop = $c["Default"]["Drop"]; // new in v1.0.4-11 @@ -252,10 +247,11 @@ public function onEnable() : void{ $this->hunger = $c["Default"]["Hunger"]; // new in v1.0.7.3 $this->falldamage = $c["Default"]["FallDamage"]; // new in 1.0.7.2-dev(1.0.8) $this->shoot = $c["Default"]["Shoot"]; // new in 1.0.7.2-dev(1.0.8) + $this->cmdmode = $c["Default"]["CMDmode"]; // new in 1.0.7.8-dev(1.0.8) - $this->flagset = $c['Default']; // new in v1.0.5-12 + $this->flagset = $c['Default']; // all flags :) new in v1.0.5-12 - // world default flag settings + // specified world default flag settings if(is_array( $c["Worlds"] )){ foreach($c["Worlds"] as $level => $flags){ if( isset($flags["Barrier"]) ){ // check since v1.0.3-11 @@ -298,16 +294,17 @@ public function onEnable() : void{ if( !isset($flags["Shoot"]) ){ // new v1.0.7.2 $flags["Shoot"] = $this->shoot; } + if( !isset($flags["CMD"]) ){ // new in v1.0.7.2 + $flags["CMDmode"] = $this->cmdmode; + } $this->levels[$level] = $flags; } } - // innitialize default flags & update data $data = json_decode(file_get_contents($this->getDataFolder() . "areas.json"), true); if( isset( $data ) && is_array( $data ) ){ - foreach($data as $datum){ $flags = $datum["flags"]; if( isset($datum["flags"]["barrier"]) ){ @@ -364,13 +361,14 @@ public function onEnable() : void{ $flags["shoot"] = false; $newchange['Msgtype'] = "! Shoot ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } - + if( !isset($datum["flags"]["cmdmode"]) ){ //new in v1.0.7.4 + $flags["cmdmode"] = false; + $newchange['CMDmode'] = "! Event Command mode ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + // setup area's to use 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); } - } - - $this->saveAreas(); // all save $this->areaList available :) /** load language translation class */ @@ -395,8 +393,6 @@ public function onEnable() : void{ } } - - /** load language ( experiment v1.0.7.7-dev ) * @var plugin config[] * @file resources en.json @@ -421,18 +417,17 @@ public function loadLanguage($languageCode = 'en' ){ new Language($this, $langJson); } - + /** set language + * @var str lang + * @var obj Player + */ public function setLanguage( $lang, $player ){ - $this->options["Language"] = $lang; $this->loadLanguage(); - // Area Flag text colors GREEN, AQUA, BLUE, RED, WHITE, YELLOW, LIGHT_PURPLE, DARK_PURPLE, GOLD, GRAY $msg = TextFormat::AQUA . Language::translate("language-selected"); $this->areaMessage( $msg, $player ); - } - /** Flag check experimental (synonym to original name) * @param string $flag * @return str $flag @@ -456,6 +451,7 @@ public function isFlag( $str ){ "perms","perm", "falldamage","nofalldamage","fd","nfd","fall", "shoot", "launch", + "cmdmode","commandmode","cmdm", ]; $str = strtolower( $str ); $flag = false; @@ -506,12 +502,13 @@ public function isFlag( $str ){ if( $str == "nofalldamage" || $str == "falldamage" || $str == "fd" || $str == "nfd" || $str == "fall"){ $flag = "falldamage"; } + if( $str == "cmdmode" || $str == "commandmode" || $str == "cmdm"){ // ! command is used as function.. + $flag = "cmdmode"; + } } return $flag; } - - /** Commands * @param CommandSender $sender * @param Command $cmd @@ -520,13 +517,11 @@ public function isFlag( $str ){ * @return bool */ public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool{ - if(!($sender instanceof Player)){ //$sender->sendMessage(TextFormat::RED . "Command must be used in-game."); $sender->sendMessage( TextFormat::RED . Language::translate("cmd-ingameonly-msg") ); return true; } - if(!isset($args[0])){ return false; } @@ -535,7 +530,6 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o = ""; switch($action){ - case "lang": // experiment v1.0.7.7-dev if( isset($args[1]) ){ if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.lang")){ @@ -565,8 +559,8 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar //$o = TextFormat::RED . "You do not have permission to use this subcommand."; $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); } - break; + case "pos1": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.pos1")){ if(isset($this->selectingFirst[$playerName]) || isset($this->selectingSecond[$playerName])){ @@ -582,6 +576,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); } break; + case "pos2": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.pos2")){ if(isset($this->selectingFirst[$playerName]) || isset($this->selectingSecond[$playerName])){ @@ -597,6 +592,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); } break; + case "create": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.area") || $sender->hasPermission("festival.command.fe.create")){ if(isset($args[1])){ @@ -615,7 +611,6 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar if( $this->options["AutoWhitelist"] == "on" ){ $whitelist = [$playerName]; } - new Area( strtolower($args[1]), "", @@ -634,8 +629,9 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar "shoot" => $flags['Shoot'], "hunger" => $flags['Hunger'], "perms" => $flags['Perms'], - "falldamage" => $flags['FallDamage']], - + "falldamage" => $flags['FallDamage'], + "cmdmode" => $flags['CMDmode'] + ], $this->firstPosition[$playerName], $this->secondPosition[$playerName], $sender->getLevel()->getName(), @@ -669,7 +665,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar //$o = TextFormat::RED . "You do not have permission to use this subcommand."; $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); } - break; + break; case "desc": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.desc")){ @@ -684,26 +680,21 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $area = $this->areas[strtolower($ar)]; $area->desc = $desc; $this->saveAreas(); - //$o = TextFormat::GREEN . "Area ". TextFormat::LIGHT_PURPLE . $area->getName() . TextFormat::GREEN . " description saved"; - $o = TextFormat::GREEN . Language::translate("area") . ' ' . TextFormat::LIGHT_PURPLE . $area->getName() . ' ' . TextFormat::GREEN . Language::translate("desc-saved"); + $o = TextFormat::GREEN . Language::translate("area") . ' ' . TextFormat::LIGHT_PURPLE . $area->getName() . ' ' . TextFormat::GREEN . Language::translate("desc-saved"); }else{ - //$o = TextFormat::RED . "Please write the description. Usage /fe desc <..>"; - $o = TextFormat::RED . Language::translate("desc-write-usage"); + $o = TextFormat::RED . Language::translate("desc-write-usage"); // Please write the description. Usage /fe desc <..> } }else{ - //$o = TextFormat::RED . "Area does not exist."; - $o = TextFormat::RED . Language::translate("area-not-excist"); + $o = TextFormat::RED . Language::translate("area-not-excist"); // Area does not excist } }else{ - //$o = TextFormat::RED . "Please specify an area to edit the description. Usage: /fe desc "; - $o = TextFormat::RED . Language::translate("desc-specify-area"); + $o = TextFormat::RED . Language::translate("desc-specify-area"); // Please specify an area to edit the description. Usage: /fe desc } }else{ - //$o = TextFormat::RED . "You do not have permission to use this subcommand."; - $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); // You do not have permission to use this subcommand } - break; + break; case "list": if( $sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.list")){ @@ -748,7 +739,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o = TextFormat::GRAY . Language::translate("area-no-area-to-edit"); } } - break; + break; case "here": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.here")){ @@ -767,7 +758,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o = TextFormat::RED . Language::translate("in-unknown-area"); } } - break; + break; case "tp": if (!isset($args[1])){ @@ -804,7 +795,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $list = $this->listAllAreas(); $o = TextFormat::RED . Language::translate("the-area"). " " . $args[1] . " ". Language::translate("cannot-be-found"). $list; } - break; + break; case "f": case "flag": @@ -837,6 +828,9 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "nofalldamage": case "fall": case "nfd": + case "cmdmode": + case "commandmode": + case "cmdm": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.flag")){ if(isset($args[1])){ @@ -1376,6 +1370,23 @@ public function hasFallDamage(Entity $entity) : bool{ return $o; } + /* + public function onFallDisable(EntityDamageEvent $event) : void{ + $player = $event->getEntity(); + $level = $player->getLevel()->getFolderName(); + $cause = $event->getCause(); + if($event->getEntity() instanceof Player){ + if(!$this->canGetHurt($player)){ + $event->setCancelled(); + } + if($cause == EntityDamageEvent::CAUSE_FALL && $this->hasFallDamage($player)){ + $event->setCancelled(true); + } + } + } + */ + + /** On hurt * @param EntityDamageEvent $event @@ -1553,7 +1564,6 @@ public function canHunger( PlayerExhaustEvent $event ): bool{ return $o; } - /** on Explode entity * EntityExplodeEvent * @param EntityExplodeEvent $event @@ -2060,14 +2070,11 @@ public function onMove(PlayerMoveEvent $ev) : void{ } } } - /** Area Player Monitor */ //$this->AreaPlayerMonitor($area, $ev); - } $this->checkPlayerFlying( $ev->getPlayer() ); - return; } @@ -2077,9 +2084,7 @@ public function onMove(PlayerMoveEvent $ev) : void{ * Set/refresh effects & status */ public function AreaPlayerMonitor( Area $area, PlayerMoveEvent $ev ): void{ - $player = $ev->getPlayer(); - if( $area->contains( $player->getPosition(), $player->getLevel()->getName() ) ){ if( $this->skippTime(5, strtolower($player->getName()) ) ){ // start / renew effects @@ -2087,7 +2092,6 @@ public function AreaPlayerMonitor( Area $area, PlayerMoveEvent $ev ): void{ //$this->areaMessage( $msg, $player ); } } - } /** Area event barrier cross by op @@ -2140,7 +2144,6 @@ public function barrierLeaveArea(Area $area, PlayerMoveEvent $ev): void{ } } return; - } /** Area event enter @@ -2160,7 +2163,6 @@ public function enterArea(Area $area, PlayerMoveEvent $ev): void{ $this->areaMessage( $msg, $player ); } } - $playerName = strtolower( $player->getName() ); $this->inArea[$playerName][] = strtolower( $area->getName() ); // player area's @@ -2191,7 +2193,6 @@ public function leaveArea(Area $area, PlayerMoveEvent $ev): void{ } $playerName = strtolower( $player->getName() ); - if (($key = array_search( strtolower( $area->getName() ), $this->inArea[$playerName] )) !== false) { unset($this->inArea[$playerName][$key]); } @@ -2252,31 +2253,47 @@ public function leaveAreaCenter(Area $area, PlayerMoveEvent $ev): void{ public function runAreaEvent(Area $area, PlayerMoveEvent $event, string $eventtype): void{ $player = $event->getPlayer(); $areaevents = $area->getEvents(); + $position = $player->getPosition(); + $playername = strtolower($player->getName()); - if( isset( $areaevents[$eventtype] ) && $areaevents[$eventtype] != '' ){ - $cmds = explode( "," , $areaevents[$eventtype] ); - if(count($cmds) > 0){ - foreach($cmds as $cid){ - if($cid != ''){ - // check {player} or @p (and other stuff) - $command = $this->commandStringFilter( $area->commands[$cid], $event ); - - if ( !$player->isOp() && $this->useOpPerms($player, $area) ) { // perm flag v1.0.4-11 - $player->setOp(true); - $player->getServer()->dispatchCommand($player, $command); - $player->setOp(false); - }else{ - if ( !$player->isOp() ){ - $this->getServer()->getPluginManager()->callEvent($ne = new PlayerCommandPreprocessEvent($player, "/" . $command)); - if(!$ne->isCancelled()) return; // don't do this - } - $player->getServer()->dispatchCommand($player, $command); - } - - } - } - } + $runcmd = true; + $c = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["CMDmode"] : $this->cmdmode); + if( $c ){ + $runcmd = false; // flag default + } + if( $area->getFlag("cmdmode") ){ + $runcmd = false; } + + if( $runcmd || $player->isOp() ){ + + if( isset( $areaevents[$eventtype] ) && $areaevents[$eventtype] != '' ){ + $cmds = explode( "," , $areaevents[$eventtype] ); + if(count($cmds) > 0){ + foreach($cmds as $cid){ + if($cid != ''){ + + // check {player} or @p (and other stuff) + $command = $this->commandStringFilter( $area->commands[$cid], $event ); + + if ( !$player->isOp() && $this->useOpPerms($player, $area) ) { // perm flag v1.0.4-11 + $player->setOp(true); + $player->getServer()->dispatchCommand($player, $command); + $player->setOp(false); + }else{ + if ( !$player->isOp() ){ + $this->getServer()->getPluginManager()->callEvent($ne = new PlayerCommandPreprocessEvent($player, "/" . $command)); + if(!$ne->isCancelled()) return; // don't do this (return) if player does not have permission + } + $player->getServer()->dispatchCommand($player, $command); + } + + } + } + } + } + + } } /** Command string filter @@ -2285,26 +2302,21 @@ public function runAreaEvent(Area $area, PlayerMoveEvent $event, string $eventty * @return $command str */ public function commandStringFilter( $command, $event ){ - - $playername = $event->getPlayer()->getName(); - + $playername = $event->getPlayer()->getName(); if( strpos( $command, "{player}" ) !== false ) { $command = str_replace("{player}", $playername, $command); // replaces {player} with the player name }else if( strpos( $command, "@p" ) !== false ) { // only if {player} is not used - untill we know why @p does not work $command = str_replace("@p", $playername, $command); // replaces @p with the player name } - return $command; - + return $command; } - /** skippTime * delay function for str player $nm repeating int $sec * @param string $sec * @return false */ public function skippTime($sec, $nm){ - $t = false; if(!isset($this->skipsec[$nm])){ $this->skipsec[$nm] = time(); @@ -2358,7 +2370,7 @@ public function msgOpDsp( $area, $player ){ } } - /** areaSounds + /** areaSounds * @param array $sounds */ public function areaEventSound( $player ){ @@ -2386,6 +2398,7 @@ public function listAllAreas(){ return Language::translate("area-no-area-available"); } } + /** List Area Info * @var obj area */ @@ -2395,15 +2408,12 @@ public function areaInfoDisplayList( $area ){ // Players in area $ap = []; foreach( $this->inArea as $p => $playerAreas ){ - if( $this->getServer()->getPlayer($p) ){ - foreach( $playerAreas as $a ){ if( $a == strtolower( $area->getName() ) ){ $ap[] = $p; } } - }else{ unset( $this->inArea[$p] ); // remove player from inArea list } @@ -2443,35 +2453,25 @@ public function areaInfoDisplayList( $area ){ return $l; } - public function onFallDisable(EntityDamageEvent $event) : void{ - $player = $event->getEntity(); - $level = $player->getLevel()->getFolderName(); - $cause = $event->getCause(); - if($event->getEntity() instanceof Player){ - if(!$this->canGetHurt($player)){ - $event->setCancelled(); - } - if($cause == EntityDamageEvent::CAUSE_FALL && $this->hasFallDamage($player)){ - $event->setCancelled(true); - } - } - } - /** Save areas - * @var obj area - * @file areas.json - */ - public function saveAreas() : void{ - $areas = []; - foreach($this->areas as $area){ - $areas[] = ["name" => $area->getName(), "desc" => $area->getDesc(), "flags" => $area->getFlags(), "pos1" => [$area->getFirstPosition()->getFloorX(), $area->getFirstPosition()->getFloorY(), $area->getFirstPosition()->getFloorZ()] , "pos2" => [$area->getSecondPosition()->getFloorX(), $area->getSecondPosition()->getFloorY(), $area->getSecondPosition()->getFloorZ()], "level" => $area->getLevelName(), "whitelist" => $area->getWhitelist(), "commands" => $area->getCommands(), "events" => $area->getEvents()]; - - $this->areaList[strtolower( $area->getName() )] = $area; // name associated area list for inArea check - } - file_put_contents($this->getDataFolder() . "areas.json", json_encode($areas)); - } + /** isWhitelisted global or specific area + * @param Player $player + * @param Area $area + */ + public function isWhitelisted( $player, $area = false ): bool{ + if( $area instanceof Area && $area->isWhitelisted( strtolower( $player->getName() ) ) && $area->getLevel() == $player->getPosition()->getLevel() ){ + return true; + }else{ + foreach($this->areas as $area){ + if( $area->isWhitelisted( strtolower( $player->getName() ) ) && $area->getLevel() == $player->getPosition()->getLevel() ){ + return true; + } + } + } + return false; + } /** onJoin Area Titles for Player ( FloatingTextParticle ) * @param PlayerJoinEvent $event @@ -2514,26 +2514,7 @@ public function checkAreaTitles( $player, $level ) : void{ return; } - - /** isWhitelisted global or specific area - * @param Player $player - * @param Area $area - */ - public function isWhitelisted( $player, $area = false ): bool{ - - if( $area instanceof Area && $area->isWhitelisted( strtolower( $player->getName() ) ) && $area->getLevel() == $player->getPosition()->getLevel() ){ - return true; - }else{ - foreach($this->areas as $area){ - if( $area->isWhitelisted( strtolower( $player->getName() ) ) && $area->getLevel() == $player->getPosition()->getLevel() ){ - return true; - } - } - } - return false; - } - - /** Set Floating Area Title ( FloatingTextParticle ) + /** Set Floating Area Title ( FloatingTextParticle ) * @param Player $player * @param Level $level * @param Area $area @@ -2569,6 +2550,19 @@ public function hideAreaTitle( $player, $level, $area ) : void{ return; } + /** Save areas + * @var obj area + * @file areas.json + */ + public function saveAreas() : void{ + $areas = []; + foreach($this->areas as $area){ + $areas[] = ["name" => $area->getName(), "desc" => $area->getDesc(), "flags" => $area->getFlags(), "pos1" => [$area->getFirstPosition()->getFloorX(), $area->getFirstPosition()->getFloorY(), $area->getFirstPosition()->getFloorZ()] , "pos2" => [$area->getSecondPosition()->getFloorX(), $area->getSecondPosition()->getFloorY(), $area->getSecondPosition()->getFloorZ()], "level" => $area->getLevelName(), "whitelist" => $area->getWhitelist(), "commands" => $area->getCommands(), "events" => $area->getEvents()]; + + $this->areaList[strtolower( $area->getName() )] = $area; // name associated area list for inArea check + } + file_put_contents($this->getDataFolder() . "areas.json", json_encode($areas)); + } /** Festival Console Sign Flag for developers * makes it easy to find Festival console output fast From 642ddaf8237b5813a96d065414a6305978062ff8 Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 29 Sep 2018 19:43:07 +0200 Subject: [PATCH 50/68] Update info --- README.md | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9b9c435..97da8f3 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ Create a festival with this custom area events plugin for Pocketmine Server: - perms: player permissions are used to determine area command execution (experiment) - hunger: player does not exhaust / hunger - falldamage: player will not have fall damage (no fall damage) + - cmdmode: area event commands are only executed for ops (for testing commands) **Events & Commands** @@ -90,9 +91,11 @@ Create a festival with this custom area events plugin for Pocketmine Server: **Specific** - - World: Default & world specific flags in config.yml + - World flags: Default & level(world) specific flags in config.yml are used for level default flag settings and new area flags settings - 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 or, if perms flag true: area uses the player permissions + - Area Titles: Set area titles to display, for ops or any player (in config.yml), ops can select display ingame with /fe titles + - CMDmode: The cmdmode flag disables event commands for (whitelisted)players, allows ops to test area event commands. !Please first check festival and other plugins configs (ie. worldguard) and the used player permissions incl. Festival whitelistings. @@ -141,9 +144,10 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). #### Create area - First command '/fe pos1' and tab a block for position 1, - then command '/fe pos2' and tab a block to set position2, + First command '/fe pos1' and tab or break a block for position 1 (holding a block, not an item), + + then command '/fe pos2' and tab or break a block to set position2, these are the endpoints of the area longest diagonal. @@ -166,7 +170,7 @@ 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. @@ -174,7 +178,7 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). The basic command to control area flags: - /fe flag(f) + /fe flag(f) Area flag listing @@ -189,12 +193,22 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). #### List all area's - /fe list + See all area info, optional per level + + /fe list () #### Teleport to area + Teleporting to area center top, drop with no falldamage (if falldamage flag true) + /fe tp + #### Toggle level area's floating title display + + Area floating title display (default set in config.yml) + + /fe titles + From 2e53fab870ad5677380b1626afa4c14aa13eadfa Mon Sep 17 00:00:00 2001 From: iZeaoGamer Date: Sun, 30 Sep 2018 12:23:16 +0100 Subject: [PATCH 51/68] Fix some grammatical errors. --- plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.yml b/plugin.yml index 29d9aa9..27601ee 100644 --- a/plugin.yml +++ b/plugin.yml @@ -8,7 +8,7 @@ website: "https://github.com/genboy/Festival" commands: fe: description: "Allows you to manage Festival area's and events." - usage: "\n§bset lang: §f/fe lang §bToggle floating titles §f/fe titles §bSee list or present area info: §f/fe \n§5Create area: §6select 2 positions §f/fe §6, then createarea by naming it §f/fe create \n§9Toggle area flags: §f/fe §9Flags: §fgod, pvp, flight, edit, touch, mobs, animals, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage \n§5Set commands: \n§f/fe command \n§5(Edit)del command: \n§f/fe command <(edit)/del> () \n§5Change event for command: \n§f/fe command event \n§5Whitelist players: \n§f/fe whitelist " + usage: "\n§bset lang: §f/fe lang §bToggle floating titles §f/fe titles §bSee a list of present area info: §f/fe \n§5Create an area: §6select 2 positions §f/fe §6, then create an area by using: §f/fe create \n§9Toggle area flags: §f/fe §9Flags: §fgod, pvp, flight, edit, touch, mobs, animals, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage \n§5Set commands: \n§f/fe command \n§5(Edit)del command: \n§f/fe command <(edit)/del> () \n§5Change event for command: \n§f/fe command event \n§5Whitelist players: \n§f/fe whitelist " permission: festival.command.fe permissions: festival: From 7261f607eb03afd9985ba2093968a76c75e39ae1 Mon Sep 17 00:00:00 2001 From: Genboy <30810841+genboy@users.noreply.github.com> Date: Thu, 4 Oct 2018 17:16:20 +0200 Subject: [PATCH 52/68] Update plugin.yml --- plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.yml b/plugin.yml index 27601ee..fef1b5b 100644 --- a/plugin.yml +++ b/plugin.yml @@ -8,7 +8,7 @@ website: "https://github.com/genboy/Festival" commands: fe: description: "Allows you to manage Festival area's and events." - usage: "\n§bset lang: §f/fe lang §bToggle floating titles §f/fe titles §bSee a list of present area info: §f/fe \n§5Create an area: §6select 2 positions §f/fe §6, then create an area by using: §f/fe create \n§9Toggle area flags: §f/fe §9Flags: §fgod, pvp, flight, edit, touch, mobs, animals, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage \n§5Set commands: \n§f/fe command \n§5(Edit)del command: \n§f/fe command <(edit)/del> () \n§5Change event for command: \n§f/fe command event \n§5Whitelist players: \n§f/fe whitelist " + usage: "\n§bChoose language: §f/fe lang §bToggle floating area titles: §f/fe titles §bSee area info at location: §f/fe \n§5How to create an area: §6select 2 corner positions §f/fe §6, then name the area by using: §f/fe create \n§9Toggle area flags: §f/fe §9Flags: §fgod, pvp, flight, edit, touch, mobs, animals, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage \n§5Add an area event command: \n§f/fe command \n§5Edit or delete command: \n§f/fe command <(edit)/del> () \n§5Change command event: \n§f/fe command event \n§5Whitelist players: \n§f/fe whitelist " permission: festival.command.fe permissions: festival: From 3e4211c3734ab932418074c7f143c5f9d747f7df Mon Sep 17 00:00:00 2001 From: genboy Date: Thu, 4 Oct 2018 19:27:42 +0200 Subject: [PATCH 53/68] Fix active area titles level --- src/genboy/Festival/Main.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 5e2dee6..9cf512b 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -2478,7 +2478,7 @@ public function isWhitelisted( $player, $area = false ): bool{ */ public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); - $level = $this->getServer()->getDefaultLevel(); + $level = $player->getLevel(); // $this->getServer()->getDefaultLevel(); $this->areaTitles[strtolower($player->getName())] = []; $this->checkAreaTitles( $player, $level ); } @@ -2502,12 +2502,11 @@ public function levelChange(EntityLevelChangeEvent $event) { */ public function checkAreaTitles( $player, $level ) : void{ foreach($this->areas as $area){ - + $this->hideAreaTitle( $player, $level, $area ); if( $level->getName() == $area->getLevelName() && (( $this->options["Areadisplay"] == 'on' && ( !$area->getFlag("msg") || $area->isWhitelisted( strtolower( $player->getName() ) ) ) ) || ( $this->options["Areadisplay"] == 'op' && ( $player->isOp() || $area->isWhitelisted( strtolower( $player->getName() ) ) ) ))){ - $this->placeAreaTitle( $player, $level, $area ); } } From 7ca83cc03fe51ba4479af5211c8661b5dd7f439d Mon Sep 17 00:00:00 2001 From: Genboy <30810841+genboy@users.noreply.github.com> Date: Thu, 4 Oct 2018 21:15:00 +0200 Subject: [PATCH 54/68] New: issue templates Take in accurate data to solve more quickly --- .github/ISSUE_TEMPLATE/question-or-suggestion.md | 13 +++++++++++++ .github/ISSUE_TEMPLATE/something-is-wrong.md | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/question-or-suggestion.md create mode 100644 .github/ISSUE_TEMPLATE/something-is-wrong.md diff --git a/.github/ISSUE_TEMPLATE/question-or-suggestion.md b/.github/ISSUE_TEMPLATE/question-or-suggestion.md new file mode 100644 index 0000000..5a8e092 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question-or-suggestion.md @@ -0,0 +1,13 @@ +--- +name: Question or suggestion +about: Ask questions and share suggestions + +--- + +Hi, i have Festival version **{your version)** +running with Pocketmine version **{pmmp version}** +Befor making this issue I read the [wiki pages](https://github.com/genboy/Festival/wiki) + +I wonder: **{describe your question or suggestion}** + +This involves: **{related plugins including version}** diff --git a/.github/ISSUE_TEMPLATE/something-is-wrong.md b/.github/ISSUE_TEMPLATE/something-is-wrong.md new file mode 100644 index 0000000..a89a05f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/something-is-wrong.md @@ -0,0 +1,14 @@ +--- +name: Something is wrong +about: Problems with Festival configs or usage + +--- + +Hi, i have Festival version {your version) +running with Pocketmine version {pmmp version} +and the following plugins enabled: +{list of plugins including version} + +I have read the [wiki pages](https://github.com/genboy/Festival/wiki) and could not find a solution. + +My problem is: {describe your problem} From 2d9cf8f1385254efd841badaedf8318e5c66ae5f Mon Sep 17 00:00:00 2001 From: Genboy <30810841+genboy@users.noreply.github.com> Date: Thu, 4 Oct 2018 21:23:58 +0200 Subject: [PATCH 55/68] Update issue templates --- .../ISSUE_TEMPLATE/question-or-suggestion.md | 8 ++++---- .github/ISSUE_TEMPLATE/something-is-wrong.md | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/question-or-suggestion.md b/.github/ISSUE_TEMPLATE/question-or-suggestion.md index 5a8e092..ba773ad 100644 --- a/.github/ISSUE_TEMPLATE/question-or-suggestion.md +++ b/.github/ISSUE_TEMPLATE/question-or-suggestion.md @@ -4,10 +4,10 @@ about: Ask questions and share suggestions --- -Hi, i have Festival version **{your version)** -running with Pocketmine version **{pmmp version}** +Hi, i have **Festival version** { your version ) +running with **Pocketmine version** { pmmp version } Befor making this issue I read the [wiki pages](https://github.com/genboy/Festival/wiki) -I wonder: **{describe your question or suggestion}** +**I wonder**: { describe your question or suggestion } -This involves: **{related plugins including version}** +This involves: { related plugins including version } diff --git a/.github/ISSUE_TEMPLATE/something-is-wrong.md b/.github/ISSUE_TEMPLATE/something-is-wrong.md index a89a05f..c4cc8d5 100644 --- a/.github/ISSUE_TEMPLATE/something-is-wrong.md +++ b/.github/ISSUE_TEMPLATE/something-is-wrong.md @@ -4,11 +4,18 @@ about: Problems with Festival configs or usage --- -Hi, i have Festival version {your version) -running with Pocketmine version {pmmp version} -and the following plugins enabled: -{list of plugins including version} +Hi, i have **Festival version** { your version ) +running with **Pocketmine version** { pmmp version } +and the following **plugins enabled**: +{ list of plugins including version } I have read the [wiki pages](https://github.com/genboy/Festival/wiki) and could not find a solution. -My problem is: {describe your problem} +--- +**My problem is**: + +{ describe your problem here} + +--- +! Do not include configurations or file contents in the issues, +if required please send your files/data to msg@genboy.net From d41529d5c120735a46f79f233604ff2deca87831 Mon Sep 17 00:00:00 2001 From: Genboy <30810841+genboy@users.noreply.github.com> Date: Thu, 4 Oct 2018 21:31:14 +0200 Subject: [PATCH 56/68] Delete question-or-suggestion.md --- .github/ISSUE_TEMPLATE/question-or-suggestion.md | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/question-or-suggestion.md diff --git a/.github/ISSUE_TEMPLATE/question-or-suggestion.md b/.github/ISSUE_TEMPLATE/question-or-suggestion.md deleted file mode 100644 index ba773ad..0000000 --- a/.github/ISSUE_TEMPLATE/question-or-suggestion.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -name: Question or suggestion -about: Ask questions and share suggestions - ---- - -Hi, i have **Festival version** { your version ) -running with **Pocketmine version** { pmmp version } -Befor making this issue I read the [wiki pages](https://github.com/genboy/Festival/wiki) - -**I wonder**: { describe your question or suggestion } - -This involves: { related plugins including version } From 8d7302d1375268542a6f820ccc128776ad2db731 Mon Sep 17 00:00:00 2001 From: Genboy <30810841+genboy@users.noreply.github.com> Date: Thu, 4 Oct 2018 21:31:45 +0200 Subject: [PATCH 57/68] Delete something-is-wrong.md --- .github/ISSUE_TEMPLATE/something-is-wrong.md | 21 -------------------- 1 file changed, 21 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/something-is-wrong.md diff --git a/.github/ISSUE_TEMPLATE/something-is-wrong.md b/.github/ISSUE_TEMPLATE/something-is-wrong.md deleted file mode 100644 index c4cc8d5..0000000 --- a/.github/ISSUE_TEMPLATE/something-is-wrong.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -name: Something is wrong -about: Problems with Festival configs or usage - ---- - -Hi, i have **Festival version** { your version ) -running with **Pocketmine version** { pmmp version } -and the following **plugins enabled**: -{ list of plugins including version } - -I have read the [wiki pages](https://github.com/genboy/Festival/wiki) and could not find a solution. - ---- -**My problem is**: - -{ describe your problem here} - ---- -! Do not include configurations or file contents in the issues, -if required please send your files/data to msg@genboy.net From ed1ea0b6624ea296a18c9c0ef3d0c0e02f7f2bfb Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 6 Oct 2018 01:41:54 +0200 Subject: [PATCH 58/68] check tnt --- src/genboy/Festival/Main.php | 37 +++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 9cf512b..4ec6673 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1436,6 +1436,23 @@ public function canEdit(Player $player, Position $position) : bool{ return $o; } + + + /** Block Touch + * @param PlayerInteractEvent $event + * @ignoreCancelled true + */ + public function onBlockTouch(PlayerInteractEvent $event) : void{ + + $block = $event->getBlock(); + $player = $event->getPlayer(); + + if(!$this->canTouch($player, $block)){ + $event->setCancelled(); + } + + } + /** Touch * @param Player $player * @param Position $position @@ -1468,17 +1485,6 @@ public function canTouch(Player $player, Position $position) : bool{ return $o; } - /** Block Touch - * @param PlayerInteractEvent $event - * @ignoreCancelled true - */ - public function onBlockTouch(PlayerInteractEvent $event) : void{ - $block = $event->getBlock(); - $player = $event->getPlayer(); - if(!$this->canTouch($player, $block)){ - $event->setCancelled(); - } - } /** on Interact @@ -1490,6 +1496,7 @@ public function onInteract( PlayerInteractEvent $event ): void{ $item = $event->getItem(); $block = $event->getBlock(); $player = $event->getPlayer(); + $position = $player->getPosition(); $playername = strtolower($player->getName()); $b = $block->getID(); $i = $item->getID(); @@ -1504,17 +1511,17 @@ public function onInteract( PlayerInteractEvent $event ): void{ if( $b == 46 // tnt && $i == 259 // flint & steel && !$this->canExplode( $player->getPosition() ) - && !$player->isOp() ){ - $event->setCancelled(true); + ){ + $event->setCancelled(); } if( $b == 199 // item frame || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) // no farm event - || $i == 259 // flint & steel fire + || $i == 259 // apart for fire flag ){ if(!$this->canEdit($player, $block)){ - $event->setCancelled(true); + $event->setCancelled(); } } From 0429427b550506d0984cf6ca3ca40180e834fed4 Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 7 Oct 2018 23:54:04 +0200 Subject: [PATCH 59/68] Code clean & ordening --- plugin.yml | 2 +- resources/config.yml | 6 +- resources/en.json | 3 +- resources/nl.json | 2 + src/genboy/Festival/Main.php | 1415 ++++++++++++++++++---------------- 5 files changed, 740 insertions(+), 688 deletions(-) diff --git a/plugin.yml b/plugin.yml index fef1b5b..0ad4b80 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: Festival author: Genboy -version: 1.0.7.8-dev +version: 1.0.7.9-dev main: genboy\Festival\Main load: POSTWORLD api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0,4.0.0] diff --git a/resources/config.yml b/resources/config.yml index 1052bb2..2dd7fde 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -29,7 +29,7 @@ Default: PVP: false # Keep players from flying? (true = NoFlight) - Flight: true + Flight: false # Keep players from editing the world? (true = NoEdit) Edit: true @@ -86,7 +86,7 @@ Worlds: PVP: false # Keep players from flying? (true = NoFlight) - Flight: true + Flight: false # Keep players from editing the world? (true = NoEdit) Edit: true @@ -140,7 +140,7 @@ Worlds: PVP: false # Keep players from flying? (true = NoFlight) - Flight: true + Flight: false # Keep players from editing the world? (true = NoEdit) Edit: true diff --git a/resources/en.json b/resources/en.json index 9087189..f4a470d 100644 --- a/resources/en.json +++ b/resources/en.json @@ -78,7 +78,6 @@ "cmd-specify-id-and-command-usage": "Please specify the command ID and command string to add. Usage: /fe command add ", "cmd-valid-areaname": "Area not found, please submit a valid name. Usage: /fe command .", - "cmd-id-not-found": "Command ID not found. See the commands with /fe event command list'", "cmd-specify-id-to-delete": "Please specify the command ID to delete. Usage /fe event command del ", "cmd-specify-action": "Please add an action to perform with command. Usage: /fe command .", @@ -87,6 +86,8 @@ "event-is-now": "event is now", "change-failed": "change-failed!", + "select-and": "and", + "select-in": "in", "select-yes": "Yes", "select-no": "No", "status-on": "on", diff --git a/resources/nl.json b/resources/nl.json index 47c0d34..af8e580 100644 --- a/resources/nl.json +++ b/resources/nl.json @@ -83,6 +83,8 @@ "event-is-now": "event is nu", "change-failed": "change-failed!", + "select-and": "en", + "select-in": "in", "select-yes": "Ja", "select-no": "Nee", "status-on": "aan", diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 4ec6673..63c6cc9 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1,8 +1,38 @@ -codeSigned(); // codesign - $ca = 0; // plugin area info + $ca = 0; // plugin area command count + $fa = 0; // plugin area flag count foreach( $this->areas as $a ){ + foreach($a->flags as $flag){ + if($flag){ + $fa++; + } + } $ca = $ca + count( $a->getCommands() ); } - $this->getLogger()->info( $ca .' '. Language::translate("cmds") .' in '. count($this->areas) .' '. Language::translate("areas")); + $this->getLogger()->info( $fa.' '.Language::translate("flags").' '.Language::translate("select-and").' '. $ca .' '. Language::translate("cmds") .' '.Language::translate("select-in").' '. count($this->areas) .' '. Language::translate("areas")); // warnings changes if( count($newchange) > 0 ){ @@ -393,7 +430,7 @@ public function onEnable() : void{ } } - /** load language ( experiment v1.0.7.7-dev ) + /** load language ( v1.0.7.7-dev ) * @var plugin config[] * @file resources en.json * @file resources nl.json @@ -428,7 +465,7 @@ public function setLanguage( $lang, $player ){ $this->areaMessage( $msg, $player ); } - /** Flag check experimental (synonym to original name) + /** Flag check (synonym to original name) * @param string $flag * @return str $flag */ @@ -509,7 +546,8 @@ public function isFlag( $str ){ return $flag; } - /** Commands + + /** COMMANDS * @param CommandSender $sender * @param Command $cmd * @param string $label @@ -518,8 +556,7 @@ public function isFlag( $str ){ */ public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool{ if(!($sender instanceof Player)){ - //$sender->sendMessage(TextFormat::RED . "Command must be used in-game."); - $sender->sendMessage( TextFormat::RED . Language::translate("cmd-ingameonly-msg") ); + $sender->sendMessage( TextFormat::RED . Language::translate("cmd-ingameonly-msg") ); //$sender->sendMessage(TextFormat::RED . "Command must be used in-game."); return true; } if(!isset($args[0])){ @@ -529,7 +566,6 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $action = strtolower($args[0]); $o = ""; switch($action){ - case "lang": // experiment v1.0.7.7-dev if( isset($args[1]) ){ if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.lang")){ @@ -538,7 +574,6 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } } break; - case "titles": if( $sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->isOp() || $this->isWhitelisted($sender) ){ if( $this->options["Areadisplay"] == 'op' || $this->options["Areadisplay"] == 'on' ){ @@ -556,43 +591,33 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o = TextFormat::YELLOW . "Area floating titles not available"; } }else{ - //$o = TextFormat::RED . "You do not have permission to use this subcommand."; - $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); //$o = TextFormat::RED . "You do not have permission to use this subcommand."; } break; - case "pos1": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.pos1")){ if(isset($this->selectingFirst[$playerName]) || isset($this->selectingSecond[$playerName])){ - //$o = TextFormat::RED . "You're already selecting a position!"; - $o = TextFormat::RED . Language::translate("pos-select-active"); + $o = TextFormat::RED . Language::translate("pos-select-active"); //$o = TextFormat::RED . "You're already selecting a position!"; }else{ $this->selectingFirst[$playerName] = true; - //$o = TextFormat::GREEN . "Please place or break the first position."; - $o = TextFormat::GREEN . Language::translate("make-pos1"); + $o = TextFormat::GREEN . Language::translate("make-pos1"); //$o = TextFormat::GREEN . "Please place or break the first position."; } }else{ - //$o = TextFormat::RED . "You do not have permission to use this subcommand."; - $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); //$o = TextFormat::RED . "You do not have permission to use this subcommand."; } break; - case "pos2": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.pos2")){ if(isset($this->selectingFirst[$playerName]) || isset($this->selectingSecond[$playerName])){ - //$o = TextFormat::RED . "You're already selecting a position!"; - $o = TextFormat::RED . Language::translate("pos-select-active"); + $o = TextFormat::RED . Language::translate("pos-select-active"); //$o = TextFormat::RED . "You're already selecting a position!"; }else{ $this->selectingSecond[$playerName] = true; - //$o = TextFormat::GREEN . "Please place or break the second position."; - $o = TextFormat::GREEN . Language::translate("make-pos2"); + $o = TextFormat::GREEN . Language::translate("make-pos2"); //$o = TextFormat::GREEN . "Please place or break the second position."; } }else{ - //$o = TextFormat::RED . "You do not have permission to use this subcommand."; - $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); //$o = TextFormat::RED . "You do not have permission to use this subcommand."; } break; - case "create": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.area") || $sender->hasPermission("festival.command.fe.create")){ if(isset($args[1])){ @@ -606,8 +631,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $flags = $this->levels[$sender->getLevel()->getName()]; } } - // get default whitelisting - $whitelist = []; + $whitelist = []; // get default whitelisting if( $this->options["AutoWhitelist"] == "on" ){ $whitelist = [$playerName]; } @@ -643,30 +667,23 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $this->saveAreas(); unset($this->firstPosition[$playerName], $this->secondPosition[$playerName]); - //$o = TextFormat::AQUA . "Area created!"; - $o = TextFormat::AQUA . Language::translate("area-created"); + $o = TextFormat::AQUA . Language::translate("area-created"); //$o = TextFormat::AQUA . "Area created!"; }else{ - //$o = TextFormat::RED . "An area with that name already exists."; - $o = TextFormat::RED . Language::translate("area-name-excist"); + $o = TextFormat::RED . Language::translate("area-name-excist"); //$o = TextFormat::RED . "An area with that name already exists."; } }else{ - //$o = TextFormat::RED . "Enter a name for the area (/fe create )."; - $o = TextFormat::RED . Language::translate("give-area-name") . ' (/fe create )' ; + $o = TextFormat::RED . Language::translate("give-area-name") . ' (/fe create )' ; //$o = TextFormat::RED . "Enter a name for the area (/fe create )."; } }else{ - //$o = TextFormat::RED . "Please select both positions first."; - $o = TextFormat::RED . Language::translate("select-both-pos-first"); + $o = TextFormat::RED . Language::translate("select-both-pos-first"); //$o = TextFormat::RED . "Please select both positions first."; } }else{ - //$o = TextFormat::RED . "Please specify a name for this area (/fe create )."; - $o = TextFormat::RED . Language::translate("give-area-name") . ' (/fe create )'; + $o = TextFormat::RED . Language::translate("give-area-name") . ' (/fe create )'; //$o = TextFormat::RED . "Please specify a name for this area (/fe create )."; } }else{ - //$o = TextFormat::RED . "You do not have permission to use this subcommand."; - $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); //$o = TextFormat::RED . "You do not have permission to use this subcommand."; } break; - case "desc": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.desc")){ if(isset($args[1])){ @@ -695,7 +712,6 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); // You do not have permission to use this subcommand } break; - case "list": if( $sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.list")){ $levelNamesArray = scandir($this->getServer()->getDataPath() . "worlds/"); @@ -740,7 +756,6 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } } break; - case "here": if($sender->hasPermission("festival") || $sender->hasPermission("festival.command") || $sender->hasPermission("festival.command.fe.here")){ $o = ""; @@ -759,7 +774,6 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } } break; - case "tp": if (!isset($args[1])){ //$o = TextFormat::RED . "You must specify an existing Area name"; @@ -924,16 +938,13 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar } } }else{ - //$o = TextFormat::RED . "Area doesn't exist."; - $o = TextFormat::RED . Language::translate("area-not-excist"); + $o = TextFormat::RED . Language::translate("area-not-excist"); //$o = TextFormat::RED . "Area doesn't exist."; } }else{ - //$o = TextFormat::RED . "Please specify the area you would like to flag."; - $o = TextFormat::RED . Language::translate("specify-to-flag"); + $o = TextFormat::RED . Language::translate("specify-to-flag"); //$o = TextFormat::RED . "Please specify the area you would like to flag."; } }else{ - //$o = TextFormat::RED . "You do not have permission to use this subcommand."; - $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); //$o = TextFormat::RED . "You do not have permission to use this subcommand."; } break; @@ -945,19 +956,15 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar if(isset($this->areas[strtolower($args[1])])){ $area = $this->areas[strtolower($args[1])]; $area->delete(); - //$o = TextFormat::GREEN . "Area deleted!"; - $o = TextFormat::GREEN . Language::translate("area-deleted"); + $o = TextFormat::GREEN . Language::translate("area-deleted"); //$o = TextFormat::GREEN . "Area deleted!"; }else{ - //$o = TextFormat::RED . "Area does not exist."; - $o = TextFormat::RED . Language::translate("area-not-excist"); + $o = TextFormat::RED . Language::translate("area-not-excist"); //$o = TextFormat::RED . "Area does not exist."; } }else{ - //$o = TextFormat::RED . "Please specify an area to delete."; - $o = TextFormat::RED . Language::translate("specify-to-delete"); + $o = TextFormat::RED . Language::translate("specify-to-delete"); //$o = TextFormat::RED . "Please specify an area to delete."; } }else{ - //$o = TextFormat::RED . "You do not have permission to use this subcommand."; - $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); //$o = TextFormat::RED . "You do not have permission to use this subcommand."; } break; @@ -1005,8 +1012,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar $o = TextFormat::RED . Language::translate("area-not-excist") . " ( /area whitelist [player] )"; } }else{ - //$o = TextFormat::RED . "You do not have permission to use this subcommand."; - $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); + $o = TextFormat::RED . Language::translate("cmd-noperms-subcommand"); //$o = TextFormat::RED . "You do not have permission to use this subcommand."; } break; @@ -1082,8 +1088,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar break; case "event": - //$o = '/fe command event '; - if( isset($args[3]) && isset($args[4]) ){ + if( isset($args[3]) && isset($args[4]) ){ //$o = '/fe command event '; $ar = $args[1]; $area = $this->areas[strtolower($ar)]; $cid = $args[3]; @@ -1212,183 +1217,176 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar return true; } - /** on quit - * @param Event $event - * @return bool + /** onJoin + * set Area Titles for Player ( FloatingTextParticle ) + * @param PlayerJoinEvent $event */ - public function onQuit(PlayerQuitEvent $event){ - - $playerName = strtolower($event->getPlayer()->getName()); - $lvl = $event->getPlayer()->getLevel()->getName(); - unset($this->inArea[$playerName]); - - foreach($this->areas as $area){ - $this->hideAreaTitle( $event->getPlayer(), $event->getPlayer()->getPosition()->getLevel(), $area ); - } - unset( $this->areaTitles[$playerName] ); - + public function onJoin(PlayerJoinEvent $event){ + $player = $event->getPlayer(); + $level = $player->getLevel(); // $this->getServer()->getDefaultLevel(); + $this->areaTitles[strtolower($player->getName())] = []; + $this->checkAreaTitles( $player, $level ); } - /** Hurt - * @param Entity $entity - * @return bool + /** levelChange + * change Area Titles for Player ( FloatingTextParticle ) + * @param EntityLevelChangeEvent $event */ - public function canGetHurt(Entity $entity) : bool{ - $o = true; - if( $entity instanceof Player){ - $g = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["God"] : $this->god); - if($g){ - $o = false; - } - $playername = strtolower($entity->getName()); - foreach($this->inArea[$playername] as $areaname){ - if( isset($this->areaList[ $areaname ]) ){ - $area = $this->areaList[ $areaname ]; - if($area->getFlag("god")){ - $o = false; - } - if(!$area->getFlag("god") && $g ){ - $o = true; - } - if($area->isWhitelisted($playername)){ - $o = false; - } - } - } + public function levelChange(EntityLevelChangeEvent $event) { + $entity = $event->getEntity(); + if ($entity instanceof Player) { + $level = $event->getTarget(); + $this->checkAreaTitles( $entity, $level ); } - return $o; - } + } - /** PVP - * @param Event $ev - * @return bool + /** onMove + * @param PlayerMoveEvent $ev + * @var string inArea + * @return true */ - public function canPVP(EntityDamageEvent $ev) : bool{ - $o = true; - $god = false; - if($ev instanceof EntityDamageByEntityEvent){ - if($ev->getEntity() instanceof Player && $ev->getDamager() instanceof Player){ - $entity = $ev->getEntity(); - $p = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["PVP"] : $this->pvp); - if($p){ - $o = false; - } - $playername = $entity->getName(); - $pos = $entity->getPosition(); - foreach ($this->areas as $area) { - if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { - $god = $area->getFlag("god"); - if($area->getFlag("pvp")){ - $o = false; - } - if( !$area->getFlag("pvp") && $p){ - $o = true; - } - if($area->isWhitelisted($playername)){ - $o = false; - } - } - } - } - } - if( !$o ){ - $player = $ev->getDamager(); - if( $this->skippTime( 2, strtolower($player->getName()) ) ){ - if( $god ){ - $this->areaMessage( Language::tranlate("all-players-are-god"), $player ); - }else{ - $this->areaMessage( Language::tranlate("no-pvp-area"), $player ); - } + public function onMove(PlayerMoveEvent $ev) : void{ + $player = $ev->getPlayer(); + $playerName = strtolower( $player->getName() ); + if( !isset( $this->inArea[$playerName] ) ){ + $this->inArea[$playerName] = []; + } + foreach($this->areas as $area){ + if( $area->getFlag("passage") ){ // Player area passage + if( $player->isOp() || $area->isWhitelisted( strtolower( $player->getName() ) ) || $player->hasPermission("festival") || $player->hasPermission("festival.access") ){ + if( ( $area->contains( $player->getPosition(), $player->getLevel()->getName() ) && !$area->contains( $ev->getFrom(), $player->getLevel()->getName() ) ) + || !$area->contains( $player->getPosition(), $player->getLevel()->getName() ) && $area->contains( $ev->getFrom(), $player->getLevel()->getName() ) ){ + // ops & whitelist players pass + $this->barrierCrossByOp($area, $ev); + break; + } + }else{ + if( $area->contains( $player->getPosition(), $player->getLevel()->getName() ) + && !$area->contains( $ev->getFrom(), $player->getLevel()->getName() ) ){ + $this->barrierEnterArea($area, $ev); + break; + } + if( !$area->contains( $player->getPosition(), $player->getLevel()->getName() ) + && $area->contains( $ev->getFrom(), $player->getLevel()->getName() ) ){ + $this->barrierLeaveArea($area, $ev); + break; + } + } } - } - return $o; - } + // Player enter or leave area + if( !$area->contains( $player->getPosition(), $player->getLevel()->getName() ) ){ + // Player leave Area + if( in_array( strtolower( $area->getName() ) , $this->inArea[$playerName] ) ){ + $this->leaveArea($area, $ev); + break; + } + }else{ + // Player enter Area + if( !in_array( strtolower( $area->getName() ), $this->inArea[$playerName] ) ){ + $this->enterArea($area, $ev); + break; + } + // Player enter Area Center + if( $area->centerContains( $player->getPosition(), $player->getLevel()->getName() ) ){ + if( !in_array( strtolower( $area->getName() )."center", $this->inArea[$playerName] ) ){ // Player enter in Area + $this->enterAreaCenter($area, $ev); + break; + } + }else{ + // Player leave Area Center + if( in_array( strtolower( $area->getName()."center" ) , $this->inArea[$playerName] ) ){ + $this->leaveAreaCenter($area, $ev); + break; + } + } + } + // Area Player Monitor $this->AreaPlayerMonitor($area, $ev); + } + $this->checkPlayerFlying( $ev->getPlayer() ); + return; + } - /** Player Damage Impact - * @param EntityDamageEvent $event + /** Block Place + * @param BlockPlaceEvent $event * @ignoreCancelled true - */ - public function canDamage(EntityDamageEvent $ev) : bool{ - - if($ev->getEntity() instanceof Player){ - $player = $ev->getEntity(); - $playerName = strtolower($player->getName()); - if(!$this->canGetHurt($player)){ - if( $player->isOnFire() ){ - $player->extinguish(); // 1.0.7-dev + */ + public function onBlockPlace(BlockPlaceEvent $event) : void{ + $block = $event->getBlock(); + $player = $event->getPlayer(); + $playerName = strtolower($player->getName()); + if(isset($this->selectingFirst[$playerName])){ + unset($this->selectingFirst[$playerName]); + $this->firstPosition[$playerName] = $block->asVector3(); + $player->sendMessage(TextFormat::GREEN . language::translate("pos1")." ". language::translate("set-to"). ": (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); + $event->setCancelled(); + }elseif(isset($this->selectingSecond[$playerName])){ + unset($this->selectingSecond[$playerName]); + $this->secondPosition[$playerName] = $block->asVector3(); + $player->sendMessage(TextFormat::GREEN . language::translate("pos2")." ". language::translate("set-to"). ": (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); + $event->setCancelled(); + }else{ + // .. canUseTNT( $player, $block ) + if( $block->getID() == Block::TNT && !$this->canExplode( $player->getPosition() ) ){ + if( $player->hasPermission("festival") || $player->hasPermission("festival.access") ){ + }else{ + $event->setCancelled(); + //$player->sendMessage("TNT not allowed here"); } - $ev->setCancelled(); - return false; - } - if(!$this->canPVP($ev)){ // v 1.0.6-13 - $ev->setCancelled(); - return false; + } + if(!$this->canEdit($player, $block)){ + $event->setCancelled(); } - if( isset($this->playerTP[$playerName]) && $this->playerTP[$playerName] == true ){ - unset( $this->playerTP[$playerName] ); //$this->areaMessage( 'Fall save off', $player ); - $ev->setCancelled(); - return false; + } + } + + /** Block break + * @param BlockBreakEvent $event + * @ignoreCancelled true + */ + public function onBlockBreak(BlockBreakEvent $event) : void{ + $block = $event->getBlock(); + $player = $event->getPlayer(); + $playerName = strtolower($player->getName()); + if(isset($this->selectingFirst[$playerName])){ + unset($this->selectingFirst[$playerName]); + $this->firstPosition[$playerName] = $block->asVector3(); + $player->sendMessage(TextFormat::GREEN . language::translate("pos1")." ". language::translate("set-to"). ": (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); + $event->setCancelled(); + }elseif(isset($this->selectingSecond[$playerName])){ + unset($this->selectingSecond[$playerName]); + $this->secondPosition[$playerName] = $block->asVector3(); + $player->sendMessage(TextFormat::GREEN . language::translate("pos2")." ". language::translate("set-to"). ": (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); + $event->setCancelled(); + }else{ + if(!$this->canEdit($player, $block)){ + $event->setCancelled(); } } - return true; + } - } + /** onBlockTouch + * @param PlayerInteractEvent $event + * @ignoreCancelled true + */ + public function onBlockTouch(PlayerInteractEvent $event) : void{ + $block = $event->getBlock(); + $player = $event->getPlayer(); + if(!$this->canTouch($player, $block)){ + $event->setCancelled(); + } + } - /** On No fall Damage - * @param EntityDamageEvent $event + /** onInteract + * @param PlayerInteractEvent $event * @ignoreCancelled true */ - /** - * @param Entity $entity - * - * @return bool - */ - public function hasFallDamage(Entity $entity) : bool{ - - $o = true; - if( $entity instanceof Player ){ - $f = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["FallDamage"] : $this->falldamage); - if($f){ - $o = false; - } - $playername = strtolower($entity->getName()); - foreach($this->inArea[$playername] as $areaname){ - if( isset($this->areaList[ $areaname ]) ){ - $area = $this->areaList[$areaname]; - if($area->getFlag("falldamage")){ - $o = false; - } - if(!$area->getFlag("falldamage") && $f){ - $o = true; - } - if($area->isWhitelisted($playername)){ - $o = false; - } - } - } + public function onInteract( PlayerInteractEvent $event ): void{ + if ( !$this->canInteract( $event ) ) { + $event->setCancelled(); } - return $o; - } - - /* - public function onFallDisable(EntityDamageEvent $event) : void{ - $player = $event->getEntity(); - $level = $player->getLevel()->getFolderName(); - $cause = $event->getCause(); - if($event->getEntity() instanceof Player){ - if(!$this->canGetHurt($player)){ - $event->setCancelled(); - } - if($cause == EntityDamageEvent::CAUSE_FALL && $this->hasFallDamage($player)){ - $event->setCancelled(true); - } - } - } - */ - - + } - /** On hurt + /** onHurt * @param EntityDamageEvent $event * @ignoreCancelled true */ @@ -1396,7 +1394,7 @@ public function onHurt(EntityDamageEvent $event) : void{ $this->canDamage( $event ); } - /** On Damage + /** onDamage * @param EntityDamageEvent $event * @ignoreCancelled true */ @@ -1404,7 +1402,100 @@ public function onDamage(EntityDamageEvent $event) : void{ $this->canDamage( $event ); } - /** Edit + /** Mob / Animal spawning + * @param EntitySpawnEvent $event + * @ignoreCancelled true + */ + public function onEntitySpawn( EntitySpawnEvent $event ): void{ + $e = $event->getEntity(); + if( !$e instanceof Player && !$this->canEntitySpawn( $e ) ){ + //$e->flagForDespawn() to slow / ? $e->close(); private.. + $this->getServer()->getPluginManager()->callEvent(new EntityDespawnEvent($e)); + $e->despawnFromAll(); + if($e->chunk !== null){ + $e->chunk->removeEntity($e); + $e->chunk = null; + } + if($e->isValid()){ + $e->level->removeEntity($e); + $e->setLevel(null); + } + } + } + + /** Item drop + * @param itemDropEvent $event + * @ignoreCancelled true + */ + public function onDrop(PlayerDropItemEvent $event){ + $player = $event->getPlayer(); + $position = $player->getPosition(); + if(!$this->canDrop($player, $position)){ + $event->setCancelled(); + return; + } + } + + /** Shoot / Launch projectiles + * @param EntityShootBowEvent $event + * @ignoreCancelled true + */ + public function onEntityShootBow( EntityShootBowEvent $event ){ + $e = $event->getEntity(); + if( $e instanceof Player){ + if( !$this->canShoot($e) ){ + $event->setCancelled(); + } + } + } + + /** on Explode entity + * EntityExplodeEvent + * @param EntityExplodeEvent $event + * @return void + */ + public function onEntityExplode(EntityExplodeEvent $event){ + if (!$this->canExplode( $event->getPosition() )) { + $event->setCancelled(); + } + } + + /** Hunger + * PlayerExhaustEvent + * @param PlayerExhaustEvent $event + * @return void + */ + public function Hunger(PlayerExhaustEvent $event){ + if ( !$this->canHunger( $event ) ) { + $event->setCancelled(); + } + } + + + /** onQuit + * @param Event $event + * @return bool + */ + public function onQuit(PlayerQuitEvent $event){ + + $playerName = strtolower($event->getPlayer()->getName()); + $lvl = $event->getPlayer()->getLevel()->getName(); + unset($this->inArea[$playerName]); + + foreach($this->areas as $area){ + $this->hideAreaTitle( $event->getPlayer(), $event->getPlayer()->getPosition()->getLevel(), $area ); + } + unset( $this->areaTitles[$playerName] ); + + } + + + + + + /** OUTBOUND ACTION */ + + /** canEdit * @param Player $player * @param Position $position * @return bool @@ -1436,24 +1527,7 @@ public function canEdit(Player $player, Position $position) : bool{ return $o; } - - - /** Block Touch - * @param PlayerInteractEvent $event - * @ignoreCancelled true - */ - public function onBlockTouch(PlayerInteractEvent $event) : void{ - - $block = $event->getBlock(); - $player = $event->getPlayer(); - - if(!$this->canTouch($player, $block)){ - $event->setCancelled(); - } - - } - - /** Touch + /** canTouch * @param Player $player * @param Position $position * @return bool @@ -1485,13 +1559,11 @@ public function canTouch(Player $player, Position $position) : bool{ return $o; } - - - /** on Interact - * @param PlayerInteractEvent $event - * @ignoreCancelled true - */ - public function onInteract( PlayerInteractEvent $event ): void{ + /** canInteract + * @param PlayerInteractEvent $event + * @return bool + */ + public function canInteract( PlayerInteractEvent $event ): bool{ $item = $event->getItem(); $block = $event->getBlock(); @@ -1500,272 +1572,270 @@ public function onInteract( PlayerInteractEvent $event ): void{ $playername = strtolower($player->getName()); $b = $block->getID(); $i = $item->getID(); - + /* $player->sendMessage("Action on " . $block->getName() . "(". $block->getID() . ") with ". $item->getName() ."(".$item->getID().") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"); */ if( $player->isOp() || $player->hasPermission("festival") || $player->hasPermission("festival.access")){ - - }else{ - - if( $b == 46 // tnt - && $i == 259 // flint & steel - && !$this->canExplode( $player->getPosition() ) - ){ - $event->setCancelled(); - } - - if( - $b == 199 // item frame - || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) // no farm event - || $i == 259 // apart for fire flag - ){ - if(!$this->canEdit($player, $block)){ - $event->setCancelled(); - } - } - - } - } - - /** hunger - * PlayerExhaustEvent - * @param PlayerExhaustEvent $event - * @return void - */ - public function Hunger(PlayerExhaustEvent $event){ - if ( !$this->canHunger( $event ) ) { - $event->setCancelled(); + return true; } - } - /** - * canhunger() - * Checks if player can exhaust (hunger) - * @param pocketmine\level\Position $pos - * @param pocketmine\level\Level $level - * @return bool - */ - public function canHunger( PlayerExhaustEvent $event ): bool{ - $pos = $event->getPlayer()->getPosition(); - $playername = strtolower($event->getPlayer()->getName()); $o = true; - $h = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Hunger"] : $this->hunger); - if ($h) { + // 46 // tnt //259 // flint & steel + //.. canUseTNT( $player, $b ) + if( $b == Block::TNT && $i == Item::FLINT_AND_STEEL && !$this->canExplode( $player->getPosition() ) ){ $o = false; } - foreach($this->inArea[$playername] as $areaname){ - if( isset($this->areaList[ $areaname ]) ){ - $area = $this->areaList[$areaname]; - if ($area->getFlag("hunger")) { - $o = false; - } - if(!$area->getFlag("hunger") && $h){ - $o = true; - } - if($area->isWhitelisted($playername)){ - $o = false; - } + if( + $b == 199 // item frame + || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) // no farm event + || $i == 259 // apart for fire flag + //.. canBurn( $player->getPosition() ) + ){ + if(!$this->canEdit($player, $block)){ + $o = false; } } 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; - $e = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["TNT"] : $this->tnt); - if ($e) { - $o = false; - } - // including entities/mobs in any area - 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; - } - if(!$area->getFlag("tnt") && $e){ - $o = true; - } - } - } - return $o; } - /** Item drop - * @param itemDropEvent $event - * @ignoreCancelled true + /** Hurt + * @param Entity $entity + * @return bool */ - public function onDrop(PlayerDropItemEvent $event) - { - $player = $event->getPlayer(); - $position = $player->getPosition(); - - if(!$this->canDrop($player, $position)){ - $event->setCancelled(); - return; - } + public function canGetHurt(Entity $entity) : bool{ + $o = true; + if( $entity instanceof Player){ + $g = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["God"] : $this->god); + if($g){ + $o = false; + } + $playername = strtolower($entity->getName()); + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[ $areaname ]; + if($area->getFlag("god")){ + $o = false; + } + if(!$area->getFlag("god") && $g ){ + $o = true; + } + if($area->isWhitelisted($playername)){ + $o = false; + } + } + } + } + return $o; } - /** on Drop - * @param Player $player - * @param Position $position + /** On No fall Damage + * @param Entity $entity * @return bool */ - public function canDrop(Player $player, Position $position) : bool{ - if($player->hasPermission("festival") || $player->hasPermission("festival.access")){ - return true; - } + public function hasFallDamage(Entity $entity) : bool{ + $o = true; - $d = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Drop"] : $this->drop); - if($d){ - $o = false; + if( $entity instanceof Player ){ + $f = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["FallDamage"] : $this->falldamage); + if($f){ + $o = false; + } + $playername = strtolower($entity->getName()); + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + if($area->getFlag("falldamage")){ + $o = false; + } + if(!$area->getFlag("falldamage") && $f){ + $o = true; + } + if($area->isWhitelisted($playername)){ + $o = false; + } + } + } + } + return $o; + } + + /* + public function onFallDisable(EntityDamageEvent $event) : void{ + $player = $event->getEntity(); + $level = $player->getLevel()->getFolderName(); + $cause = $event->getCause(); + if($event->getEntity() instanceof Player){ + if(!$this->canGetHurt($player)){ + $event->setCancelled(); + } + if($cause == EntityDamageEvent::CAUSE_FALL && $this->hasFallDamage($player)){ + $event->setCancelled(true); + } } - $playername = strtolower($player->getName()); - foreach($this->inArea[$playername] as $areaname){ - if( isset($this->areaList[ $areaname ]) ){ - $area = $this->areaList[$areaname]; - if($area->getFlag("drop")){ + } + */ + + /** PVP + * @param Event $ev + * @return bool + */ + public function canPVP(EntityDamageEvent $ev) : bool{ + $o = true; + $god = false; + if($ev instanceof EntityDamageByEntityEvent){ + if($ev->getEntity() instanceof Player && $ev->getDamager() instanceof Player){ + $entity = $ev->getEntity(); + $p = (isset($this->levels[$entity->getLevel()->getName()]) ? $this->levels[$entity->getLevel()->getName()]["PVP"] : $this->pvp); + if($p){ $o = false; } - if(!$area->getFlag("drop") && $d){ - $o = true; - } - if($area->isWhitelisted($playername)){ - $o = true; + $playername = $entity->getName(); + $pos = $entity->getPosition(); + foreach ($this->areas as $area) { + if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { + $god = $area->getFlag("god"); + if($area->getFlag("pvp")){ + $o = false; + } + if( !$area->getFlag("pvp") && $p){ + $o = true; + } + if($area->isWhitelisted($playername)){ + $o = false; + } + } } } + } + if( !$o ){ + $player = $ev->getDamager(); + if( $this->skippTime( 2, strtolower($player->getName()) ) ){ + if( $god ){ + $this->areaMessage( Language::tranlate("all-players-are-god"), $player ); + }else{ + $this->areaMessage( Language::tranlate("no-pvp-area"), $player ); + } + } } return $o; - } + } - /** Shoot / Launch projectiles - * @param EntityShootBowEvent $event + /** Player Damage Impact + * @param EntityDamageEvent $event * @ignoreCancelled true */ - public function onEntityShootBow( EntityShootBowEvent $event ){ + public function canDamage(EntityDamageEvent $ev) : bool{ - $e = $event->getEntity(); - if( $e instanceof Player){ - if( !$this->canShoot($e) ){ - $event->setCancelled(); - } - } + if($ev->getEntity() instanceof Player){ + $player = $ev->getEntity(); + $playerName = strtolower($player->getName()); + if(!$this->canGetHurt($player)){ + if( $player->isOnFire() ){ + $player->extinguish(); // 1.0.7-dev + } + $ev->setCancelled(); + return false; + } + if(!$this->canPVP($ev)){ // v 1.0.6-13 + $ev->setCancelled(); + return false; + } + if( isset($this->playerTP[$playerName]) && $this->playerTP[$playerName] == true ){ + unset( $this->playerTP[$playerName] ); //$this->areaMessage( 'Fall save off', $player ); + $ev->setCancelled(); + return false; + } + } + return true; } - /** onShoot + /** Flight * @param Player $player - * @return bool */ - public function canShoot( Player $player ) : bool{ - - if( $player->isOp() || $player->hasPermission("festival") || $player->hasPermission("festival.access")){ - return true; - } + public function checkPlayerFlying(Player $player){ - $position = $player->getPosition(); + $fly = true; + $sendmsg = false; + $falldamage = false; + $position = $player->getPosition(); $playername = strtolower($player->getName()); - $o = true; - $m = true; - $s = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Shoot"] : $this->shoot); - if($s){ - $o = false; - } + + $f = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Flight"] : $this->flight); + if( $f ){ + $fly = false; // flag default + } foreach($this->inArea[$playername] as $areaname){ if( isset($this->areaList[ $areaname ]) ){ $area = $this->areaList[$areaname]; - if($area->getFlag("shoot")){ - $o = false; + if( $area->getFlag("flight") && !$area->isWhitelisted( $playername ) ){ + $fly = false; // flag area } - if(!$area->getFlag("shoot") && $s){ - $o = true; + if(!$area->getFlag("flight") && $f){ + $fly = true; } - if($area->isWhitelisted($playername)){ - $o = true; + if( !$area->getFlag("msg") ){ + $sendmsg = true; } - if( $area->getFlag("msg") ){ - $m = false; + if( $area->getFlag("falldamage") ){ + $falldamage = true; } } } - - if( $m && !$o ){ // 'ínline' message method - $msg = TextFormat::RED . "NO Shooting here!"; - $player->areaMessage( $msg ); + // ! if( $player->isOp() ){ + if( $player->hasPermission("festival") || $player->hasPermission("festival.access") ){ + $fly = true; + $player->setAllowFlight(true); + return $fly; } - return $o; - } - - /** Mob / Animal spawning - * @param EntitySpawnEvent $event - * @ignoreCancelled true - */ - public function onEntitySpawn( EntitySpawnEvent $event ): void{ - $e = $event->getEntity(); - if( !$e instanceof Player && !$this->canEntitySpawn( $e ) ){ - //$e->flagForDespawn() to slow / ? $e->close(); private.. - $this->getServer()->getPluginManager()->callEvent(new EntityDespawnEvent($e)); - $e->despawnFromAll(); - if($e->chunk !== null){ - $e->chunk->removeEntity($e); - $e->chunk = null; + $msg = ''; + if( !$fly && $player->isFlying() ){ + if( $falldamage ){ + $this->playerTP[ strtolower( $player->getName() ) ] = true; // player tp active (fall save) } - if($e->isValid()){ - $e->level->removeEntity($e); - $e->setLevel(null); + $player->setFlying(false); + //$player->sendMessage( TextFormat::RED . "NO Flying here!" ); + if( $sendmsg ){ + $msg = TextFormat::RED . Language::translate("no-flight-area"); + $player->sendMessage( $msg ); + } + } + if( $fly && !$player->isFlying() && !$player->getAllowFlight() ){ + if( $sendmsg ){ + $msg = TextFormat::GREEN . Language::translate("flight-area"); + $player->sendMessage( $msg ); } } + $player->setAllowFlight($fly); + return $fly; + } + /** canEntitySpawn + * @param Entity $e + * @return bool + */ public function canEntitySpawn( Entity $e ): bool{ - // see pocketmine & PureEntitiesX enitities id's - // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/EntityIds.php - // https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Entity.php - // https://forums.pmmp.io/threads/mobs-spawn-event.6151/ - // https://github.com/LeinneSW/EntityManager $o = true; - if( $e instanceof ExperienceOrb || $e instanceof ItemEntity || $e instanceof Projectile || $e instanceof FloatingTextParticle){ - return $o; // allowed + if( $e instanceof PrimedTNT || $e instanceof ExperienceOrb || $e instanceof ItemEntity || $e instanceof Projectile || $e instanceof FloatingTextParticle){ + return $o; // might be allowed to spawn under different flag } - // catch more spawning entities without (get)Name - if( $e instanceof PrimedTNT ){ - if( $this->canExplode( $e->getPosition() )){ // Prevent PrimedTNT (experiment) - return true; - }else{ - return false; - } - } - - $nm = ''; //$nm = $e instanceof Item ? $e->getItem()->getName() : $e->getName(); + $nm = ''; // if( null !== $e->getName() ){ - $nm = $e->getName(); + $nm = $e instanceof Item ? $e->getItem()->getName() : $e->getName(); } $pos = false; if( null !== $e->getPosition() ){ $pos = $e->getPosition(); } + + if($pos && $nm != ''){ $animals =[ 'bat','chicken','cow','horse','llama','donkey','mule','ocelot','parrot','fish','dolphin','squit','pig','rabbit','sheep','pufferfish','salmon','turtle','tropical_fish','cod','balloon']; @@ -1813,277 +1883,273 @@ public function canEntitySpawn( Entity $e ): bool{ return $o; } - /** Block Place - * @param BlockPlaceEvent $event - * @ignoreCancelled true - */ - public function onBlockPlace(BlockPlaceEvent $event) : void{ - $block = $event->getBlock(); - $player = $event->getPlayer(); - $playerName = strtolower($player->getName()); - - if(isset($this->selectingFirst[$playerName])){ - - unset($this->selectingFirst[$playerName]); - $this->firstPosition[$playerName] = $block->asVector3(); - $player->sendMessage(TextFormat::GREEN . language::translate("pos1")." ". language::translate("set-to"). ": (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); - $event->setCancelled(); - - }elseif(isset($this->selectingSecond[$playerName])){ - - unset($this->selectingSecond[$playerName]); - $this->secondPosition[$playerName] = $block->asVector3(); - $player->sendMessage(TextFormat::GREEN . language::translate("pos2")." ". language::translate("set-to"). ": (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); - $event->setCancelled(); - - }else{ + /** Effects + * @param Player $player + * @return bool + */ + public function canUseEffects( Player $player ) : bool{ - // tnt block - if( $block->getID() == 46 && !$this->canExplode( $player->getPosition() ) ){ + if($player->hasPermission("festival") || $player->hasPermission("festival.access")){ + return true; + } - if( $player->isOp() || $player->hasPermission("festival") || $player->hasPermission("festival.access")){ + $position = $player->getPosition(); + $playername = strtolower($player->getName()); + $o = true; + $e = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Effects"] : $this->effects); + if($e){ + $o = false; + } - }else{ - $event->setCancelled(); - //$player->sendMessage("TNT not allowed here"); + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + if($area->getFlag("effects")){ + $o = false; + } + if(!$area->getFlag("effects") && $e){ + $o = true; + } + if( $area->isWhitelisted( $playername ) ){ + $o = true; } } + } - if(!$this->canEdit($player, $block)){ - $event->setCancelled(); - } - - } + return $o; } - /** Block break - * @param BlockBreakEvent $event - * @ignoreCancelled true + /** canDrop + * @param Player $player + * @param Position $position + * @return bool */ - public function onBlockBreak(BlockBreakEvent $event) : void{ - $block = $event->getBlock(); - $player = $event->getPlayer(); - $playerName = strtolower($player->getName()); - if(isset($this->selectingFirst[$playerName])){ - unset($this->selectingFirst[$playerName]); - $this->firstPosition[$playerName] = $block->asVector3(); - $player->sendMessage(TextFormat::GREEN . language::translate("pos1")." ". language::translate("set-to"). ": (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); - $event->setCancelled(); - }elseif(isset($this->selectingSecond[$playerName])){ - unset($this->selectingSecond[$playerName]); - $this->secondPosition[$playerName] = $block->asVector3(); - $player->sendMessage(TextFormat::GREEN . language::translate("pos2")." ". language::translate("set-to"). ": (" . $block->getX() . ", " . $block->getY() . ", " . $block->getZ() . ")"); - $event->setCancelled(); - }else{ - if(!$this->canEdit($player, $block)){ - $event->setCancelled(); - } + public function canDrop(Player $player, Position $position) : bool{ + if($player->hasPermission("festival") || $player->hasPermission("festival.access")){ + return true; } + $o = true; + $d = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Drop"] : $this->drop); + if($d){ + $o = false; + } + $playername = strtolower($player->getName()); + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + if($area->getFlag("drop")){ + $o = false; + } + if(!$area->getFlag("drop") && $d){ + $o = true; + } + if($area->isWhitelisted($playername)){ + $o = true; + } + } + } + return $o; } - /** Op Perms - * @param Player $player - * @param Area $area + /** + * canBurn() + * Checks if fire is allowed on given position + * @param flag $this->fire + * @param pocketmine\level\Position $pos + * @param pocketmine\level\Level $level + * @return bool + + public function canBurn( Position $pos ): bool{ + $o = true; + $e = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Fire"] : $this->fire); + if ($e) { + $o = false; + } + // including entities/mobs in any area + foreach ($this->areas as $area) { + if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { + if ($area->getFlag("fire")) { + $o = false; + } + if(!$area->getFlag("fire") && $e){ + $o = true; + } + } + } + return $o; + } + */ + + /** + * 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; + $e = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["TNT"] : $this->tnt); + if ($e) { + $o = false; + } + // including entities/mobs in any area + 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; + } + if(!$area->getFlag("tnt") && $e){ + $o = true; + } + } + } + return $o; + } + + /** canUseTNT() + * Checks if TNT is allowed to be used by player on given position + * @param flag $this->tnt + * @param Player $player + * @param Position $position * @return bool - */ - public function useOpPerms(Player $player, Area $area) : bool{ + public function canUseTNT(Player $player, Position $position) : bool{ if($player->hasPermission("festival") || $player->hasPermission("festival.access")){ - return true; // festival ops.. + return true; } - - $position = $player->getPosition(); $o = true; - $p = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[ $position->getLevel()->getName() ]["Perms"] : $this->perms); - if($p){ - $o = false; - } - if( $area->getFlag("perms") ){ + $d = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["TNT"] : $this->tnt); + if($d){ $o = false; } - if(!$area->getFlag("perms") && $p){ - $o = true; + $playername = strtolower($player->getName()); + foreach($this->inArea[$playername] as $areaname){ + if( isset($this->areaList[ $areaname ]) ){ + $area = $this->areaList[$areaname]; + if($area->getFlag("tnt")){ + $o = false; + } + if(!$area->getFlag("tnt") && $d){ + $o = true; + } + if($area->isWhitelisted($playername)){ + $o = true; + } + } } - if( $area->isWhitelisted( strtolower( $player->getName() ) ) ){ - $o = true; - } return $o; } + */ - /** Effects + /** canShoot * @param Player $player * @return bool */ - public function canUseEffects( Player $player ) : bool{ + public function canShoot( Player $player ) : bool{ - if($player->hasPermission("festival") || $player->hasPermission("festival.access")){ + if( $player->hasPermission("festival") || $player->hasPermission("festival.access")){ return true; } $position = $player->getPosition(); $playername = strtolower($player->getName()); $o = true; - $e = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Effects"] : $this->effects); - if($e){ + $m = true; + $s = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Shoot"] : $this->shoot); + if($s){ $o = false; } foreach($this->inArea[$playername] as $areaname){ if( isset($this->areaList[ $areaname ]) ){ $area = $this->areaList[$areaname]; - if($area->getFlag("effects")){ + if($area->getFlag("shoot")){ $o = false; } - if(!$area->getFlag("effects") && $e){ + if(!$area->getFlag("shoot") && $s){ $o = true; } - if( $area->isWhitelisted( $playername ) ){ + if($area->isWhitelisted($playername)){ $o = true; } + if( $area->getFlag("msg") ){ + $m = false; + } } } + if( $m && !$o ){ // 'ínline' message method + $msg = TextFormat::RED . "NO Shooting here!"; + $player->areaMessage( $msg ); + } return $o; - } + } - /** Flight + /** useOpPerms * @param Player $player - */ - public function checkPlayerFlying(Player $player){ + * @param Area $area + * @return bool + */ + public function useOpPerms(Player $player, Area $area) : bool{ - $fly = true; - $sendmsg = false; - $falldamage = false; - $position = $player->getPosition(); - $playername = strtolower($player->getName()); + if($player->hasPermission("festival") || $player->hasPermission("festival.access")){ + return true; // festival ops.. + } - $f = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["Flight"] : $this->flight); - if( $f ){ - $fly = false; // flag default + $position = $player->getPosition(); + $o = true; + $p = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[ $position->getLevel()->getName() ]["Perms"] : $this->perms); + if($p){ + $o = false; + } + if( $area->getFlag("perms") ){ + $o = false; + } + if(!$area->getFlag("perms") && $p){ + $o = true; } + if( $area->isWhitelisted( strtolower( $player->getName() ) ) ){ + $o = true; + } + return $o; + } + /** + * canhunger() + * Checks if player can exhaust (hunger) + * @param pocketmine\level\Position $pos + * @param pocketmine\level\Level $level + * @return bool + */ + public function canHunger( PlayerExhaustEvent $event ): bool{ + $pos = $event->getPlayer()->getPosition(); + $playername = strtolower($event->getPlayer()->getName()); + $o = true; + $h = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Hunger"] : $this->hunger); + if ($h) { + $o = false; + } foreach($this->inArea[$playername] as $areaname){ if( isset($this->areaList[ $areaname ]) ){ $area = $this->areaList[$areaname]; - if( $area->getFlag("flight") && !$area->isWhitelisted( $playername ) ){ - $fly = false; // flag area - } - if(!$area->getFlag("flight") && $f){ - $fly = true; + if ($area->getFlag("hunger")) { + $o = false; } - if( !$area->getFlag("msg") ){ - $sendmsg = true; + if(!$area->getFlag("hunger") && $h){ + $o = true; } - if( $area->getFlag("falldamage") ){ - $falldamage = true; + if($area->isWhitelisted($playername)){ + $o = false; } } } - if( $player->isOp() ){ - $fly = true; // ops can fly || - $sendmsg = true; - if( isset($area) ){ - $sendmsg = $this->msgOpDsp( $area, $player ); - } - } - $msg = ''; - if( !$fly && $player->isFlying() ){ - if( $falldamage ){ - $this->playerTP[ strtolower( $player->getName() ) ] = true; // player tp active (fall save) - } - $player->setFlying(false); - //$player->sendMessage( TextFormat::RED . "NO Flying here!" ); - if( $sendmsg ){ - $msg = TextFormat::RED . Language::translate("no-flight-area"); - $player->sendMessage( $msg ); - } - } - if( $fly && !$player->isFlying() && !$player->getAllowFlight() ){ - if( $sendmsg ){ - $msg = TextFormat::GREEN . Language::translate("flight-area"); - $player->sendMessage( $msg ); - } - } - $player->setAllowFlight($fly); - return $fly; - + return $o; } - /** On player move .. - * @param PlayerMoveEvent $ev - * @var string inArea - * @return true - */ - public function onMove(PlayerMoveEvent $ev) : void{ - - $player = $ev->getPlayer(); - $playerName = strtolower( $player->getName() ); - - if( !isset( $this->inArea[$playerName] ) ){ - $this->inArea[$playerName] = []; - } - - foreach($this->areas as $area){ - - // Player area passage - if( $area->getFlag("passage") ){ - if( $player->isOp() || $area->isWhitelisted( strtolower( $player->getName() ) ) || $player->hasPermission("festival") || $player->hasPermission("festival.access") ){ - if( ( $area->contains( $player->getPosition(), $player->getLevel()->getName() ) && !$area->contains( $ev->getFrom(), $player->getLevel()->getName() ) ) - || !$area->contains( $player->getPosition(), $player->getLevel()->getName() ) && $area->contains( $ev->getFrom(), $player->getLevel()->getName() ) ){ - // ops & whitelist players pass - $this->barrierCrossByOp($area, $ev); - break; - } - }else{ - if( $area->contains( $player->getPosition(), $player->getLevel()->getName() ) - && !$area->contains( $ev->getFrom(), $player->getLevel()->getName() ) ){ - $this->barrierEnterArea($area, $ev); - break; - } - if( !$area->contains( $player->getPosition(), $player->getLevel()->getName() ) - && $area->contains( $ev->getFrom(), $player->getLevel()->getName() ) ){ - $this->barrierLeaveArea($area, $ev); - break; - } - } - } - // Player enter or leave area - if( !$area->contains( $player->getPosition(), $player->getLevel()->getName() ) ){ - // Player leave Area - if( in_array( strtolower( $area->getName() ) , $this->inArea[$playerName] ) ){ - $this->leaveArea($area, $ev); - break; - } - }else{ - // Player enter Area - if( !in_array( strtolower( $area->getName() ), $this->inArea[$playerName] ) ){ - $this->enterArea($area, $ev); - break; - } - // Player enter Area Center - if( $area->centerContains( $player->getPosition(), $player->getLevel()->getName() ) ){ - if( !in_array( strtolower( $area->getName() )."center", $this->inArea[$playerName] ) ){ // Player enter in Area - $this->enterAreaCenter($area, $ev); - break; - } - }else{ - // Player leave Area Center - if( in_array( strtolower( $area->getName()."center" ) , $this->inArea[$playerName] ) ){ - $this->leaveAreaCenter($area, $ev); - break; - } - } - } - /** Area Player Monitor */ - //$this->AreaPlayerMonitor($area, $ev); - } - - $this->checkPlayerFlying( $ev->getPlayer() ); - return; - } /** Area Player Monitor/Task * @param area Area @@ -2429,7 +2495,7 @@ public function areaInfoDisplayList( $area ){ $l .= "\n". TextFormat::GRAY . " - ". Language::translate("players-in-area") .": \n " . TextFormat::GOLD . implode(", ", $ap ); } - // Area Flag text colors GREEN, AQUA, BLUE, RED, WHITE, YELLOW, LIGHT_PURPLE, DARK_PURPLE, GOLD, GRAY + // Area Flag $flgs = $area->getFlags(); $l .= "\n". TextFormat::GRAY . " - ". Language::translate("flags") ." :"; foreach($flgs as $fi => $flg){ @@ -2461,7 +2527,6 @@ public function areaInfoDisplayList( $area ){ } - /** isWhitelisted global or specific area * @param Player $player * @param Area $area @@ -2480,28 +2545,6 @@ public function isWhitelisted( $player, $area = false ): bool{ return false; } - /** onJoin Area Titles for Player ( FloatingTextParticle ) - * @param PlayerJoinEvent $event - */ - public function onJoin(PlayerJoinEvent $event){ - $player = $event->getPlayer(); - $level = $player->getLevel(); // $this->getServer()->getDefaultLevel(); - $this->areaTitles[strtolower($player->getName())] = []; - $this->checkAreaTitles( $player, $level ); - } - - /** levelChange Area Titles for Player ( FloatingTextParticle ) - * @param EntityLevelChangeEvent $event - */ - public function levelChange(EntityLevelChangeEvent $event) { - $entity = $event->getEntity(); - if ($entity instanceof Player) { - $level = $event->getTarget(); - $this->checkAreaTitles( $entity, $level ); - } - } - - /** Check Floating Area Title placement( FloatingTextParticle ) * @param Vector3 $pos * @param string $text @@ -2574,12 +2617,18 @@ public function saveAreas() : void{ * makes it easy to find Festival console output fast */ public function codeSigned(){ - - $this->getLogger()->info( "by -----------.------------" ); - $this->getLogger()->info( " ,-. ,-. ,-. |-. ,-. . . " ); - $this->getLogger()->info( " | | |-' | | | | | | | | " ); - $this->getLogger()->info( " `-| `-' ' ' `-' `-' `-| " ); - $this->getLogger()->info( "--`-'-----------------`-'--" ); - + $this->getLogger()->info( " " ); + $this->getLogger()->info( " |~ " ); + $this->getLogger()->info( " .___---^^^ ^^^---___. " ); + $this->getLogger()->info( " ___|~__/_____________________\___|~__ " ); + $this->getLogger()->info( " /_______\ ._____. /_______\ " ); + $this->getLogger()->info( " / |\ / | F | \ |\ \ " ); + $this->getLogger()->info( "------------------'-----'-------------------" ); + $this->getLogger()->info( " ____ ___ _ |_| _ " ); + $this->getLogger()->info( " | __|| -_| ___ | |_ | | _ _ ___ | | " ); + $this->getLogger()->info( " | _| |___||_ -|| _ | | | | || .'|| | " ); + $this->getLogger()->info( " |_| |___||_| |_| \__/ |__,||_| " ); + $this->getLogger()->info( " GENBOY 2018 " ); } + } From 5ea185a6eb2302c2f2e71606ec19059b3ac8be58 Mon Sep 17 00:00:00 2001 From: genboy Date: Tue, 16 Oct 2018 22:50:19 +0200 Subject: [PATCH 60/68] Info & image update --- README.md | 88 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 67 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 97da8f3..d07a604 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ 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/08/festival_usage_1.0.7.5-dev.png) +![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/10/festival_usage_1.0.7.9-dev.png) ###### Copyright [Genboy](https://genboy.net) 2018 @@ -28,6 +28,8 @@ Create a festival with this custom area events plugin for Pocketmine Server: [issues @ github](https://github.com/genboy/Festival/issues) and/or [reviews @ poggit](https://poggit.pmmp.io/p/Festival) +More info also available at [the Festival Wiki](https://github.com/genboy/Festival/wiki) + !Please before asking first double-check your server basic world configurations, other plugins configurations (ie. worldguard) and the used player permissions incl. Festival whitelistings. #### Features @@ -56,7 +58,7 @@ Create a festival with this custom area events plugin for Pocketmine Server: - Set area flags ingame Flags: Any flag true will protect the area and the players in it. - ie. edit: true (on) means no breaking/building by players. shoot: true (on) means no shooting by players. + ie. edit: true (on) means no breaking/building by players. shoot: true (on) means no shooting by players. - edit: the area is save from building/breaking - god: players in the area are save in god mode @@ -66,7 +68,7 @@ Create a festival with this custom area events plugin for Pocketmine Server: - animals: no animal spawning (including spawners & eggs) - mobs: no mobs spawning (including spawners & eggs) - effects: player can not keep using effects in the area - - msg: do not display area enter/leave messages + - msg: do not display area enter/leave messages - passage: no passage for non-whitelisted players! (previously barrier flag) - drop: players can not drop things - tnt: explosions protected area @@ -86,7 +88,7 @@ Create a festival with this custom area events plugin for Pocketmine Server: - variable player in commands with {player} or @p - add/edit/delete area event command - list area commands (ordered by event) - - change event of area commands + - change event of area commands **Specific** @@ -138,11 +140,20 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). ##### A visualisation of Festival command usage - ![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/08/festival_usage_1.0.7.5-dev.png) + ![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/10/festival_usage_1.0.7.9-dev.png) ###### Copyright [Genboy](https://genboy.net) 2018 + + #### Language + + Set Festival language en/nl for area and command returned messages. + en = english + nl = nederlands + __ = your language, please help [translate __.js](https://github.com/genboy/Festival/blob/master/resources/en.json) + + #### Create area First command '/fe pos1' and tab or break a block for position 1 (holding a block, not an item), @@ -183,7 +194,12 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). Area flag listing /fe flag list + + #### Delete an area + + /fe delete(del,remove) + #### Position info @@ -191,42 +207,37 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). /fe here + #### List all area's See all area info, optional per level /fe list () + #### Teleport to area Teleporting to area center top, drop with no falldamage (if falldamage flag true) /fe tp + #### Toggle level area's floating title display Area floating title display (default set in config.yml) - /fe titles - - + /fe titles #### Set description /fe desc + #### Manage whitelist /fe whitelist - - #### Delete an area - - /fe delete(del,remove) - - - - + #### Area event commands @@ -285,6 +296,7 @@ If you like to help improve this plugin; - download/use the plugin and give your feedback - look at the code and give feedback +- help translating [__.js](https://github.com/genboy/Festival/blob/master/resources/en.json) - both by submitting [issues @ github](https://github.com/genboy/Festival/issues) and/or [reviews @ poggit](https://poggit.pmmp.io/p/Festival) or send an email to msg @ genboy.net @@ -325,8 +337,35 @@ Thank you - [x] No shooting (bow) - [x] No Fall Damage flag (was implemented as effect for TP dropping and flight break) - - +### Milestones v1.0.7 - v1.0.7.9 + + - [x] Areas floating title + - set config option Areadisplay (off/op/on) + - never or on command (off) + - for ops only always (op) + - for all players if msg flag true (on) + - display toggle /fe titles for ops + - [x] Add translation options + - set config option language (en/nl/..) + - ops change language /fe lang + - English en + - Nederlands nl + - [x] Enhancements Edit Flag + - No Farmland creation + - No Fire from Flint & Steel + - protect item in frame use + - [x] Enhancements TNT Flag (experimental) + - No TNT placing + - No TNT ignition with Flint & Steel + - [x] Spawning: Prevent mob spawning (and spawners/eggs) in area's + - Prevent spawn (incl. spawners/eggs) (EntitySpawnEvent)! + - Mobs flag prevent mobs from spawning in area + - Animals flag prevent animals from spawning in area + - [x] Area messages display in chat with config option Msgtype 'msg' + - [x] cmd flag: area event commands for ops or whitelisted players only + + + ### History **Since v1.0.3-11+** @@ -363,15 +402,22 @@ Thank you - new animals and mobs (spawning) flag - Fixes itemframe and farmland edit - **Since v1.0.8** + **Since v1.0.7.9** - /fe lang - set Festival language - Edit flag includes No Farmland creation - Edit flag includes No Fire from Flint & Steel - Edit flag includes No TNT placing - Edit flag includes No TNT ignition with Flint & Steel - Edit flag includes protect item in frame use - ------- + - Areas floating title + - Add translation options (en/nl/..) + - Spawning: Prevent mob/animal spawning (and spawners/eggs) in area's + - Mobs flag prevent mobs from spawning in area + - Animals flag prevent animals from spawning in area + - Area messages display in chat with config option Msgtype 'msg' + - cmd flag: area event commands for ops or whitelisted players only + +------ ## Credits From cf7f0f9150dcb3505251014c38210d264fe02a35 Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 20 Oct 2018 01:27:22 +0200 Subject: [PATCH 61/68] fix spawnentity FallingBlock FallingSand --- src/genboy/Festival/Main.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 63c6cc9..61e857c 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -45,6 +45,8 @@ use pocketmine\block\Block; use pocketmine\entity\object\ExperienceOrb; use pocketmine\entity\object\ItemEntity; +use pocketmine\entity\object\FallingBlock; +use pocketmine\entity\object\FallingSand; use pocketmine\entity\object\PrimedTNT; use pocketmine\entity\projectile\Arrow; use pocketmine\entity\projectile\Projectile; @@ -1822,7 +1824,7 @@ public function checkPlayerFlying(Player $player){ public function canEntitySpawn( Entity $e ): bool{ $o = true; - if( $e instanceof PrimedTNT || $e instanceof ExperienceOrb || $e instanceof ItemEntity || $e instanceof Projectile || $e instanceof FloatingTextParticle){ + if( $e instanceof FallingBlock || $e instanceof FallingSand || $e instanceof PrimedTNT || $e instanceof ExperienceOrb || $e instanceof ItemEntity || $e instanceof Projectile || $e instanceof FloatingTextParticle){ return $o; // might be allowed to spawn under different flag } From 058f94a23a6569d85a38de33df389a81474ba522 Mon Sep 17 00:00:00 2001 From: genboy Date: Wed, 24 Oct 2018 01:58:03 +0200 Subject: [PATCH 62/68] Separated Explode, TNT and Fire flags --- src/genboy/Festival/Main.php | 213 ++++++++++++++++++++++++++--------- 1 file changed, 157 insertions(+), 56 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 61e857c..6a4bbbb 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -20,15 +20,6 @@ * language: en/nl, Msgtype: msg/title/tip/pop, Areadisplay: off/op/on, Msgdisplay: off/op/on * Flags: god, pvp, flight, edit, touch, mobs, animals, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage, cmdmode * - * Development Notes - * text colors GREEN, AQUA, BLUE, RED, WHITE, YELLOW, LIGHT_PURPLE, DARK_PURPLE, GOLD, GRAY - * enitities id's - * https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/EntityIds.php - * https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Entity.php - * https://forums.pmmp.io/threads/mobs-spawn-event.6151/ - * https://github.com/LeinneSW/EntityManager - * player action - * http://forums.pocketmine.net/threads/get-the-player-who-fired-tnt.14640/ */ declare(strict_types = 1); @@ -52,6 +43,7 @@ use pocketmine\entity\projectile\Projectile; use pocketmine\event\block\BlockBreakEvent; use pocketmine\event\block\BlockPlaceEvent; +use pocketmine\event\block\BlockUpdateEvent; use pocketmine\event\block\BlockBurnEvent; use pocketmine\event\entity\EntitySpawnEvent; use pocketmine\event\entity\EntityDespawnEvent; @@ -110,8 +102,12 @@ class Main extends PluginBase implements Listener{ /** @var bool */ private $drop = false; /** @var bool */ + private $explode = false; + /** @var bool */ private $tnt = false; /** @var bool */ + private $fire = false; + /** @var bool */ private $shoot = false; /** @var bool */ private $hunger = false; @@ -247,9 +243,15 @@ public function onEnable() : void{ if(!isset($c["Default"]["Flight"])) { // new in v1.0.6-13 $c["Default"]["Flight"] = false; } - if(!isset($c["Default"]["TNT"])) { // new in v1.0.7 + if(!isset($c["Default"]["Explode"])) { // new in v1.0.7.9 + $c["Default"]["Explode"] = false; + } + if(!isset($c["Default"]["TNT"])) { // new in v1.0.7.3 $c["Default"]["TNT"] = false; } + if(!isset($c["Default"]["Fire"])) { // new in v1.0.7.9 + $c["Default"]["Fire"] = false; + } if(!isset($c["Default"]["Shoot"])) { // new in v1.0.7 $c["Default"]["Shoot"] = false; } @@ -276,7 +278,9 @@ public function onEnable() : void{ $this->effects = $c["Default"]["Effects"]; // new in v1.0.5-12 $this->pvp = $c["Default"]["PVP"]; // new in v1.0.6-13 $this->flight = $c["Default"]["Flight"]; // new in v1.0.6-13 + $this->explode = $c["Default"]["Explode"]; // new in v1.0.7.9 $this->tnt = $c["Default"]["TNT"]; // new in v1.0.7.3 + $this->fire = $c["Default"]["Fire"]; // new in v1.0.7.9 $this->hunger = $c["Default"]["Hunger"]; // new in v1.0.7.3 $this->falldamage = $c["Default"]["FallDamage"]; // new in 1.0.7.2-dev(1.0.8) $this->shoot = $c["Default"]["Shoot"]; // new in 1.0.7.2-dev(1.0.8) @@ -315,9 +319,15 @@ public function onEnable() : void{ if( !isset($flags["Flight"]) ){ // new v1.0.6-13 $flags["Flight"] = $this->flight; } - if( !isset($flags["TNT"]) ){ // new v1.0.7 + if( !isset($flags["Explode"]) ){ // new v1.0.7.9 + $flags["Explode"] = $this->explode; + } + if( !isset($flags["TNT"]) ){ // new v1.0.7.3 $flags["TNT"] = $this->tnt; } + if( !isset($flags["Fire"]) ){ // new v1.0.7.9 + $flags["Fire"] = $this->fire; + } if( !isset($flags["Hunger"]) ){ // new v1.0.7 $flags["Hunger"] = $this->hunger; } @@ -347,39 +357,47 @@ public function onEnable() : void{ } if( !isset($datum["flags"]["perms"]) ){ // new flags v 1.0.5-12 $flags["perms"] = false; - $newchange['Msgtype'] = "! Perms ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + $newchange['Perms'] = "! Perms ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } if( !isset($datum["flags"]["drop"]) ){ // new flags v 1.0.5-12 $flags["drop"] = false; - $newchange['Msgtype'] = "! Drop ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + $newchange['canInteract'] = "! Drop ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } if( !isset($datum["flags"]["animals"]) ){ // new flags v 1.0.7.5-dev $flags["animals"] = false; - $newchange['Msgtype'] = "! Animals ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + $newchange['Animals'] = "! Animals ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } if( !isset($datum["flags"]["mobs"]) ){ // new flags v 1.0.7.5-dev $flags["mobs"] = false; - $newchange['Msgtype'] = "! Mobs ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + $newchange['Mobs'] = "! Mobs ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } if( !isset($datum["flags"]["effects"]) ){ // new flags v 1.0.5-12 $flags["effects"] = false; - $newchange['Msgtype'] = "! Effects ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + $newchange['Effects'] = "! Effects ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } if( !isset($datum["flags"]["pvp"]) ){ //new flags v 1.0.6-13 $flags["pvp"] = false; - $newchange['Msgtype'] = "! PVP ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + $newchange['PVP'] = "! PVP ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } if( !isset($datum["flags"]["flight"]) ){ //new flags v 1.0.6-13 $flags["flight"] = false; - $newchange['Msgtype'] = "! Flight ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + $newchange['Flight'] = "! Flight ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + if( !isset($datum["flags"]["explode"]) ){ // new flags v 1.0.7.9 + $flags["explode"] = false; + $newchange['Explode'] = "! Explode ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } - if( !isset($datum["flags"]["tnt"]) ){ // new flags v 1.0.7 + if( !isset($datum["flags"]["tnt"]) ){ // new flags v 1.0.7.3 $flags["tnt"] = false; - $newchange['Msgtype'] = "! TNT ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + $newchange['TNT'] = "! TNT ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + } + if( !isset($datum["flags"]["fire"]) ){ // new flags v 1.0.7.9 + $flags["fire"] = false; + $newchange['Fire'] = "! Fire ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } if( !isset($datum["flags"]["hunger"]) ){ // new flags v 1.0.7 $flags["hunger"] = false; - $newchange['Msgtype'] = "! Hunger ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + $newchange['Hunger'] = "! Hunger ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } if( isset($datum["flags"]["nofalldamage"]) ){ $flags["falldamage"] = $datum["flags"]["nofalldamage"]; // replaced in v1.0.5-11 can use both @@ -388,11 +406,11 @@ public function onEnable() : void{ } if( !isset($datum["flags"]["falldamage"]) ){ //new in v1.0.7.3 $flags["falldamage"] = false; - $newchange['Msgtype'] = "! FallDamage ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + $newchange['FallDamage'] = "! FallDamage ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } if( !isset($datum["flags"]["shoot"]) ){ //new in v1.0.7.4 $flags["shoot"] = false; - $newchange['Msgtype'] = "! Shoot ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); + $newchange['Shoot'] = "! Shoot ".Language::translate("flag-missing-in-config")." 'false'; ". Language::translate("option-see-configfile"); } if( !isset($datum["flags"]["cmdmode"]) ){ //new in v1.0.7.4 $flags["cmdmode"] = false; @@ -482,7 +500,9 @@ public function isFlag( $str ){ "mobs","mob", "animals","animal", "effects","magic","effect", - "tnt","explode", + "tnt", + "explode","explosion","explosions", + "fire","fires","burn", "hunger","starve", "drop", "msg","message", @@ -526,9 +546,15 @@ public function isFlag( $str ){ if( $str == "pass" || $str == "barrier" ){ $flag = "passage"; } - if( $str == "tnt" || $str == "explode" ){ + if( $str == "explosion" || $str == "explosions" || $str == "explode" ){ + $flag = "explode"; + } + if( $str == "tnt" ){ $flag = "tnt"; } + if( $str == "fire" || $str == "fires" || $str == "burn" ){ + $flag = "fire"; + } if( $str == "shoot" || $str == "launch" ){ $flag = "shoot"; } @@ -835,8 +861,13 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar case "perms": case "hunger": case "starve": + case "fire": + case "fires": + case "burn": case "tnt": case "explode": + case "explosion": + case "explosions": case "shoot": case "launch": case "drop": @@ -855,7 +886,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar * Revert a flag in all area's (v1.0.4-11) */ if($args[1] == 'swappall'){ - $flag = $this->isFlag( $args[0] ); // v1.0.6-13 + $flag = $this->isFlag( $args[0] ); // since v1.0.6-13 if( $flag ){ foreach($this->areas as $area){ if($area->getFlag($flag)){ @@ -1328,7 +1359,7 @@ public function onBlockPlace(BlockPlaceEvent $event) : void{ $event->setCancelled(); }else{ // .. canUseTNT( $player, $block ) - if( $block->getID() == Block::TNT && !$this->canExplode( $player->getPosition() ) ){ + if( $block->getID() == Block::TNT && !$this->canUseTNT( $player, $block ) ){ if( $player->hasPermission("festival") || $player->hasPermission("festival.access") ){ }else{ $event->setCancelled(); @@ -1388,6 +1419,30 @@ public function onInteract( PlayerInteractEvent $event ): void{ } } + + /** onBlockUpdate + * BlockUpdateEvent + * @param BlockUpdateEvent $event + * @return void + + public function onBlockUpdate( BlockUpdateEvent $event ): void{ + + $block = $event->getBlock(); + $position = new Position($block->getFloorX(), $block->getFloorY(), $block->getFloorZ(), $block->getLevel()); + $levelname = $block->getLevel()->getName(); + // fire + $f = true; + if( $this->getServer()->getLevelByName( $levelname )->getBlockIdAt($block->x, $block->y + 1, $block->z) == 51 ){ // is fire above + if( !$this->canBurn( $position ) ){ // is fire not allowed? // Block::FIRE + $this->getServer()->getLevelByName( $levelname )->setBlockIdAt( $block->x, $block->y + 1, $block->z, 0); + } + } + $msg = TextFormat::RED . "Updated " . $block->getName() . "(". $block->getID() . ") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"; + $this->getLogger()->info( $msg ); + + } + */ + /** onHurt * @param EntityDamageEvent $event * @ignoreCancelled true @@ -1409,7 +1464,9 @@ public function onDamage(EntityDamageEvent $event) : void{ * @ignoreCancelled true */ public function onEntitySpawn( EntitySpawnEvent $event ): void{ + $e = $event->getEntity(); + //($e instanceof Fire && !$this->canBurn( $e->getPosition() )) || ( if( !$e instanceof Player && !$this->canEntitySpawn( $e ) ){ //$e->flagForDespawn() to slow / ? $e->close(); private.. $this->getServer()->getPluginManager()->callEvent(new EntityDespawnEvent($e)); @@ -1423,6 +1480,7 @@ public function onEntitySpawn( EntitySpawnEvent $event ): void{ $e->setLevel(null); } } + } /** Item drop @@ -1451,17 +1509,25 @@ public function onEntityShootBow( EntityShootBowEvent $event ){ } } - /** on Explode entity + /** on Explode entity // canExplode * EntityExplodeEvent * @param EntityExplodeEvent $event * @return void */ public function onEntityExplode(EntityExplodeEvent $event){ - if (!$this->canExplode( $event->getPosition() )) { + + $e = $event->getEntity(); + if( $e instanceof PrimedTNT ){ + if( !$this->canTNTExplode( $event->getPosition() ) ){ + $event->setCancelled(); // ? on + } + }else if (!$this->canExplode( $event->getPosition() )) { $event->setCancelled(); } + } + /** Hunger * PlayerExhaustEvent * @param PlayerExhaustEvent $event @@ -1491,10 +1557,6 @@ public function onQuit(PlayerQuitEvent $event){ } - - - - /** OUTBOUND ACTION */ /** canEdit @@ -1570,30 +1632,31 @@ public function canInteract( PlayerInteractEvent $event ): bool{ $item = $event->getItem(); $block = $event->getBlock(); $player = $event->getPlayer(); - $position = $player->getPosition(); + $position = new Position($block->getFloorX(), $block->getFloorY(), $block->getFloorZ(), $block->getLevel());// $player->getPosition(); $playername = strtolower($player->getName()); $b = $block->getID(); $i = $item->getID(); - /* - $player->sendMessage("Action on " . $block->getName() . "(". $block->getID() . ") with ". $item->getName() ."(".$item->getID().") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"); - */ + // $player->sendMessage("Action on ".$block->getName()."(".$block->getID().") with ".$item->getName()."(".$item->getID().") at [x=".round($block->x). " y=".round($block->y)." z=".round($block->z)."]"); + if( $player->isOp() || $player->hasPermission("festival") || $player->hasPermission("festival.access")){ return true; } - $o = true; - // 46 // tnt //259 // flint & steel - //.. canUseTNT( $player, $b ) - if( $b == Block::TNT && $i == Item::FLINT_AND_STEEL && !$this->canExplode( $player->getPosition() ) ){ - $o = false; + // tnt flag id 46 Block::TNT _ id 259 FLINT_AND_STEEL ? canUseTNT( $player, $b ) + if( $b == 46 && $i == 259 && !$this->canUseTNT( $player, $position ) ){ + return false; } - if( - $b == 199 // item frame - || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) // no farm event - || $i == 259 // apart for fire flag - //.. canBurn( $player->getPosition() ) - ){ + + // fire flag + if( $i == 259 && $b != 46 && !$this->canBurn( $position ) ){ + return false; + } + + // edit / + $o = true; + // 199 itemframe, dirt & grass + items for farm events + if( $b == 199 || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) ){ if(!$this->canEdit($player, $block)){ $o = false; } @@ -1824,7 +1887,14 @@ public function checkPlayerFlying(Player $player){ public function canEntitySpawn( Entity $e ): bool{ $o = true; - if( $e instanceof FallingBlock || $e instanceof FallingSand || $e instanceof PrimedTNT || $e instanceof ExperienceOrb || $e instanceof ItemEntity || $e instanceof Projectile || $e instanceof FloatingTextParticle){ + if( // what entities are always allowed + $e instanceof FallingBlock // FallingBlock (Sand,Gravel, Water, Lava? )// $e instanceof FallingSand + || $e instanceof PrimedTNT + || $e instanceof ExperienceOrb + || $e instanceof ItemEntity + || $e instanceof Projectile + || $e instanceof FloatingTextParticle + ){ return $o; // might be allowed to spawn under different flag } @@ -1837,7 +1907,6 @@ public function canEntitySpawn( Entity $e ): bool{ $pos = $e->getPosition(); } - if($pos && $nm != ''){ $animals =[ 'bat','chicken','cow','horse','llama','donkey','mule','ocelot','parrot','fish','dolphin','squit','pig','rabbit','sheep','pufferfish','salmon','turtle','tropical_fish','cod','balloon']; @@ -1960,7 +2029,7 @@ public function canDrop(Player $player, Position $position) : bool{ * @param pocketmine\level\Position $pos * @param pocketmine\level\Level $level * @return bool - + */ public function canBurn( Position $pos ): bool{ $o = true; $e = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Fire"] : $this->fire); @@ -1980,7 +2049,7 @@ public function canBurn( Position $pos ): bool{ } return $o; } - */ + /** * canExplode() @@ -1990,18 +2059,19 @@ public function canBurn( Position $pos ): bool{ * @return bool */ public function canExplode( Position $pos ): bool{ + $o = true; - $e = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["TNT"] : $this->tnt); + $e = (isset($this->levels[$pos->getLevel()->getName()]) ? $this->levels[$pos->getLevel()->getName()]["Explode"] : $this->explode); if ($e) { $o = false; } // including entities/mobs in any area foreach ($this->areas as $area) { if ($area->contains(new Vector3($pos->getX(), $pos->getY(), $pos->getZ()), $pos->getLevel()->getName() )) { - if ($area->getFlag("tnt")) { + if ($area->getFlag("explode")) { $o = false; } - if(!$area->getFlag("tnt") && $e){ + if(!$area->getFlag("explode") && $e){ $o = true; } } @@ -2015,7 +2085,7 @@ public function canExplode( Position $pos ): bool{ * @param Player $player * @param Position $position * @return bool - + */ public function canUseTNT(Player $player, Position $position) : bool{ if($player->hasPermission("festival") || $player->hasPermission("festival.access")){ return true; @@ -2029,6 +2099,9 @@ public function canUseTNT(Player $player, Position $position) : bool{ foreach($this->inArea[$playername] as $areaname){ if( isset($this->areaList[ $areaname ]) ){ $area = $this->areaList[$areaname]; + + //if( $area->contains( $position, $position->getLevel()->getName() ) ){} + if($area->getFlag("tnt")){ $o = false; } @@ -2042,7 +2115,35 @@ public function canUseTNT(Player $player, Position $position) : bool{ } return $o; } + + /** canTNTExplode() + * Checks if TNT is allowed to be used by player on given position + * @param flag $this->tnt + * @param Player $player + * @param Position $position + * @return bool */ + public function canTNTExplode( Position $position ) : bool{ + + $o = true; + $e = (isset($this->levels[$position->getLevel()->getName()]) ? $this->levels[$position->getLevel()->getName()]["TNT"] : $this->tnt); + if ($e) { + $o = false; + } + // look for any area + foreach ($this->areas as $area) { + if ($area->contains(new Vector3($position->getX(), $position->getY(), $position->getZ()), $position->getLevel()->getName() )) { + if ($area->getFlag("tnt")) { + $o = false; + } + if(!$area->getFlag("tnt") && $e){ + $o = true; + } + } + } + return $o; + } + /** canShoot * @param Player $player From 4458b36c651377306b8f5a4ed8f3981a9b35838c Mon Sep 17 00:00:00 2001 From: genboy Date: Fri, 26 Oct 2018 01:25:58 +0200 Subject: [PATCH 63/68] Added (fire) bucket Fire flag no lava --- src/genboy/Festival/Main.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 6a4bbbb..b6444ce 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1366,6 +1366,7 @@ public function onBlockPlace(BlockPlaceEvent $event) : void{ //$player->sendMessage("TNT not allowed here"); } } + if(!$this->canEdit($player, $block)){ $event->setCancelled(); } @@ -1419,12 +1420,11 @@ public function onInteract( PlayerInteractEvent $event ): void{ } } - /** onBlockUpdate * BlockUpdateEvent * @param BlockUpdateEvent $event * @return void - + */ public function onBlockUpdate( BlockUpdateEvent $event ): void{ $block = $event->getBlock(); @@ -1434,14 +1434,14 @@ public function onBlockUpdate( BlockUpdateEvent $event ): void{ $f = true; if( $this->getServer()->getLevelByName( $levelname )->getBlockIdAt($block->x, $block->y + 1, $block->z) == 51 ){ // is fire above if( !$this->canBurn( $position ) ){ // is fire not allowed? // Block::FIRE - $this->getServer()->getLevelByName( $levelname )->setBlockIdAt( $block->x, $block->y + 1, $block->z, 0); + $this->getServer()->getLevelByName( $levelname )->setBlockIdAt( $block->x, $block->y + 1, $block->z, 0); + $msg = TextFormat::RED . "Fire removed from " . $block->getName() . "(". $block->getID() . ") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"; + $this->getLogger()->info( $msg ); } + } - $msg = TextFormat::RED . "Updated " . $block->getName() . "(". $block->getID() . ") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"; - $this->getLogger()->info( $msg ); } - */ /** onHurt * @param EntityDamageEvent $event @@ -1649,10 +1649,15 @@ public function canInteract( PlayerInteractEvent $event ): bool{ } // fire flag - if( $i == 259 && $b != 46 && !$this->canBurn( $position ) ){ + if( $i == 259 && $b != 46 && !$this->canBurn( $position ) ){ // FLINT_AND_STEEL + not tnt return false; } + if( $i == 325 && !$this->canBurn( $position ) ){ // Flowing Lava flowing_lava 10, Lava lava 11 set by Lava Bucket 325 + return false; + } + + // edit / $o = true; // 199 itemframe, dirt & grass + items for farm events From 217166bd777422dc99ec246a7ccbdb1c9826c9bf Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 27 Oct 2018 23:34:18 +0200 Subject: [PATCH 64/68] Lava in fire flag onBlockupdate --- src/genboy/Festival/Main.php | 54 +++++++++++++----------------------- 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index b6444ce..62f73ae 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -66,6 +66,7 @@ use pocketmine\event\player\PlayerCommandPreprocessEvent; use pocketmine\event\player\PlayerExhaustEvent; use pocketmine\event\player\PlayerDropItemEvent; +use pocketmine\event\player\PlayerBucketEvent; use pocketmine\event\player\PlayerQuitEvent; class Main extends PluginBase implements Listener{ @@ -116,7 +117,7 @@ class Main extends PluginBase implements Listener{ /** @var bool */ private $falldamage = false; /** @var bool */ - private $cmdmode = false; + private $cmdmode = false; /** @var bool[] */ private $selectingFirst = []; @@ -295,7 +296,7 @@ public function onEnable() : void{ $flags["Passage"] = $flags["Barrier"]; // replaced in v1.0.5-11 unset($flags["Barrier"]); } - if( !isset($flags["Passage"]) ){ + if( !isset($flags["Passage"]) ){ // changed in v1.0.3-11 $flags["Passage"] = $this->passage; } if( !isset($flags["Perms"]) ){ // new v1.0.4-11 @@ -1430,18 +1431,27 @@ public function onBlockUpdate( BlockUpdateEvent $event ): void{ $block = $event->getBlock(); $position = new Position($block->getFloorX(), $block->getFloorY(), $block->getFloorZ(), $block->getLevel()); $levelname = $block->getLevel()->getName(); - // fire + + // kill fire - or lava - flowing_lava 10, lava 11 , Bucket item id 325 $f = true; - if( $this->getServer()->getLevelByName( $levelname )->getBlockIdAt($block->x, $block->y + 1, $block->z) == 51 ){ // is fire above + $aid = $this->getServer()->getLevelByName( $levelname )->getBlockIdAt($block->x, $block->y + 1, $block->z); + if( $aid == 51 || $aid == 10 || $aid == 11 ){ // is fire/lava above if( !$this->canBurn( $position ) ){ // is fire not allowed? // Block::FIRE $this->getServer()->getLevelByName( $levelname )->setBlockIdAt( $block->x, $block->y + 1, $block->z, 0); $msg = TextFormat::RED . "Fire removed from " . $block->getName() . "(". $block->getID() . ") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"; $this->getLogger()->info( $msg ); } - } - } + /* + public function onPlayerBucketEvent( PlayerBucketEvent $event): void{ + $block = $event->getBlockClicked(); + $position = new Position($block->getFloorX(), $block->getFloorY(), $block->getFloorZ(), $block->getLevel()); + if( ($event->getItem()->getId() == 10 || $event->getItem()->getId() == 11) && !$this->canBurn( $position ) ){ + $event->setCancelled(); + $this->getLogger()->info( 'No lava bucket allowed!' ); + } + }*/ /** onHurt * @param EntityDamageEvent $event @@ -1648,23 +1658,15 @@ public function canInteract( PlayerInteractEvent $event ): bool{ return false; } - // fire flag + // fire flag - see also onBlockUpdate if( $i == 259 && $b != 46 && !$this->canBurn( $position ) ){ // FLINT_AND_STEEL + not tnt return false; } - if( $i == 325 && !$this->canBurn( $position ) ){ // Flowing Lava flowing_lava 10, Lava lava 11 set by Lava Bucket 325 - return false; - } - - - // edit / + // edit flag for items - 199 itemframe, dirt & grass + items for farm events $o = true; - // 199 itemframe, dirt & grass + items for farm events - if( $b == 199 || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) ){ - if(!$this->canEdit($player, $block)){ - $o = false; - } + if( ( $b == 199 || ( ( $b == 2 || $b == 3) && ( $i == 290 || $i == 291 || $i == 292 || $i == 293 || $i == 294 ) ) ) && !$this->canEdit($player, $block) ){ + $o = false; } return $o; @@ -1731,22 +1733,6 @@ public function hasFallDamage(Entity $entity) : bool{ return $o; } - /* - public function onFallDisable(EntityDamageEvent $event) : void{ - $player = $event->getEntity(); - $level = $player->getLevel()->getFolderName(); - $cause = $event->getCause(); - if($event->getEntity() instanceof Player){ - if(!$this->canGetHurt($player)){ - $event->setCancelled(); - } - if($cause == EntityDamageEvent::CAUSE_FALL && $this->hasFallDamage($player)){ - $event->setCancelled(true); - } - } - } - */ - /** PVP * @param Event $ev * @return bool From 674d67efc10c2e06b363c70dce01919da7690403 Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 10 Nov 2018 22:45:25 +0100 Subject: [PATCH 65/68] fire flag extinguishing players and blocks (onblockupdate) +info update --- README.md | 16 ++++++++++------ src/genboy/Festival/Main.php | 11 ++++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d07a604..2f477d5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## Festival -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!_ +If you like Festival please share your experience to help Festival plugin improve, thank you! ![Festival plugin logo large](https://genboy.net/wp-content/uploads/2018/02/festival_plugin_logo.png) @@ -30,7 +30,9 @@ Create a festival with this custom area events plugin for Pocketmine Server: More info also available at [the Festival Wiki](https://github.com/genboy/Festival/wiki) -!Please before asking first double-check your server basic world configurations, other plugins configurations (ie. worldguard) and the used player permissions incl. Festival whitelistings. +Download the latest .phar files from [poggit.pmmp.io](https://poggit.pmmp.io/p/Festival/1.0.7), also available at [mcpehost.ru](https://panel.mcpehost.ru/repository/plugin?name=Festival) + +!Please before asking; first double-check your server basic world configurations, other plugins configurations (ie. worldguard) and the used player permissions incl. Festival whitelistings. #### Features @@ -67,16 +69,18 @@ More info also available at [the Festival Wiki](https://github.com/genboy/Festiv - touch: area is save from player interaction with doors/chests/signs etc. - animals: no animal spawning (including spawners & eggs) - mobs: no mobs spawning (including spawners & eggs) - - effects: player can not keep using effects in the area + - 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) - drop: players can not drop things - tnt: explosions protected area + - fire: fire protected area (including spreading & lava) + - explode: explosions protected area - shoot: player can not shoot (bow) - - perms: player permissions are used to determine area command execution (experiment) + - perms: player permissions are used to determine area command execution - hunger: player does not exhaust / hunger - falldamage: player will not have fall damage (no fall damage) - - cmdmode: area event commands are only executed for ops (for testing commands) + - cmdmode: area event commands are only executed for ops (test area commands) **Events & Commands** @@ -145,7 +149,7 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). ###### Copyright [Genboy](https://genboy.net) 2018 - + #### Language Set Festival language en/nl for area and command returned messages. diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 62f73ae..e880cb6 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -1426,7 +1426,7 @@ public function onInteract( PlayerInteractEvent $event ): void{ * @param BlockUpdateEvent $event * @return void */ - public function onBlockUpdate( BlockUpdateEvent $event ): void{ + public function onBlockUpdate( BlockUpdateEvent $event ): void{ // BlockUpdateEvent $block = $event->getBlock(); $position = new Position($block->getFloorX(), $block->getFloorY(), $block->getFloorZ(), $block->getLevel()); @@ -1435,14 +1435,15 @@ public function onBlockUpdate( BlockUpdateEvent $event ): void{ // kill fire - or lava - flowing_lava 10, lava 11 , Bucket item id 325 $f = true; $aid = $this->getServer()->getLevelByName( $levelname )->getBlockIdAt($block->x, $block->y + 1, $block->z); - if( $aid == 51 || $aid == 10 || $aid == 11 ){ // is fire/lava above + if( $aid == 51 || $aid == 10 || $aid == 11 ){ // is fire/lava above if( !$this->canBurn( $position ) ){ // is fire not allowed? // Block::FIRE $this->getServer()->getLevelByName( $levelname )->setBlockIdAt( $block->x, $block->y + 1, $block->z, 0); - $msg = TextFormat::RED . "Fire removed from " . $block->getName() . "(". $block->getID() . ") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"; - $this->getLogger()->info( $msg ); + //$msg = TextFormat::RED . "Fire removed from " . $block->getName() . "(". $block->getID() . ") at [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]"; + //$this->getLogger()->info( $msg ); } } } + /* public function onPlayerBucketEvent( PlayerBucketEvent $event): void{ $block = $event->getBlockClicked(); @@ -1787,7 +1788,7 @@ public function canDamage(EntityDamageEvent $ev) : bool{ if($ev->getEntity() instanceof Player){ $player = $ev->getEntity(); $playerName = strtolower($player->getName()); - if(!$this->canGetHurt($player)){ + if( !$this->canGetHurt( $player ) || !$this->canBurn( $player->getPosition() )){ if( $player->isOnFire() ){ $player->extinguish(); // 1.0.7-dev } From 831ae504f08f27e315e25286385544e68520feaa Mon Sep 17 00:00:00 2001 From: genboy Date: Sat, 10 Nov 2018 22:57:44 +0100 Subject: [PATCH 66/68] Update info & version --- README.md | 10 +++++----- plugin.yml | 4 ++-- resources/config.yml | 24 +++++++++++++++++++++--- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d07a604..b619efd 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ 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. @@ -189,7 +189,7 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). The basic command to control area flags: - /fe flag(f) + /fe flag(f) Area flag listing @@ -405,10 +405,10 @@ Thank you **Since v1.0.7.9** - /fe lang - set Festival language - Edit flag includes No Farmland creation - - Edit flag includes No Fire from Flint & Steel - - Edit flag includes No TNT placing - - Edit flag includes No TNT ignition with Flint & Steel - Edit flag includes protect item in frame use + - !Fire flag includes No Fire from Flint & Steel and No lava + - !TNT flag includes No TNT placing or tnt explosions + - !Explode flag includes No entity explosions - Areas floating title - Add translation options (en/nl/..) - Spawning: Prevent mob/animal spawning (and spawners/eggs) in area's diff --git a/plugin.yml b/plugin.yml index 0ad4b80..54f07ed 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: Festival author: Genboy -version: 1.0.7.9-dev +version: 1.0.8-dev main: genboy\Festival\Main load: POSTWORLD api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0,4.0.0] @@ -8,7 +8,7 @@ website: "https://github.com/genboy/Festival" commands: fe: description: "Allows you to manage Festival area's and events." - usage: "\n§bChoose language: §f/fe lang §bToggle floating area titles: §f/fe titles §bSee area info at location: §f/fe \n§5How to create an area: §6select 2 corner positions §f/fe §6, then name the area by using: §f/fe create \n§9Toggle area flags: §f/fe §9Flags: §fgod, pvp, flight, edit, touch, mobs, animals, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage \n§5Add an area event command: \n§f/fe command \n§5Edit or delete command: \n§f/fe command <(edit)/del> () \n§5Change command event: \n§f/fe command event \n§5Whitelist players: \n§f/fe whitelist " + usage: "\n§bChoose language: §f/fe lang §bToggle floating area titles: §f/fe titles §bSee area info at location: §f/fe \n§5How to create an area: §6select 2 corner positions §f/fe §6, then name the area by using: §f/fe create \n§9Toggle area flags: §f/fe §9Flags: §fgod, pvp, flight, edit, touch, mobs, animals, effects, msg, passage, drop, tnt, fire, explode, shoot, hunger, perms, falldamage \n§5Add an area event command: \n§f/fe command \n§5Edit or delete command: \n§f/fe command <(edit)/del> () \n§5Change command event: \n§f/fe command event \n§5Whitelist players: \n§f/fe whitelist " permission: festival.command.fe permissions: festival: diff --git a/resources/config.yml b/resources/config.yml index 2dd7fde..802631b 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -55,9 +55,15 @@ Default: # Keep players from dropping items in the area? (true = NoDropping) Drop: false - # No explosions allowed in the area? (true = NoExplosions) + # No tnt placement or explosions allowed in the area? (true = NoTNT) TNT: false + # No Fire allowed in the area? (true = NoFire) + Fire: false + + # No entity explosions allowed in the area? (true = NoExplosions) + Explode: false + # No shooting allowed in the area? (true = NoShooting) Shoot: false @@ -112,9 +118,15 @@ Worlds: # Keep players from dropping items in the area? (true = NoDropping) Drop: false - # No explosions allowed in the area? (true = NoExplosions) + # No tnt placement or explosions allowed in the area? (true = NoTNT) TNT: false + # No Fire allowed in the area? (true = NoFire) + Fire: false + + # No entity explosions allowed in the area? (true = NoExplosions) + Explode: false + # No shooting allowed in the area? (true = NoShooting) Shoot: false @@ -166,9 +178,15 @@ Worlds: # Keep players from dropping items in the area? (true = NoDropping) Drop: false - # No explosions allowed in the area? (true = NoExplosions) + # No tnt placement or explosions allowed in the area? (true = NoTNT) TNT: false + # No Fire allowed in the area? (true = NoFire) + Fire: false + + # No entity explosions allowed in the area? (true = NoExplosions) + Explode: false + # No shooting allowed in the area? (true = NoShooting) Shoot: false From 749396a6c87ac949dc287cae24aa738dcf3d8f0b Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 11 Nov 2018 19:07:26 +0100 Subject: [PATCH 67/68] Info & usage image v1.0.8(dev2) --- README.md | 16 ++++++++-------- plugin.yml | 4 ++-- resources/config.yml | 6 +++--- src/genboy/Festival/Main.php | 8 ++++++++ 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c88b019..b774632 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ 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/10/festival_usage_1.0.7.9-dev.png) +![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/11/festival_usage_1.0.8.png) ###### Copyright [Genboy](https://genboy.net) 2018 @@ -30,7 +30,7 @@ Create a festival with this custom area events plugin for Pocketmine Server: More info also available at [the Festival Wiki](https://github.com/genboy/Festival/wiki) -Download the latest .phar files from [poggit.pmmp.io](https://poggit.pmmp.io/p/Festival/1.0.7), also available at [mcpehost.ru](https://panel.mcpehost.ru/repository/plugin?name=Festival) +Download the latest .phar files from [poggit.pmmp.io](https://poggit.pmmp.io/p/Festival/1.0.8), also available at [mcpehost.ru](https://panel.mcpehost.ru/repository/plugin?name=Festival) !Please before asking; first double-check your server basic world configurations, other plugins configurations (ie. worldguard) and the used player permissions incl. Festival whitelistings. @@ -144,7 +144,7 @@ and all [other iProtector devs](https://github.com/LDX-MCPE/iProtector/network). ##### A visualisation of Festival command usage - ![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/10/festival_usage_1.0.7.9-dev.png) + ![Festival creation & usage](https://genboy.net/wp-content/uploads/2018/11/festival_usage_1.0.8.png) ###### Copyright [Genboy](https://genboy.net) 2018 @@ -406,20 +406,20 @@ Thank you - new animals and mobs (spawning) flag - Fixes itemframe and farmland edit - **Since v1.0.7.9** + **Since v1.0.8** - /fe lang - set Festival language - Edit flag includes No Farmland creation - Edit flag includes protect item in frame use - - !Fire flag includes No Fire from Flint & Steel and No lava - - !TNT flag includes No TNT placing or tnt explosions - - !Explode flag includes No entity explosions + - !NEW Fire flag includes No Fire from Flint & Steel and No lava + - !NEW TNT flag includes No TNT placing or tnt explosions + - !NEW Explode flag includes No entity explosions - Areas floating title - Add translation options (en/nl/..) - Spawning: Prevent mob/animal spawning (and spawners/eggs) in area's - Mobs flag prevent mobs from spawning in area - Animals flag prevent animals from spawning in area - Area messages display in chat with config option Msgtype 'msg' - - cmd flag: area event commands for ops or whitelisted players only + - cmd flag: area event commands for ops or whitelisted players only ------ diff --git a/plugin.yml b/plugin.yml index 54f07ed..3f3daf9 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,9 +1,9 @@ name: Festival author: Genboy -version: 1.0.8-dev +version: 1.0.8-dev2 main: genboy\Festival\Main load: POSTWORLD -api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0,4.0.0] +api: [3.0.0-ALPHA10,3.0.0-ALPHA11,3.0.0-ALPHA12,3.0.0] website: "https://github.com/genboy/Festival" commands: fe: diff --git a/resources/config.yml b/resources/config.yml index 802631b..842419a 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -55,7 +55,7 @@ Default: # Keep players from dropping items in the area? (true = NoDropping) Drop: false - # No tnt placement or explosions allowed in the area? (true = NoTNT) + # No tnt explosions allowed in the area? (true = NoTNT) TNT: false # No Fire allowed in the area? (true = NoFire) @@ -118,7 +118,7 @@ Worlds: # Keep players from dropping items in the area? (true = NoDropping) Drop: false - # No tnt placement or explosions allowed in the area? (true = NoTNT) + # No tnt explosions allowed in the area? (true = NoTNT) TNT: false # No Fire allowed in the area? (true = NoFire) @@ -178,7 +178,7 @@ Worlds: # Keep players from dropping items in the area? (true = NoDropping) Drop: false - # No tnt placement or explosions allowed in the area? (true = NoTNT) + # No tnt explosions allowed in the area? (true = NoTNT) TNT: false # No Fire allowed in the area? (true = NoFire) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index e880cb6..0890849 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -246,12 +246,18 @@ public function onEnable() : void{ } if(!isset($c["Default"]["Explode"])) { // new in v1.0.7.9 $c["Default"]["Explode"] = false; + if( isset($c["Default"]["TNT"]) ){ + $c["Default"]["Explode"] = true; + } } if(!isset($c["Default"]["TNT"])) { // new in v1.0.7.3 $c["Default"]["TNT"] = false; } if(!isset($c["Default"]["Fire"])) { // new in v1.0.7.9 $c["Default"]["Fire"] = false; + if( isset($c["Default"]["TNT"]) ){ + $c["Default"]["Fire"] = true; + } } if(!isset($c["Default"]["Shoot"])) { // new in v1.0.7 $c["Default"]["Shoot"] = false; @@ -678,7 +684,9 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar "msg" => $flags['Msg'], "passage" => $flags['Passage'], "drop" => $flags['Drop'], + "explode" => $flags['Explode'], "tnt" => $flags['TNT'], + "fire" => $flags['Fire'], "shoot" => $flags['Shoot'], "hunger" => $flags['Hunger'], "perms" => $flags['Perms'], From 002b54e2523878704a4eb545579e8dab5c4cfaee Mon Sep 17 00:00:00 2001 From: genboy Date: Sun, 11 Nov 2018 19:39:44 +0100 Subject: [PATCH 68/68] Release ready --- src/genboy/Festival/Main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/genboy/Festival/Main.php b/src/genboy/Festival/Main.php index 0890849..c54ff85 100644 --- a/src/genboy/Festival/Main.php +++ b/src/genboy/Festival/Main.php @@ -18,7 +18,7 @@ * * Options in config.yml * language: en/nl, Msgtype: msg/title/tip/pop, Areadisplay: off/op/on, Msgdisplay: off/op/on - * Flags: god, pvp, flight, edit, touch, mobs, animals, effects, msg, passage, drop, tnt, shoot, hunger, perms, falldamage, cmdmode + * Flags: god, pvp, flight, edit, touch, mobs, animals, effects, msg, passage, drop, tnt, fire, explode, shoot, hunger, perms, falldamage, cmdmode * */