function umc_websend_main() { global $UMC_USER; XMPP_ERROR_trace(__FUNCTION__, func_get_args()); $main = $UMC_USER['args'][0]; switch ($main) { case 'event': $event = $UMC_USER['args'][1]; umc_ws_eventhandler($event); break; case 'inventory': umc_show_inventory(); break; case 'help': umc_show_help(); break; default: // check in the plugin folder items for existing commands $function = "umc_wsplg_{$main}"; if (function_exists($function)) { // This plugin wants to handle its own dispatching $function(); } else { umc_wsplg_dispatch($main); // Attempt to use global dispatching } } }
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!"); }
function umc_mod_warp_lot() { global $UMC_USER; $args = $UMC_USER['args']; if (!isset($args[2])) { umc_show_help($args); die; } $lot = strtolower($args[2]); $world = umc_get_lot_world($lot); $playerworld = $UMC_USER['world']; if ($world != $playerworld) { umc_ws_cmd("mv tp {$world}", 'asPlayer'); } $sql = "SELECT min_x, min_z FROM minecraft_worldguard.`region_cuboid` WHERE region_id='{$lot}';"; $D = umc_mysql_fetch_all($sql); $row = $D[0]; $x = $row['min_x']; $z = $row['min_z']; $y = 70; umc_ws_cmd("tppos {$x} {$y} {$z} 135", 'asPlayer'); }
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'); }
function umc_contests_join() { global $UMC_USER; $args = $UMC_USER['args']; $player = $UMC_USER['username']; $debug = true; if (!isset($args[2])) { umc_show_help($args); die; } $id = $args[2]; umc_pretty_bar("darkblue", "-", "{darkcyan} Joining contest {$id} "); if (!is_numeric($id)) { umc_error("You have to enter a numeric contest ID ({$id}). See /contest list"); } // find out if the contest is creative or survival $sql = "SELECT * FROM minecraft_srvr.contest_contests WHERE id = {$id};"; $rst = mysql_query($sql); $contest = mysql_fetch_array($rst, MYSQL_ASSOC); $status = $contest['status']; if ($status !== 'active') { umc_error("Contest number {$id} is not active. Please chose a different contest!"); } $min = array('aether' => array('x' => -1532, 'z' => -1532, 'y' => 11, 'parent' => 'aet_p1'), 'flatlands' => array('x' => 1028, 'z' => 1028, 'y' => 64, 'parent' => 'flat_b19')); $max = array('aether' => array('x' => -1157, 'z' => -1157, 'y' => 255), 'flatlands' => array('x' => 1275, 'z' => 1275, 'y' => 255)); $gap = 4; $type = 'survival'; $world = 'aether'; if ($contest['type'] == 'creative') { $type = 'creative'; $world = 'flatlands'; } $parent = $min[$world]['parent']; $min_coords = $min[$world]; $min_x = $min_coords['x']; $min_z = $min_coords['z']; $min_y = $min_coords['y']; if ($debug) { umc_echo("Min coords are {$min_x}/{$min_y}/{$min_z}"); } $max_coords = $max[$world]; $max_x = $max_coords['x']; $max_z = $max_coords['z']; $max_y = $max_coords['y']; if ($debug) { umc_echo("MAx coords are {$max_x}/{$max_y}/{$max_z}"); } $user_id = umc_get_worldguard_id('user', strtolower($player)); $world_id = umc_get_worldguard_id('world', strtolower($world)); // 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 WHERE world.name='{$world}' AND region.id LIKE 'con_" . $id . "%' AND user_id={$user_id} AND Owner=1\r\n ORDER BY max_z, max_x"; $rst = mysql_query($sql); $count = mysql_num_rows($rst); if ($count >= $contest['max_entries'] && $player != 'uncovery') { umc_error("You have reached the max number of entries for this contest!;"); } // find out if a contest lot already exists $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 WHERE world.name='{$world}' AND region.id LIKE 'con%' ORDER BY max_z, max_x"; $rst = mysql_query($sql); $count = mysql_num_rows($rst); if ($debug) { umc_echo("{$count} entries already entered!"); } $lotnumber = $count + 1; $lot = 'con_' . $id . '_' . $lotnumber; if ($debug) { umc_echo("Trying to create entry {$lot}"); } // how many lots can I fit into the space across? $fullwidth = $max_x - $min_x; if ($debug) { umc_echo("Lot width is {$fullwidth}"); } $single_width = $contest['x'] + $gap; if ($debug) { umc_echo("One lot (with gap) is {$single_width} wide"); } $width_lots = floor($fullwidth / $single_width); if ($debug) { umc_echo("Fitting {$width_lots} per line"); } $fulldepth = $max_z - $min_z; $single_depth = $contest['z'] + $gap; if ($debug) { umc_echo("One lot (with gap) is {$single_depth} deep"); } $depth_lots = floor($fulldepth / $single_depth); if ($debug) { umc_echo("Fitting {$depth_lots} per row"); } $full_lines = floor($count / $width_lots); if ($debug) { umc_echo("{$full_lines} lines already full"); } $lastline_lots = $count - $full_lines * $width_lots; if ($debug) { umc_echo("Last line has {$lastline_lots} lots"); } $start_x = $lastline_lots * ($contest['x'] + $gap) + $min_coords['x']; $start_z = $full_lines * ($contest['z'] + $gap) + $min_coords['z']; $start_y = $min_coords['y']; if ($debug) { umc_echo("Starting coords are {$start_x}/{$start_y}/{$start_z}"); } $end_x = $start_x + $contest['x'] - 1; $end_z = $start_z + $contest['z'] - 1; $end_y = $min_coords['y'] + $contest['y'] - 1; if ($debug) { umc_echo("End coords are {$end_x}/{$end_y}/{$end_z}"); } if ($end_x > $max_x || $end_z > $max_z) { umc_error('There is no more space for additional contest entries!;'); } umc_echo("New lot {gold}{$lot}{white} in {gold}{$world}{white} was created at "); umc_echo("coordinates {gold}{$start_x}/{$start_y}/{$start_z}{white} - {gold}{$end_x}/{$end_y}/{$end_z}{white};"); umc_echo("Use {gold}/contest warp {$id} {$lotnumber}{white} to get there."); // create insert SQL id world_id type priority parent $ins_region_sql = "INSERT INTO region (id, world_id, type, priority, parent)\r\n VALUES ('{$lot}', {$world_id}, 'cuboid', 0, '{$parent}');"; $ins_region_rst = mysql_query($ins_region_sql); // insert cuboid region_id world_id min_x min_y min_z max_x max_y max_z $ins_cuboid_sql = "INSERT INTO region_cuboid (region_id, world_id, min_x, min_y, min_z, max_x, max_y, max_z)\r\n VALUES ('{$lot}', {$world_id}, {$start_x}, {$start_y}, {$start_z}, {$end_x}, {$end_y}, {$end_z});"; $ins_cuboid_rst = mysql_query($ins_cuboid_sql); // add user to lot as Owner region_id world_id user_id Owner $ins_user_sql = "INSERT INTO region_players (region_id, world_id, user_id, Owner)\r\n VALUES ('{$lot}', {$world_id}, {$user_id}, 1);"; $inc_user_rst = mysql_query($ins_user_sql); umc_ws_cmd("region load -w {$world}", 'asConsole'); umc_footer(); }
function umc_ticket_new() { global $WSEND; $player = $WSEND['player']; $player_email = umc_user_email($player); $player_id = umc_user_id($player); $devOptions = umc_ticket_options(); $args = $WSEND['args']; if (!isset($args[1])) { umc_show_help($args); } array_shift($args); array_shift($args); $text = trim(implode(' ', $args)); if (stristr($text, 'have a problem') || strlen($text) < 8) { umc_error("You need to specify the problem better!"); } $sql_text = mysql_real_escape_string($text); $wpscst_title = base64_encode(strip_tags($text)); $wpscst_initial_message = base64_encode($text); $wpscst_department = base64_encode(strip_tags('in-game')); $sql = "\r\n INSERT INTO minecraft.`wp_wpscst_tickets` (\r\n `primkey`, `title`, `initial_message`, `user_id`, `email`, `assigned_to`, `severity`, `resolution`,\r\n `time_posted`, `last_updated`, `last_staff_reply`, `target_response_time`, `type`) VALUES (\r\n NULL,\r\n '{$wpscst_title}',\r\n '{$wpscst_initial_message}',\r\n '{$player_id}',\r\n '{$player_email}',\r\n '0',\r\n 'Normal',\r\n 'Open',\r\n '" . current_time('timestamp') . "',\r\n '" . current_time('timestamp') . "',\r\n '',\r\n '2 days',\r\n '{$wpscst_department}'\r\n );\r\n "; $rst = mysql_query($sql); $lastID = mysql_insert_id(); // user email $to = $player_email; // Send this to the ticket creator $subject = $devOptions['email_new_ticket_subject'] . " Ticket ID [{$lastID}]"; $message = $devOptions['email_new_ticket_body'] . "\r\nTicket contents: \r\n{$text}"; $headers = 'From: ' . $devOptions['email'] . "\r\n" . 'Reply-To: ' . $devOptions['email'] . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); // admin email $to = $devOptions['email']; // Send this to the admin^M $subject = __("[Uncovery Minecraft] New Ticket from {$player}", 'wpsc-support-tickets'); $message = __("New Ticket [{$lastID}] from {$player}:\r\n" . $text . "\r\n", 'wpsc-support-tickets') . get_admin_url() . 'admin.php?page=wpscSupportTickets-edit&primkey=' . $lastID . "\r\n" . var_dump($devOptions); $headers = 'From: ' . $player_email . "\r\n" . 'Reply-To: ' . $player_email . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); umc_pretty_bar('red', '-', ' Help Ticket Created ', $width = 52); umc_echo('Your question:'); umc_echo("{yellow}{$text}"); umc_echo('You also received an email. Please check your inbox.'); umc_pretty_bar('red', '-', '', $width = 52); }
function umc_wsplg_dispatch($module) { global $UMC_USER, $WS_INIT, $UMC_SETTING; XMPP_ERROR_trace(__FUNCTION__, func_get_args()); $admins = $UMC_SETTING['admins']; $player = $UMC_USER['username']; $command = umc_wsplg_find_command($module); if (!$command) { return umc_show_help($UMC_USER['args']); } // we call this here since $UMC_USER was changes in the line above $args = $UMC_USER['args']; if (!in_array($player, $admins) && isset($WS_INIT[$args[0]]['disabled']) && $WS_INIT[$args[0]]['disabled'] == true) { umc_error("{yellow}Sorry {$player}, {red}{$args[0]}{yellow} is currently down for maintenance."); } if (isset($command['function']) && function_exists($command['function'])) { if (isset($command['security']) && !in_array($player, $admins)) { // Are there security restrictions? // This command is restricted to the named worlds if (isset($command['security']['worlds'])) { if (!in_array($UMC_USER['world'], $command['security']['worlds'])) { umc_error("{red}That command is restricted to the following worlds: {yellow}" . join(", ", $command['security']['worlds'])); } } // This command is restricted to a user level or higher if (isset($command['security']['level'])) { if (!umc_rank_check(umc_get_userlevel($player), $command['security']['level'])) { umc_error('{red}That command is restricted to user level {yellow}' . $command['security']['level'] . '{red} or higher.'); } } } $function = $command['function']; $function(); return true; } else { return umc_show_help($args); } }
/** * Buy items * * @global type $UMC_USER * @param type $to_deposit * @return type */ function umc_do_buy_internal($to_deposit = false) { global $UMC_USER; $player = $UMC_USER['username']; $args = $UMC_USER['args']; $uuid = $UMC_USER['uuid']; $userlevel = $UMC_USER['userlevel']; // we check first if the deposit is empty before we allow trading $remaining = umc_depositbox_checkspace($uuid, $userlevel); $minimum = 0; if ($to_deposit) { $minimum = 1; } if ($remaining < $minimum) { umc_log("shop", "cancel_sale", "sale cancelled, inventory full"); umc_error("You cannot trade items if your deposit is overfilled!"); } $do_check = false; $pos = array_search('check', $args); if ($pos) { $do_check = true; array_splice($args, $pos, 1); } if (!isset($args[2])) { umc_show_help(); return; } elseif (!is_numeric($args[2])) { umc_error("{red}Invalid shop_id: '{yellow}{$args[2]}{red}'. Did you mean '{yellow}/find {$args[2]}{red}'?;"); } $id = $args[2]; if (!isset($args[3])) { umc_echo("{yellow}[!]{gray} You did not enter an amount. Attempting to buy all."); $amount = false; } $amount = umc_sanitize_input($args[3], 'amount'); $sql = "SELECT * FROM minecraft_iconomy.stock WHERE id='{$id}' LIMIT 1;"; $data_row = umc_mysql_fetch_all($sql); if (count($data_row) == 0) { umc_error("Sorry, there is no shop ID {$id}! Please try again."); } $row = $data_row[0]; $seller = umc_user2uuid($row['uuid']); $item = umc_goods_get_text($row['item_name'], $row['damage'], $row['meta']); if ($row) { if (!$amount && $row['amount'] == -1) { umc_error("{red}That item has an unlimited supply. Please enter an amount!;"); } if ($row['uuid'] == $uuid && $player != 'uncovery') { umc_error("{red}You cannot buy your own goods. Use {yellow}/cancel <id>{red} instead!;"); } if (!$amount || $amount > $row['amount'] && $row['amount'] != -1) { // buy as much as possible $amount = $row['amount']; } $sum = $amount * $row['price']; if ($do_check) { umc_echo("{white}[?] {gray}Buying {yellow}{$amount} {$item['full']}{gray} for {cyan}{$row['price']}{gray} each from {gold}{$seller}"); } else { umc_echo("{green}[+] {gray}Buying {yellow}{$amount} {$item['full']}{gray} for {cyan}{$row['price']}{gray} each from {gold}{$seller}"); } $balance = umc_money_check($player); if ($balance < $sum) { umc_echo("{red}[!]{gray} Insufficient funds ({white}{$sum}{gray} needed).;{purple}[?]{white} Why don't you vote for the server and try again?"); } else { $new_balance = $balance - $sum; if ($do_check) { umc_echo("{white}[?]{gray} You would have {green}{$new_balance} Uncs{gray} remaining after spending {cyan}{$sum}", true); return; } if (!$to_deposit) { umc_check_space($amount, $item['item_name'], $item['type']); } umc_echo("{green}[+]{gray} You have {green}{$new_balance} Uncs{gray} remaining after spending {cyan}{$sum}"); // transfer money player1 > player2 umc_money($uuid, $row['uuid'], $sum); $seller = umc_user2uuid($row['uuid']); umc_log('shop', 'buy', "{$player} bought from {$seller}/{$row['uuid']} {$amount} {$item['full_clean']} for {$sum}, money was tranferred"); // give goods to player1 $leftover = umc_checkout_goods($id, $amount, 'stock', false, $to_deposit); $msg = "{$player} bought {$amount} {$item['name']} for {$row['price']} Uncs/pcs (= {$sum} Uncs)! {$leftover} left in stock!;"; umc_msg_user($seller, $msg); } } else { umc_error("{red}The shop-id {white}{$id}{red} could not be found. Please use {yellow}/find{red} and{yellow} /shophelp buy;"); } }