hey , so am making a plugin that involves PlayerMoveEvent , it works prefectly just that when the player moves with a helmet on called "Diamond Helmet \nGills I \nFeed I" it doesn't work but yet with the "Diamond Helmet \nGills I" it works . PHP: public function onHelmet(Player $player){ $helmet = $player->getInventory()->getHelmet(); // Getting Helmet $id = $helmet->getId(); // Helmets ID $name = $helmet->getCustomName(); // Helmets Name // Helmet with Feed I and Gills I if($id === 310 and $name === "§r§f§bDiamond Helmet \n§7Feed I \n§7Gills I"){ $player->addEffect(Effect::getEffect(13)->setDuration(9999 * 20)->setAmplifier(1)); $player->addEffect(Effect::getEffect(23)->setDuration(9999 * 20)->setAmplifier(1)); } else { $player->removeEffect(Effect::SATURATION); $player->removeEffect(Effect::WATER_BREATHING); } //Helmet with Gills I and Feed I if($id === 310 and $name === "§r§f§bDiamond Helmet \n§7Gills I \n§7Feed I"){ $player->addEffect(Effect::getEffect(13)->setDuration(9999 * 20)->setAmplifier(1)); $player->addEffect(Effect::getEffect(23)->setDuration(9999 * 20)->setAmplifier(1)); } else { $player->removeEffect(Effect::SATURATION); $player->removeEffect(Effect::WATER_BREATHING); } }
Hacky way to do that using names. Why use on move event? PHP: public function onArmorEquipt(EntityArmorChangeEvent $e){//CustomEnchantment armor effect $i = $e->getNewItem();//armor put on $o = $e->getOldItem();//armor taken off $p = $e->getEntity();//player //do whatver with the items, use nbt tags :D}
heres my code with your method PHP: public function onArmorEquipt(EntityArmorChangeEvent $e){//CustomEnchantment armor effect $i = $e->getNewItem()->getCustomName();//armor put on $o = $e->getOldItem();//armor taken off $player = $e->getEntity();//player //do whatver with the items, use nbt tags :D // Helmet with Feed I and Gills I if($i === "§r§f§bDiamond Helmet \n§7Feed I \n§7Gills I"){ $player->addEffect(Effect::getEffect(13)->setDuration(9999 * 20)->setAmplifier(1)); $player->addEffect(Effect::getEffect(23)->setDuration(9999 * 20)->setAmplifier(1)); } else { $player->removeEffect(Effect::SATURATION); $player->removeEffect(Effect::WATER_BREATHING); } //Helmet with Gills I and Feed I if($i === "§r§f§bDiamond Helmet \n§7Gills I \n§7Feed I"){ $player->addEffect(Effect::getEffect(13)->setDuration(9999 * 20)->setAmplifier(1)); $player->addEffect(Effect::getEffect(23)->setDuration(9999 * 20)->setAmplifier(1)); } else { $player->removeEffect(Effect::SATURATION); $player->removeEffect(Effect::WATER_BREATHING); } // Helmet with Gills I if($i === "§r§f§bDiamond Helmet \n§7Gills I"){ $player->addEffect(Effect::getEffect(13)->setDuration(9999 * 20)->setAmplifier(1)); } else { $player->removeEffect(Effect::WATER_BREATHING); } // Helmet with Feed I if($i === "§r§f§bDiamond Helmet \n§7Feed I"){ $player->addEffect(Effect::getEffect(23)->setDuration(9999 * 20)->setAmplifier(1)); } else { $player->removeEffect(Effect::SATURATION); } } doesn't work the same thing happens
The formatting of that code was triggering my OCD... PHP: public function onArmorEquipt(EntityArmorChangeEvent $e){ $i = $e->getNewItem()->getCustomName(); //name of new armor $player = $e->getEntity(); if(!$player instanceof Player) { $this->getLogger()->error("not a player?"); } if($i === "§r§f§bDiamond Helmet \n§7Feed I \n§7Gills I") $player->addEffect(Effect::getEffect(Effect::WATER_BREATHING)->setDuration(9999 * 20)->setAmplifier(1)); $player->addEffect(Effect::getEffect(Effect::SATURATION)->setDuration(9999 * 20)->setAmplifier(1)); } else { $player->removeEffect(Effect::SATURATION); $player->removeEffect(Effect::WATER_BREATHING); } if($i === "§r§f§bDiamond Helmet \n§7Gills I \n§7Feed I"){ $player->addEffect(Effect::getEffect(Effect::WATER_BREATHING)->setDuration(9999 * 20)->setAmplifier(1)); $player->addEffect(Effect::getEffect(Effect::SATURATION)->setDuration(9999 * 20)->setAmplifier(1)); } else { $player->removeEffect(Effect::SATURATION); $player->removeEffect(Effect::WATER_BREATHING); } if($i === "§r§f§bDiamond Helmet \n§7Gills I"){ $player->addEffect(Effect::getEffect(Effect::WATER_BREATHING)->setDuration(9999 * 20)->setAmplifier(1)); } else { $player->removeEffect(Effect::WATER_BREATHING); } if($i === "§r§f§bDiamond Helmet \n§7Feed I"){ $player->addEffect(Effect::getEffect(Effect::SATURATION)->setDuration(9999 * 20)->setAmplifier(1)); } else { $player->removeEffect(Effect::SATURATION); }} One possible solution is lowering the duration to ensure that you haven't passed the php maximum integer limit
the idea of verifying items enchantments based on names just make me ask why am i even here the idea of using an AND crazes me even more so if i have a 3 enchantment you would need all possible enhancements order of 3 enchantment + all combinations of using only 2 and 1 which would be a lot (wished i exactly split out the number there) only if you stored it in item NBT you could foreach all the enchantments way easier sorry, this just have to be said...