public function onRun($tick) { $cfg = $this->plugin->getConfig()->getAll(); $this->counter += 1; if ($this->counter >= $cfg["Motd"]["update-timeout"]) { //Check if Motd message is custom if (CustomAlerts::getAPI()->isMotdCustom()) { CustomAlerts::getAPI()->setMotdMessage(CustomAlerts::getAPI()->getDefaultMotdMessage()); } $this->plugin->getServer()->getPluginManager()->callEvent(new CustomAlertsMotdUpdateEvent($this->plugin->getServer()->getMotd())); $this->counter = 0; } }
public function onCAJoinEvent(CustomAlertsJoinEvent $event) { CustomAlerts::getAPI()->setJoinMessage("Example Join Message: " . $event->getPlayer()->getName()); }
/** * @param PlayerDeathEvent $event * * @priority HIGHEST */ public function onPlayerDeath(PlayerDeathEvent $event) { $player = $event->getEntity(); CustomAlerts::getAPI()->setDeathMessage($event->getDeathMessage()); if ($player instanceof Player) { $cause = $player->getLastDamageCause(); if (CustomAlerts::getAPI()->isDeathHidden($cause)) { CustomAlerts::getAPI()->setDeathMessage(""); } else { //Check if Death message is custom if (CustomAlerts::getAPI()->isDeathCustom($cause)) { CustomAlerts::getAPI()->setDeathMessage(CustomAlerts::getAPI()->getDefaultDeathMessage($player, $cause)); } } //Death Event $this->plugin->getServer()->getPluginManager()->callEvent(new CustomAlertsDeathEvent($player, $cause)); $event->setDeathMessage(CustomAlerts::getAPI()->getDeathMessage()); } }
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { $fcmd = strtolower($cmd->getName()); switch ($fcmd) { case "customalerts": if (isset($args[0])) { $args[0] = strtolower($args[0]); if ($args[0] == "help") { if ($sender->hasPermission("customalerts.help")) { $sender->sendMessage($this->plugin->translateColors("&", "&b-- &aAvailable Commands &b--")); $sender->sendMessage($this->plugin->translateColors("&", "&d/calerts help &b-&a Show help about this plugin")); $sender->sendMessage($this->plugin->translateColors("&", "&d/calerts info &b-&a Show info about this plugin")); $sender->sendMessage($this->plugin->translateColors("&", "&d/calerts reload &b-&a Reload the config")); break; } else { $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); break; } } elseif ($args[0] == "info") { if ($sender->hasPermission("customalerts.info")) { $sender->sendMessage($this->plugin->translateColors("&", CustomAlerts::PREFIX . "&aCustomAlerts &dv" . CustomAlerts::VERSION . " &adeveloped by&d " . CustomAlerts::PRODUCER)); $sender->sendMessage($this->plugin->translateColors("&", CustomAlerts::PREFIX . "&aWebsite &d" . CustomAlerts::MAIN_WEBSITE)); break; } else { $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); break; } } elseif ($args[0] == "reload") { if ($sender->hasPermission("customalerts.reload")) { $this->plugin->reloadConfig(); //Reload Motd if (!CustomAlerts::getAPI()->isMotdCustom()) { CustomAlerts::getAPI()->setMotdMessage($this->plugin->getServer()->getMotd()); } $sender->sendMessage($this->plugin->translateColors("&", CustomAlerts::PREFIX . "&aConfiguration Reloaded.")); break; } else { $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); break; } } else { if ($sender->hasPermission("customalerts")) { $sender->sendMessage($this->plugin->translateColors("&", CustomAlerts::PREFIX . "&cSubcommand &a" . $args[0] . " &cnot found. Use &a/calerts help &cto show available commands")); break; } else { $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); break; } } } else { if ($sender->hasPermission("customalerts.help")) { $sender->sendMessage($this->plugin->translateColors("&", "&b-- &aAvailable Commands &b--")); $sender->sendMessage($this->plugin->translateColors("&", "&d/calerts help &b-&a Show help about this plugin")); $sender->sendMessage($this->plugin->translateColors("&", "&d/calerts info &b-&a Show info about this plugin")); $sender->sendMessage($this->plugin->translateColors("&", "&d/calerts reload &b-&a Reload the config")); break; } else { $sender->sendMessage($this->plugin->translateColors("&", "&cYou don't have permissions to use this command")); break; } } } }