Advertisement
Guest User

Untitled

a guest
Dec 7th, 2014
1,116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.47 KB | None | 0 0
  1. K  changelog.yml���T�m�w� config.yml���T�����#nbproject/private/config.properties��T�$nbproject/private/private.properties\��T\��z�nbproject/private/private.xmlP��TP&��nbproject/project.properties���T�V FԶnbproject/project.xml1��T1]Z�H� plugin.yml���T��kMQ� README.md���T���"�src/CTF/main.php�N��T�Ng-�)�src/CTF/timer.php� ��T� E ƶ teams.yml%��T%)02|�\\ CHANGELOG \\ 1.0.0: - Initial Release ----- 1.0.1: - Made it so flag can only be obtained once **until returned** (AntiSpam Precaution) - Added special nametag when flag is captured. It goes from [COLOR] to *COLOR* - Players intentionally blocking the ReturnPoint get teleported to base. - A better and more balanced inventory. ----- 1.0.2: - Bumped up the API to 1.6.0 (Backwards compatible) - Less obtrusive in-game notifications. - More detailed command descriptions. ----- 1.1.0: - Added Team Armors. - Fixed the Damage bug. - Fixed the Config.yml. - Added permissions to commands. - Permissions: - ctfbs: permission: ctf.admin.bs ctfbr: permission: ctf.admin.bs ctfbf: permission: ctf.admin.bf ctfrs: permission: ctf.admin.rs ctfrr: permission: ctf.admin.rr ctfrf: permission: ctf.admin.rf lobbyset: permission: ctf.admin.ls ----- 1.1.1: - Removed /lobbyset command. - A more balanced and cooler inventory! --- Maximum score to win (Integer): 15 Game Length (Mins): 2 MySQL Details: 'host:': null 'port:': "null" 'user:': null 'password:': "null" 'database:': null ... copy.src.on.open=false include.path.private= index.file=index.php url=http://localhost/CTF/ file.reference.adam-GoogleFusionTablesphp=../../../../GoogleFusionTablesphp file.reference.PMDev-src=../../Desktop/PMDev/src file.reference.PMDev-src-1=../../src include.path=\ ${php.global.include.path}:\ ${file.reference.PMDev-src-1}:\ ${file.reference.adam-GoogleFusionTablesphp} php.version=PHP_54 source.encoding=UTF-8 src.dir=. tags.asp=false tags.short=false web.root=. org.netbeans.modules.php.project CTF name: CTF Framework main: CTF\main version: 1.1.1 api: [1.6.0] website: EPICMC.US author: EPICMC Team description: "CTF" commands: bs: description: CTF Set BlueSpawn permission: ctf.admin.bs br: description: CTF Set BlueReturn permission: ctf.admin.br bf: description: CTF Set BlueFlag permission: ctf.admin.bf rs: description: CTF Set RedSpawn permission: ctf.admin.rs rr: description: CTF Set RedReturn permission: ctf.admin.rr rf: description: CTF Set RedFlag permission: ctf.admin.rf edit: description: CTF Enable Terrain Edit **OUTDATED: Version 1.2.0 will be released soon, and it will support the new API and be more stable!** **Objective**: Capture the flag is a neat minigame where each team has to try to capture the other team's flag and return it to their base. SpawnPoints | ReturnPoints | Flags | ------------- | ------------- | -------------| /bs - **BlueSpawn** | /br - **BlueReturn** | /bf - **BlueFlag** /rs - **RedSpawn** | /rr - **RedReturn** | /rf - **RedFlag** **SpawnPoints**: This is where the team spawns when they first join or after dying in battle. Also, the ReturnPoint is usually located somewhere near this area. *To use this command you stand where you want the area to be and then use one of the designated commands in the above chart.* **ReturnPoints**: After stealing a flag from an opposing team you want to return it to this area to score a point. Also, the SpawnPoint is usually located somewhere near this area. *To use this command you stand where you want the area to be and then use one of the designated commands in the above chart.* **Flags**: Your entire objective is to capture your opponent's flag. The flag is a wool block on the opponents side of the map. You must break it and book it back to your base and put it in your ReturnPoint. *Use one of the corresponding flag commands above and then place the flag wherever you want it to go.* Here is a preview of our CTF plugin in action. The video is showcasing our initial plugin, and a lot has improved since then but you'll still get a general idea of how it works. https://www.youtube.com/watch?v=zTqM00DFd14 *Also, if you think you could make a better showcase video contact us on Twitter @EPICMC_US!* getServer()->getPluginManager()->registerEvents($this, $this); @mkdir($this->getDataFolder()); $this->config = (new Config($this->getDataFolder()."config.yml", Config::YAML, array( "Maximum score to win (Integer)" => "15", "Game Length (Mins)" => "20", "message" => "0" )))->getAll(); //$this->saveDefaultConfig(); //$this->reloadConfig(); $this->getLogger()->info(TextFormat::DARK_PURPLE . "CTF ENABLED!"); //$this->getConfig()->setDefaults(array("Maximum score to win (Integer)" => 15, "Game Length (Mins)" => 20)); $this->getServer()->getScheduler()->scheduleRepeatingTask(new timer($this), 1200); } public function onCommand(CommandSender $sender, Command $command, $label, array $args) { //if ($sender->isOp()) { switch($command->getName()) { case "bs": if($sender->hasPermission("ctf.admin.bs")){ $this->writeConfigCoords($sender, "CTF Set BlueSpawn"); $sender->sendMessage("This is where the blue team will spawn."); } else { $sender->sendMessage("You cannot use this command!"); } break; case "bf": if($sender->hasPermission("ctf.admin.bf")){ $this->temp[$sender->getName()]["BlueFlag"] = true; $sender->sendMessage("Place a block in the desired spot for the flag"); } else { $sender->sendMessage("You cannot use this command!"); } break; case "br": if($sender->hasPermission("ctf.admin.br")){ $this->writeConfigCoords($sender, "CTF Set BlueReturn"); $sender->sendMessage("This is where the blue team will return."); } else { $sender->sendMessage("You cannot use this command!"); } break; case "rs": if($sender->hasPermission("ctf.admin.rs")){ $this->writeConfigCoords($sender, "CTF Set RedSpawn"); $sender->sendMessage("This is where the red team will spawn."); } else { $sender->sendMessage("You cannot use this command!"); } break; case "rf": if($sender->hasPermission("ctf.admin.rf")){ $this->temp[$sender->getName()]["RedFlag"] = true; $sender->sendMessage("Place a block in the desired spot for the flag"); } else { $sender->sendMessage("You cannot use this command!"); } break; case "rr": if($sender->hasPermission("ctf.admin.rr")){ $this->writeConfigCoords($sender, "CTF Set RedReturn"); $sender->sendMessage("This is where the red team will return."); } else { $sender->sendMessage("You cannot use this command!"); } break; case "edit": if ($sender->isOp()) { if (!isset($this->editors[$sender->getName()])) { $this->editors[$sender->getName()] = true; $sender->sendMessage("You are now allowed to edit!"); } else { unset($this->editors[$sender->getName()]); $sender->sendMessage("You are not allowed to edit!"); } } else { $sender->sendMessage("You need to be OP to do this."); } break; } //} } public function onBlockBreak(BlockBreakEvent $event) { $player = $event->getPlayer(); $x = (Int)$event->getBlock()->getX(); $y = (Int)$event->getBlock()->getY(); $z = (Int)$event->getBlock()->getZ(); $level = $event->getBlock()->getLevel()->getName(); $blue = $this->getConfig()->get("BlueFlag"); $red = $this->getConfig()->get("RedFlag"); if (isset($this->editors[$player->getName()])) { $event->setCancelled(false); } else if ($x == $blue["x"] and $y == $blue["y"] and $z == $blue["z"] and $level = $blue["level"]) { if (array_key_exists($player->getName(), $this->temp["RedPlayers"])) { // player is on red team $event->setCancelled(); $item = new Item(35, 11, 1); $player->getInventory()->addItem($item); if (isset($this->temp[$player->getName()])) { $player->sendMessage("You can only place the flag once."); } else { $this->getServer()->broadcastMessage("Player:" . $player->getDisplayName() . " captured the BLUE team's flag!"); $this->temp[$player->getName()] = true; $player->setNameTag("*RED* " . $player->getName()); } } else { $event->setCancelled(); } } else if ($x == $red["x"] and $y == $red["y"] and $z == $red["z"] and $level == $red["level"]) { if (array_key_exists($player->getName(), $this->temp["BluePlayers"])) { // player is on blue team $event->setCancelled(); $item = new Item(35,14, 1); $player->getInventory()->addItem($item); if (isset($this->temp[$player->getName()])) { $player->sendMessage("You can only place the flag once."); } else { $this->getServer()->broadcastMessage("Player:" . $player->getDisplayName() . " captured the RED team's flag!"); $this->temp[$player->getName()] = true; $player->setNameTag("*BLUE* " . $player->getName()); } } else { $event->setCancelled(); } } else { $event->setCancelled(); } } public function onBlockPlace (BlockPlaceEvent $event) { $player = $event->getPlayer(); $x = (Int)$event->getBlock()->getX(); $y = (Int)$event->getBlock()->getY(); $z = (Int)$event->getBlock()->getZ(); $block = $event->getBlock()->getID(); $level = $event->getBlock()->getLevel()->getName(); if (isset($this->editors[$player->getName()])) { $event->setCancelled(false); } else if (isset($this->temp[$player->getName()]["RedFlag"])) { $coordarray = array("x" => $x, "y" => $y, "z" => $z, "level" => $level); $this->getConfig()->set("RedFlag", $coordarray); $player->sendMessage("RedFlag set!"); unset($this->temp[$player->getName()]); } else if (isset($this->temp[$player->getName()]["BlueFlag"])) { $coordarray = array("x" => $x, "y" => $y, "z" => $z, "level" => $level); $this->getConfig()->set("BlueFlag", $coordarray); $player->sendMessage("BlueFlag set!"); unset($this->temp[$player->getName()]); } else { if (isset($this->temp["RedPlayers"]) or isset($this->temp["BluePlayers"])) { // IDK why I made this function if(is_array($this->temp["RedPlayers"]) && array_key_exists($player->getName(), $this->temp["RedPlayers"])) { //Player is on the red team $config = $this->getConfig()->get("RedReturn"); if($x == $config["x"] and $y == $config["y"] and $z == $config["z"] and $level == $config["level"] and $block == 35) { if (isset($this->temp["RedPoints"])) { $points = $this->temp["RedPoints"] +1; $this->temp["RedPoints"] = $points; $event->setCancelled(); } else { $this->temp["RedPoints"] = 1; } $event->setCancelled(); $this->giveRedTeamItems($player->getName()); $this->broadcastScore($player); if (isset($this->temp[$player->getName()])) { unset($this->temp[$player->getName()]); $player->setNameTag("[RED] " . $player->getName()); } } } if(is_array($this->temp["BluePlayers"]) && array_key_exists($player->getName(), $this->temp["BluePlayers"])) { //Player is on the blue team $config = $this->getConfig()->get("BlueReturn"); if($x == $config["x"] and $y == $config["y"] and $z == $config["z"] and $level == $config["level"] and $block == 35) { if (isset($this->temp["BluePoints"])) { $points = $this->temp["BluePoints"] +1; $this->temp["BluePoints"] = $points; $event->setCancelled(); } else { $this->temp["BluePoints"] = 1; } $event->setCancelled(); $this->giveBlueTeamItems($player->getName()); $this->broadcastScore($player); if (isset($this->temp[$player->getName()])) { unset($this->temp[$player->getName()]); $player->setNameTag("[BLUE] " . $player->getName()); } } } } $event->setCancelled(); } } public function onPlayerJoin (PlayerJoinEvent $event) { $player = $event->getPlayer(); $this->assignPlayer($player); //$this->giveTeamItems($player->getName()); //DEBUG getName or just player } public function onPlayerQuit (PlayerQuitEvent $event) { $player = $event->getPlayer(); if (array_key_exists($player->getName(), $this->temp["BluePlayers"])) { unset($this->temp["BluePlayers"][$player->getName()]); } else { unset($this->temp["RedPlayers"][$player->getName()]); } } public function onEntityMove(EntityMoveEvent $event) { $x = round($event->getEntity()->getX()); $y = round($event->getEntity()->getY()); $z = round($event->getEntity()->getZ()); $blue = $this->getConfig()->get("BlueReturn"); $red = $this->getConfig()->get("RedReturn"); $blues = $this->getConfig()->get("BlueSpawn"); $reds = $this->getConfig()->get("RedSpawn"); if ($x == $blue["x"] and $y == $blue["y"] and $z == $blue["z"]){ $pos = new Position($blues["x"], $blues["y"], $blues["z"], $event->getEntity()->getLevel()); $event->getEntity()->teleport($pos); } else if ($x == $red["x"] and $y == $red["y"] and $z == $red["z"]) { $pos = new Position($reds["x"], $reds["y"], $reds["z"] ,$event->getEntity()->getLevel()); $event->getEntity()->teleport($pos); } } public function onHurt(EntityDamageEvent $event) { if($event->getEntity() instanceof Player and $event instanceof EntityDamageByEntityEvent) { $player = $event->getEntity(); $cause = $event->getDamager(); if (($player instanceof Player) and ($cause instanceof Player)) { if (array_key_exists($player->getName(), $this->temp["BluePlayers"])) { if (array_key_exists($cause->getName(), $this->temp["BluePlayers"])) { $cause->sendMessage("You cannot harm players on your team!"); $event->setCancelled(); } } else if (array_key_exists($player->getName(), $this->temp["RedPlayers"])) { if (array_key_exists($cause->getName(), $this->temp["RedPlayers"])) { $cause->sendMessage("You cannot harm players on your team!"); $event->setCancelled(); } } } } } public function onEntityDeath (EntityDeathEvent $event) { $event->setDrops(array()); } public function onPlayerRespawn (PlayerRespawnEvent $event) { $player = $event->getPlayer(); if (is_array($this->temp["BluePlayers"]) && array_key_exists($player->getName(), $this->temp["BluePlayers"])) { $config = $this->getConfig()->get("BlueSpawn"); $pos = new Position($config["x"], $config["y"], $config["z"], $this->getServer()->getLevelByName($config["level"])); $event->setRespawnPosition($pos); $player->sendMessage("You have been teleported to your base!"); $this->giveBlueTeamItems($player->getName()); $player->setNameTag("[BLUE] " . $player->getName()); } else if (is_array($this->temp["RedPlayers"]) && array_key_exists($player->getName(), $this->temp["RedPlayers"])) { $config = $this->getConfig()->get("RedSpawn"); $pos = new Position($config["x"], $config["y"], $config["z"], $this->getServer()->getLevelByName($config["level"])); $event->setRespawnPosition($pos); $player->sendMessage("You have been teleported to your base!"); $this->giveRedTeamItems($player->getName()); $player->setNameTag("[RED] " . $player->getName()); } } public function writeConfigCoords($sender, $coordname){ $x = (int)$sender->x; $y = (int)$sender->y; $z = (int)$sender->z; $level = $sender->getLevel()->getName(); $coordarray = array("x" => $x, "y" => $y, "z" => $z, "level" => $level); $this->getConfig()->set($coordname, $coordarray); $sender->sendMessage($coordname. " set!"); } public function assignPlayer($player){ $name = $player->getName(); $red = $this->temp["RedPlayers"]; //sends minor error cuz not set yet $blue = $this->temp["BluePlayers"]; if (count($blue) > count($red)) { $assignment = "red"; } else { $assignment = "blue"; } if ($assignment === "blue") { $this->temp["BluePlayers"][$name] = true; $player->setDisplayName("[BLUE] " . $name); $player->setNameTag("[BLUE] " . $name); $this->giveBlueTeamItems($player->getName()); } else { $this->temp["RedPlayers"][$name] = true; $player->setDisplayName("[RED] " . $name); $player->setNameTag("[RED] " . $name); $this->giveRedTeamItems($player->getName()); } $player->sendMessage("You have been assigned to the " . $assignment . " team!"); if ($assignment === "red"){ $spawn = "RedSpawn"; } else { $spawn = "BlueSpawn"; } if ($this->getConfig()->get($spawn) == false) { $player->sendMessage("Plugin not yet configured. Come back soon!"); } else { $config = $this->getConfig()->get($spawn); $pos = new Position($config["x"], $config["y"], $config["z"], $this->getServer()->getLevelByName($config["level"])); $player->teleport($pos); $player->sendMessage("You have been teleported to your base!"); } } public function broadcastScore($player) { if (isset($this->temp["BluePoints"])) { $blue = $this->temp["BluePoints"]; } else { $blue = 0; } if (isset($this->temp["RedPoints"])) { $red = $this->temp["RedPoints"]; } else { $red = 0; } $this->getServer()->broadcastMessage("Player:" . $player->getDisplayName() . " scored a point!"); $this->getServer()->broadcastMessage("Red: " . $red); $this->getServer()->broadcastMessage("Blue: " . $blue); } public function giveRedTeamItems($player) { //gives items to $player according to which team he is on $p = $this->getServer()->getPlayer($player); $inv = $p->getInventory(); $inv->setContents([]); $inv->setArmorItem(0, Item::get(Item::GOLD_HELMET)); $inv->setArmorItem(1, Item::get(Item::GOLD_CHESTPLATE)); $inv->setArmorItem(2, Item::get(Item::GOLD_LEGGINGS)); $inv->setArmorItem(3, Item::get(Item::GOLD_BOOTS)); $inv->sendArmorContents($p); $inv->addItem(Item::get(Item::COMPASS, 0, 1)); $inv->addItem(Item::get(Item::APPLE, 0, 5)); $inv->addItem(Item::get(Item::STONE_SWORD, 0, 1)); $inv->addItem(Item::get(Item::BOW, 0, 1)); $inv->addItem(Item::get(Item::ARROW, 0, 32)); $inv->addItem(Item::get(Item::SNOWBALL, 0, 32)); $inv->sendContents($p); //$pk = new PlayerArmorEquipmentPacket; //$pk->eid = $p->getID(); //$armor = []; // TODO //$pk->slots = $armor; //foreach($this->getServer()->getOnlinePlayers() as $other){ // if($p->getID() !== $other->getID()){ // $other->dataPacket($pk); // } //} } public function giveBlueTeamItems($player) { //gives items to $player according to which team he is on $p = $this->getServer()->getPlayer($player); $inv = $p->getInventory(); $inv->setContents([]); $inv->setArmorItem(0, Item::get(Item::CHAIN_HELMET)); $inv->setArmorItem(1, Item::get(Item::CHAIN_CHESTPLATE)); $inv->setArmorItem(2, Item::get(Item::CHAIN_LEGGINGS)); $inv->setArmorItem(3, Item::get(Item::CHAIN_BOOTS)); $inv->sendArmorContents($p); $inv->addItem(Item::get(Item::COMPASS, 0, 1)); $inv->addItem(Item::get(Item::APPLE, 0, 5)); $inv->addItem(Item::get(Item::STONE_SWORD, 0, 1)); $inv->addItem(Item::get(Item::BOW, 0, 1)); $inv->addItem(Item::get(Item::ARROW, 0, 32)); $inv->addItem(Item::get(Item::SNOWBALL, 0, 32)); $inv->sendContents($p); //$pk = new PlayerArmorEquipmentPacket; //$pk->eid = $p->getID(); //$armor = []; // TODO //$pk->slots = $armor; //foreach($this->getServer()->getOnlinePlayers() as $other){ //if($p->getID() !== $other->getID()){ //$other->dataPacket($pk); //} //} } public function onDisable() { $this->getConfig()->save(); } } getOwner()->getConfig()->get("Game Length (Mins)") - $this->times > 0) { $this->broadcastScores(); $times = $this->times + 1; $this->times = $times; $remaining = $this->getOwner()->getConfig()->get("Game Length (Mins)") - $this->times; $this->getServer()->broadcastMessage(round($remaining) . " minutes remaining!" ); } else { $this->endGame(); } } public function broadcastScores(){ $red = $this->getOwner()->temp["RedPoints"]; $blue = $this->getOwner()->temp["BluePoints"]; $this->getserver()->broadcastMessage("EPICMC"); $this->getServer()->broadcastMessage("Blue:" . $blue); $this->getServer()->broadcastMessage("Red:" . $red); } public function endGame() { if ($this->getOwner()->temp["BluePoints"] > $this->getOwner()->temp["RedPoints"]) { $this->broadcastScores(); $this->getServer()->broadcastMessage("THE BLUE TEAM WINS!"); $this->getServer()->broadcastMessage("Server will now restart"); $this->getServer()->broadcastMessage("Please rejoin to play again!"); sleep(3); $this->getServer()->shutdown(); } else if ($this->getOwner()->temp["BluePoints"] < $this->getOwner()->temp["RedPoints"]) { $this->broadcastScores(); $this->getServer()->broadcastMessage("THE RED TEAM WINS!"); $this->getServer()->broadcastMessage("Server will now restart"); $this->getServer()->broadcastMessage("Please rejoin to play again!"); sleep(3); $this->getServer()->shutdown(); } else { $this->getServer()->broadcastMessage("The game ended in a tie!"); $this->getServer()->broadcastMessage("Please rejoin to play again!"); sleep(3); $this->getServer()->shutdown(); } } } This will be used at a later time :) R0§�Z���n��� M&[�.�GBMB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement