void onLeave(IInstance sender, EventCancelToken token) { var name = sender.Attributes.AvatarName; var user = GetUser(sender.Attributes.AvatarSession); if (user == null) { return; } user.Session = User.OFFLINE; user.Save(); // Deallocate pool HudPanel.IDPools.Remove(sender.Attributes.AvatarSession); }
private void OnEntityAdded(IEntity entity, EventCancelToken token) { // Check for errors. if (entity == null) { return; } //Check if it's a player. var isPlayer = entity.GetType().GetInterfaces().Contains(typeof(IPlayerEntity)); if (isPlayer && players) { var playerEntity = (IPlayerEntity)entity; var friendlyFixed = this.friendly.Replace("-", ""); var friendly = friendlyFixed.Split(' '); if (!friendly.Contains(playerEntity.uuid, StringComparer.CurrentCultureIgnoreCase)) { var name = player.entities.FindNameByUuid(playerEntity?.uuid); if ((name?.Name != null && !friendly.Contains(name.Name)) && (name?.Uuid != null && !player.entities.IsBot(name.Uuid))) { NotifyUser(ApplyVariables("A player has been detected.", player?.status?.entity?.location?.ToLocation(0), playerEntity.location.ToLocation(0), name.Name), 4, 3); } } } else if (entity is IMobEntity) { var mobEntity = entity as IMobEntity; if (mobEntity.type == MobType.Wither && wither) { NotifyUser(ApplyVariables("A wither has been detected.", player?.status?.entity?.location?.ToLocation(0), mobEntity.location.ToLocation(0), "Wither"), 10, 2); } else if (mobEntity.type == MobType.Creeper && creeper) { NotifyUser(ApplyVariables("A creeper has been detected.", player?.status?.entity?.location?.ToLocation(0), mobEntity.location.ToLocation(0), "Creeper"), 4, 1); } } }
public void OnClick(IInstance sender, EventCancelToken token) { if (IsDisposed || token.Cancelled) { return; } // Security var id = AWHT.Bot.Attributes.HudElementId; var session = AWHT.Bot.Attributes.HudElementSession; if (id != this.Id || session != this.Session) { return; } // Fire var x = AWHT.Bot.Attributes.HudElementClickX; var y = AWHT.Bot.Attributes.HudElementClickY; token.Cancelled = true; clicked(session, x, y); }
void onEnter(IInstance sender, EventCancelToken token) { var name = sender.Attributes.AvatarName; var session = sender.Attributes.AvatarSession; if (name.StartsWith("[") && name.EndsWith("]")) { return; } if (Settings.Core.GetBoolean("TouristsOnly") && !User.IsTourist(name)) { return; } var user = GetUser(name); user.Session = session; user.LastSeen = DateTime.Now; user.Save(); // Allocate ID pool HudPanel.IDPools[session] = 990; // Create and show scene Log.Info("HUD", "Generating HUD for {0} (session {1})", name, session); user.Scene = SceneIntro.Create(session); if (user.Hidden) { user.Scene.MinimizeHud.Show(); } else { user.Scene.Show(); } }
void onDisconnect(IInstance sender, EventCancelToken token) { Log.Severe("Warn", "Disconnected! Going down..."); throw new Exception("Disconnected"); }