Ejemplo n.º 1
0
        private void LevelOnPlayerRemoved(object sender, LevelEventArgs e)
        {
            var plotPlayer = _plotManager.GetOrAddPlotPlayer(e.Player);

            plotPlayer.LastPosition = e.Player.KnownPosition;
            _plotManager.UpdatePlotPlayer(plotPlayer);
        }
Ejemplo n.º 2
0
        public string PlotSetOwner(Player player, string username)
        {
            PlotCoordinates coords = (PlotCoordinates)player.KnownPosition;

            if (coords == null)
            {
                return("Not able to set owner for this plot.");
            }
            if (!_plotManager.HasClaim(coords, player))
            {
                return("Not able to set owner for this plot.");
            }
            if (!_plotManager.TryGetPlot(coords, out Plot plot))
            {
                return("Not able to set owner for this plot.");
            }

            var plotPlayer = _plotManager.GetPlotPlayer(username);

            if (plotPlayer == null)
            {
                var newOwnerPlayer = player.Level.GetSpawnedPlayers().FirstOrDefault(p => p.Username.Equals(username, StringComparison.InvariantCultureIgnoreCase));
                if (newOwnerPlayer == null)
                {
                    return($"Found no player with the name {username}");
                }

                plotPlayer = _plotManager.GetOrAddPlotPlayer(newOwnerPlayer);
            }

            plot.Owner = plotPlayer.Xuid;
            if (!_plotManager.UpdatePlot(plot))
            {
                return("Not able to set owner for this plot.");
            }

            return($"Set new owner to {username}");
        }