function umc_skyblock_abandon() { global $UMC_USER; $player = $UMC_USER['username']; $args = $UMC_USER['args']; if (!isset($args[2])) { umc_show_help($args); die; } else { $lot = umc_sanitize_input($args[2], 'lot'); $check = umc_check_lot_exists('skyblock', $lot); if (!$check) { umc_error("The lot you entered does not exist!"); } if ($lot == 'block_k11') { umc_error('You cannot warp to that lot!'); } } //check if the user abandoned already $abandon_id = umc_get_worldguard_id('user', '_abandoned_'); $abandon_sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id = '{$lot}' AND Owner=1 AND user_id={$abandon_id};"; $D3 = umc_mysql_fetch_all($abandon_sql); $num = count($D3); if ($num > 0) { umc_error("You abandoned the entry {$lot} already!"); } // make sure the user actually owns this enrty $user_id = umc_get_worldguard_id('user', strtolower($player)); // find out if the user can have additional contest entries in this contest $sql = "SELECT * FROM minecraft_worldguard.world LEFT JOIN minecraft_worldguard.region ON world.id=region.world_id\r\n LEFT JOIN minecraft_worldguard.region_cuboid ON region.id=region_cuboid.region_id\r\n LEFT JOIN minecraft_worldguard.region_players ON region_cuboid.region_id=region_players.region_id\r\n LEFT JOIN minecraft_worldguard.user ON region_players.user_id=user.id\r\n WHERE region.id LIKE '{$lot}' AND Owner=1 AND user.id={$user_id}"; $D = umc_mysql_fetch_all($sql); if (count($D) != 1) { umc_error("You do not own the lot {$lot} in skyblock!"); } else { $row = $D[0]; } $world_id = $row['world_id']; $ins_user_sql = "INSERT INTO minecraft_worldguard.region_players (region_id, world_id, user_id, Owner)\r\n VALUES ('{$lot}', {$world_id}, {$abandon_id}, 1);"; umc_mysql_query($ins_user_sql, true); umc_ws_cmd('region load -w skyblock', 'asConsole'); umc_echo("You have succcessfully abandoned the lot {$lot}! It will be reset with the next reboot. You can then register a new one!"); }
/** * Remove all members/Owners and all flags from a region * part of the standard lot reset process * * @param type $lot * @return boolean */ function umc_lot_remove_all($lot) { XMPP_ERROR_trace(__FUNCTION__, func_get_args()); $world = umc_get_lot_world($lot); $world_id = umc_get_worldguard_id('world', $world); if ($world_id === null || !umc_check_lot_exists($world_id, $lot)) { // echo "World $world or lot $lot could not be found!;"; return false; } // Remove all players $sql1 = "DELETE FROM minecraft_worldguard.region_players WHERE region_id = '{$lot}' AND world_id = {$world_id}"; umc_mysql_query($sql1, true); $sql2 = "DELETE FROM minecraft_worldguard.region_flag WHERE region_id = '{$lot}' AND world_id = {$world_id}"; umc_mysql_query($sql2, true); umc_log('lot_manager', 'remove all', "All users and flags have been removed from lot {$lot}"); return true; }
function umc_lot_addrem() { global $UMC_USER; $player = $UMC_USER['username']; $args = $UMC_USER['args']; /// /lotmember lot world add target if (count($args) <= 3) { umc_echo("{red}Not enough arguments given"); umc_show_help($args); return; } $addrem = $args[1]; $lot = strtolower($args[2]); $action = $args[3]; $worlds = array('emp' => 'empire', 'fla' => 'flatlands', 'dar' => 'darklands', 'aet' => 'aether', 'kin' => 'kingdom', 'dra' => 'draftlands', 'blo' => 'skyblock', 'con' => 'aether'); $world_abr = substr($lot, 0, 3); if (!isset($worlds[$world_abr])) { umc_error("Your used an invalid lot name!"); } $world = $worlds[$world_abr]; if ($player == '@Console') { $player = 'uncovery'; } $user_id = umc_get_worldguard_id('user', strtolower($player)); if (!$user_id) { umc_error("Your user id cannot be found!"); } $player_group = umc_get_userlevel($player); $world_id = umc_get_worldguard_id('world', $world); if (!$world_id) { umc_show_help($args); umc_error("The lot '{$lot}' cannot be found in any world!"); } if (!umc_check_lot_exists($world_id, $lot)) { umc_show_help($args); umc_error("There is no lot {$lot} in world {$world}!"); } if ($action == 'snow' || $action == 'ice') { // check if the user has DonatorPlus status. if ($player_group !== 'Owner') { if (!stristr($player_group, 'DonatorPlus')) { umc_error("You need to be DonatorPlus level to use the snow/ice features!;"); } $owner_switch = 0; // check if player is Owner of lot $sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id='{$lot}' AND world_id={$world_id} AND user_id={$user_id} and Owner=1;"; $D = umc_mysql_fetch_all($sql); $num = count($D); if ($num != 1) { umc_error("It appears you {$player} ({$user_id}) are not Owner of lot {$lot} in world {$world}!"); } } // get the current status of the flags if ($addrem == 'add') { $flag = 'allow'; umc_echo("Allowing {$action} forming on lot {$lot}... "); } else { if ($addrem == 'rem') { $flag = 'deny'; umc_echo("Preventing {$action} forming on lot {$lot}... "); } else { umc_show_help($args); } } if ($action == 'snow') { $flagname = 'snow-fall'; } else { if ($action == 'ice') { $flagname = 'ice-form'; } } // does flag exist? $check_sql = "SELECT * FROM minecraft_worldguard.region_flag WHERE region_id='{$lot}' AND world_id={$world_id} AND flag='{$flagname}';"; $D2 = umc_mysql_fetch_all($check_sql); $count = count($D2); if ($count == 0) { // insert $ins_sql = "INSERT INTO minecraft_worldguard.region_flag (region_id, world_id, flag, value) VALUES ('{$lot}', {$world_id}, '{$flagname}', '{$flag}');"; umc_mysql_query($ins_sql, true); } else { // update $upd_sql = "UPDATE minecraft_worldguard.region_flag SET value='{$flag}' WHERE region_id='{$lot}' AND world_id={$world_id} AND flag='{$flagname}';"; umc_mysql_query($upd_sql, true); } umc_echo("done!"); umc_log('lot', 'addrem', "{$player} changed {$action} property of {$lot}"); } else { if ($action == 'owner' || $action == 'give') { if ($player != 'uncovery' && $player != '@Console') { umc_error("Nice try, {$player}. Think I am stupid? Want to get banned?"); } $owner_switch = 1; } else { if ($action == 'member') { $user_id = umc_get_worldguard_id('user', strtolower($player)); if (!$user_id && $player !== 'uncovery') { umc_error("Your user id cannot be found!"); } $owner_switch = 0; // check if player is Owner of lot if ($player_group !== 'Owner') { $sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id='{$lot}' AND world_id={$world_id} AND user_id={$user_id} and Owner=1;"; $D3 = umc_mysql_fetch_all($sql); $count = count($D3); if ($count != 1) { umc_error("It appears you ({$player} {$user_id}) are not Owner of lot {$lot} in world {$world}!"); } } } else { umc_echo("Action {$action} not recognized!"); umc_show_help($args); return; } } // get list of active users $active_users = umc_get_active_members(); for ($i = 4; $i < count($args); $i++) { $target = strtolower($args[$i]); // check if target player exists $target_id = umc_get_worldguard_id('user', strtolower($target)); if (!$target_id) { umc_error("The user {$target} does not exist in the database. Please check spelling of username"); } if ($player != 'uncovery') { $targ_group = umc_get_userlevel($target); if ($targ_group == 'Guest') { umc_error("You cannnot add Guests to your lot!;"); } else { if (!in_array($target, $active_users)) { XMPP_ERROR_trigger("{$player} tried to add {$target} to his lot {$lot}, but {$target} is not an active member!"); umc_error("{$target} is not an active user! You can only add people who have their own lot! See FAQ entry #32 please."); } } } // add / remove target player from lot if ($addrem == 'add') { // make sure target is not already there $sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id='{$lot}' AND world_id={$world_id} AND user_id={$target_id};"; $D3 = umc_mysql_fetch_all($sql); $num = count($D3); if ($num == 1) { umc_error("It appears {$target} is already member of lot {$lot} in world {$world}!"); } // add to the lot umc_lot_add_player($target, $lot, 0); umc_echo("Added {$target} to {$lot} in the {$world}!"); } else { if ($addrem == 'rem') { // check if target is there at all $sql = "SELECT * FROM minecraft_worldguard.region_players WHERE region_id='{$lot}' AND world_id={$world_id} AND user_id={$target_id} AND Owner={$owner_switch} LIMIT 1;"; $D3 = umc_mysql_fetch_all($sql); $num = count($D3); if ($num !== 1) { umc_error("It appears user {$target} is not a member of lot {$lot} in world {$world}!"); } umc_lot_rem_player($target, $lot, 0); umc_echo("Removed {$target} from {$lot} in the {$world}!"); } else { if ($addrem == 'give') { // remove all members and owners umc_lot_remove_all($lot); umc_lot_add_player($target, $lot, 1); umc_echo("Gave {$lot} to {$target} in the {$world}! All other user removed!"); // logfile entry umc_log('lot', 'addrem', "{$player} gave lot to {$target}"); } else { umc_show_help($args); } } } } } umc_ws_cmd("region load -w {$world}", 'asConsole'); }
/** * returns false if lot does not exist * returns array of Owners if lot is occupied * returns empty array if lot unoccupied * @param type $world_id ID or name * @param type $lot name * @return boolean */ function umc_region_check_Owners($world_id, $lot) { if (!is_numeric($world_id)) { $world_id = umc_get_worldguard_id('world', $world_id); } if (umc_check_lot_exists($world_id, $lot)) { $sql = "SELECT user.name as user_name\r\n FROM minecraft_worldguard.region\r\n LEFT JOIN minecraft_worldguard.region_players ON region.id = region_players.region_id\r\n LEFT JOIN minecraft_worldguard.user ON user.id = region_players.user_id\r\n WHERE region.world_id = {$world_id} AND region.id = '{$lot}' AND Owner=1;"; // echo $sql; $rst = mysql_query($sql); $owners = array(); if (mysql_num_rows($rst) > 0) { while ($row = mysql_fetch_array($rst, MYSQL_ASSOC)) { $owners[] = strtolower($row['user_name']); } } return $owners; } else { return false; } }