コード例 #1
0
/**
 * Do an actual lot reset
 *
 * @param type $lot
 * @param type $a
 */
function umc_lot_manager_reset_lot($lot, $a)
{
    XMPP_ERROR_trace(__FUNCTION__, func_get_args());
    $debug = $a['reason'];
    // we assume reseting of chunks, unless the dibs owner does not want to
    $a['reset_chunks'] = true;
    $reason = $a['reason'];
    $a['new_owner'] = false;
    // check dibs
    if ($a['dibs']) {
        if (count($a['dibs']) > 1) {
            $debug .= "Lot {$lot} has more than 1 dibs applicant, aborting! ";
            return;
        }
        $debug .= "Lot {$lot} has dibs! ";
        // we iterate the people who asked for the lot, and
        // once we found a valid one, execute the actions
        //
        // this can only be done AFTER current owners have been removed
        // since the check_before_assign fails if the lot is owned by someone
        umc_lot_remove_all($lot);
        $a['remove_users'] = false;
        foreach ($a['dibs'] as $dibs_info) {
            $dibs_uuid = $dibs_info['uuid'];
            $debug .= " user {$dibs_uuid}: ";
            $dibs_check = umc_lot_manager_check_before_assign($dibs_uuid, $lot);
            XMPP_ERROR_trace('umc_lot_manager_check_before_assign result', $dibs_check);
            if ($dibs_check['result']) {
                $debug .= " OK!";
                $reason .= "user {$dibs_uuid} had dibs and got the lot";
                $a['new_owner'] = $dibs_uuid;
                $a['new_owner_costs'] = $dibs_check['cost'];
                if ($dibs_info['action'] == 'none') {
                    $a['reset_chunks'] = false;
                    $reason .= " but dibs owner did not want to reset!";
                }
                break;
            } else {
                $debug .= " NOT OK, going for next!";
            }
            umc_lot_manager_dib_delete($dibs_uuid, $lot);
            XMPP_ERROR_send_msg("{$debug}");
        }
        //echo $debug . "<br>";
    }
    // reset all lots
    $debug .= "Lot ready for reset!";
    $source_lot = $lot;
    if ($a['user_shop_clean']) {
        $debug .= " Shop cleanout user " . $a['user_shop_clean'] . ", ";
        umc_shop_cleanout_olduser($a['user_shop_clean']);
        // also remove teamspeak priviledges
        umc_ts_clear_rights($a['user_shop_clean'], false);
    }
    if ($a['remove_users']) {
        $debug .= " Removing all users ";
        umc_lot_remove_all($lot);
    }
    if ($a['reset_to']) {
        $source_lot = $a['reset_to'];
    }
    if ($a['del_skyblock_inv']) {
        // value is false or the uuid
        umc_lot_skyblock_inv_reset($a['del_skyblock_inv']);
    }
    if ($a['reset_chunks']) {
        umc_move_chunks($source_lot, $a['source_world'], $lot, $a['dest_world'], false);
    }
    umc_log('lot_manager', 'reset', $reason);
    if ($a['version_sql']) {
        umc_mysql_query($a['version_sql'], true);
    }
    if ($a['new_owner']) {
        // give lot to dibs owner and charge money
        umc_lot_add_player($a['new_owner'], $lot, 1, $a['new_owner_costs']);
        // remove dibs from database
        // umc_lot_manager_dib_delete($a['new_owner'], $lot);
    }
    $debug .= "{$source_lot}, {$a['source_world']}, {$lot}, {$a['dest_world']}";
    XMPP_ERROR_trace(__FUNCTION__, $debug);
}
コード例 #2
0
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');
}