Remove broken announcement

This commit is contained in:
Jeff 2024-07-11 13:18:55 -04:00
parent 658cde2be3
commit 2ec029e262

View File

@ -1,15 +1,19 @@
use std::{ use std::{
collections::HashMap, collections::BTreeMap,
sync::Arc, sync::Arc,
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use rand::{thread_rng, Rng};
use tokio::runtime::Runtime; use tokio::runtime::Runtime;
use vek::Quaternion; use vek::Quaternion;
use veloren_client::{addr::ConnectionArgs, Client, Event as VelorenEvent, WorldExt}; use veloren_client::{addr::ConnectionArgs, Client, Event as VelorenEvent, WorldExt};
use veloren_common::{ use veloren_common::{
clock::Clock, clock::Clock,
comp::{invite::InviteKind, item::ItemDefinitionIdOwned, ChatType, ControllerInputs, Ori, Pos}, comp::{
invite::InviteKind, item::ItemDefinitionIdOwned, Agent, Anchor, ChatType, ControllerInputs,
Ori, Pos,
},
outcome::Outcome, outcome::Outcome,
time::DayPeriod, time::DayPeriod,
trade::{PendingTrade, TradeAction, TradeResult}, trade::{PendingTrade, TradeAction, TradeResult},
@ -18,6 +22,13 @@ use veloren_common::{
DamageSource, ViewDistances, DamageSource, ViewDistances,
}; };
use veloren_common_net::sync::WorldSyncExt; use veloren_common_net::sync::WorldSyncExt;
use veloren_world::{
civ::WorldCivStage,
sim::Location,
site::{Settlement, SiteKindMeta},
site2::Site,
SettlementKindMeta,
};
const COINS: &str = "common.items.utility.coins"; const COINS: &str = "common.items.utility.coins";
@ -32,8 +43,8 @@ pub struct Bot {
client: Client, client: Client,
clock: Clock, clock: Clock,
buy_prices: HashMap<String, u32>, buy_prices: BTreeMap<String, u32>,
sell_prices: HashMap<String, u32>, sell_prices: BTreeMap<String, u32>,
trade_mode: TradeMode, trade_mode: TradeMode,
last_action: Instant, last_action: Instant,
@ -49,8 +60,8 @@ impl Bot {
password: &str, password: &str,
character: &str, character: &str,
admins: Vec<String>, admins: Vec<String>,
buy_prices: HashMap<String, u32>, buy_prices: BTreeMap<String, u32>,
sell_prices: HashMap<String, u32>, sell_prices: BTreeMap<String, u32>,
position: [f32; 3], position: [f32; 3],
orientation: f32, orientation: f32,
) -> Result<Self, String> { ) -> Result<Self, String> {
@ -141,7 +152,9 @@ impl Bot {
self.last_action = Instant::now(); self.last_action = Instant::now();
if self.last_announcement.elapsed() > Duration::from_secs(1200) { if self.last_announcement.elapsed() > Duration::from_secs(1800) {
log::info!("Making an announcement");
self.client.send_command( self.client.send_command(
"region".to_string(), "region".to_string(),
vec![format!( vec![format!(
@ -210,6 +223,24 @@ impl Bot {
self.client.send_invite(sender, InviteKind::Trade); self.client.send_invite(sender, InviteKind::Trade);
} }
} }
"position" => {
if self.is_user_admin(&sender)? {
if let (Some(x), Some(y), Some(z)) = (
split_content.next(),
split_content.next(),
split_content.next(),
) {
let position = [
x.parse::<f32>().map_err(|error| error.to_string())?,
y.parse::<f32>().map_err(|error| error.to_string())?,
z.parse::<f32>().map_err(|error| error.to_string())?,
];
is_correct_format = true;
self.position = position;
}
}
}
_ => {} _ => {}
} }
@ -568,16 +599,6 @@ impl Bot {
Ok(self.admins.contains(sender_name) || self.admins.contains(&sender_uuid)) Ok(self.admins.contains(sender_name) || self.admins.contains(&sender_uuid))
} }
fn find_name<'a>(&'a self, uid: &Uid) -> Option<&'a String> {
self.client.player_list().iter().find_map(|(id, info)| {
if id == uid {
return Some(&info.player_alias);
}
None
})
}
fn handle_position_and_orientation(&mut self) -> Result<(), String> { fn handle_position_and_orientation(&mut self) -> Result<(), String> {
let current_position = self.client.current::<Pos>(); let current_position = self.client.current::<Pos>();
@ -604,6 +625,16 @@ impl Bot {
Ok(()) Ok(())
} }
fn find_name<'a>(&'a self, uid: &Uid) -> Option<&'a String> {
self.client.player_list().iter().find_map(|(id, info)| {
if id == uid {
return Some(&info.player_alias);
}
None
})
}
fn find_uuid(&self, target: &Uid) -> Option<Uuid> { fn find_uuid(&self, target: &Uid) -> Option<Uuid> {
self.client.player_list().iter().find_map(|(uid, info)| { self.client.player_list().iter().find_map(|(uid, info)| {
if uid == target { if uid == target {