Beispiel #1
0
        private static bool BlockModify_Inner(TSPlayer player, int tileX, int tileY)
        {
            if (!player.IsLoggedIn)
            {
                return(true);
            }

            var plot = Plots.Plots.FirstOrDefault(p => p.Contains(tileX, tileY));

            if (plot == null)
            {
                return(false);
            }
            if (plot.IsWall(tileX, tileY))
            {
                return(!player.HasPermission("pm.build.wall"));
            }
            var index = plot.FindCell(tileX, tileY);

            if (index > -1 && index < plot.Cells.Length)
            {
                if (string.Equals(plot.Cells[index].Owner, player.Name, StringComparison.Ordinal) ||
                    plot.Cells[index].AllowedIDs?.Contains(player.Account.ID) == true ||
                    player.HasPermission("pm.build.everywhere"))
                {
                    plot.Cells[index].LastAccess = DateTime.Now;
                    return(false);
                }
            }

            return(true);
        }
Beispiel #2
0
        private void OnJoin(JoinEventArgs args)
        {
            TSPlayer    tSPlayer = TShock.Players[args.Who];
            UserAccount user     = tSPlayer.Account;

            try
            {
                if (!PlayTime.ContainsKey((byte)args.Who))
                {
                    PlayTime.Add((byte)args.Who, new Stopwatch());
                }
                user             = TShock.UserAccounts.GetUserAccountByName(tSPlayer.Name);
                tSPlayer.Group   = TShock.Groups.GetGroupByName(user.Group);
                tSPlayer.Account = user;
                if (IsReload && !tSPlayer.HasPermission("server.mod"))
                {
                    tSPlayer.SendData(PacketTypes.Disconnect, "Serwer jest w trakcie ladowania zasobow. Sprobuj dolaczyc za chwile.");
                    args.Handled = true;
                    return;
                }
                if (tSPlayer.HasPermission("tshock.godmode"))
                {
                    tSPlayer.GodMode = true;
                }
            }
            catch (NullReferenceException)
            {
            }
            if (user == null)
            {
                return;
            }
            SrvPlayers[args.Who] = DataBase.GetSrvPlayer(user);
            PlayTime[(byte)args.Who].Start();
        }
 public static bool CanUseTimeline(this TSPlayer player, string path)
 {
     return(player.HasPermission(Admin) ||
            player.HasPermission($"{Use}-{Path.GetFileNameWithoutExtension(path)}") ||
            player.HasPermission($"{Use}-{Path.GetDirectoryName(path)}") ||
            player.HasPermission($"{Use}-{Path.GetDirectoryName(path).Replace("\\", "/")}"));
 }
Beispiel #4
0
 public static int CostCalc(TSPlayer who, int cost)
 {
     if (who.HasPermission("isGracz+"))
     {
         cost = (int)(cost * 0.8);
     }
     else if (who.HasPermission("isGracz++"))
     {
         cost = (int)(cost * 0.6);
     }
     return(cost);
 }
Beispiel #5
0
        private void OnNpcStrike(NpcStrikeEventArgs args)
        {
            player = TShock.Players[args.Player.whoAmI];
            if (!args.Handled && !(player.TPlayer.FindBuffIndex(130) == -1) && !player.HasPermission("slimydisable.bypass")) //check if player has slimy saddle buff
            {
                timer.Elapsed += ClearStrikes;
#if DEBUG
                Console.WriteLine($"Player {player.Name} has slime buff and hit {args.Npc.netID}");
#endif
                if (args.Npc.netID == 488 || args.Npc.netID == 68) // target dummy and dungeon guardian respectively
                {
                    if ((args.Player.position.Y + 80 > args.Npc.position.Y) && (args.Player.position.Y + 22 < args.Npc.position.Y) && ((args.Player.position.X - args.Npc.position.X < 64) && (args.Npc.position.X - args.Player.position.X < 64)))
                    {
                        strikes++;
#if DEBUG
                        player.SendMessage($"{strikes} strikes were counted", Color.BurlyWood);
                        player.SendMessage($"Player y: {args.Player.position.Y},\nNpc {args.Npc.netID} y: {args.Npc.position.Y}\n Diff y: {args.Player.position.Y - args.Npc.position.Y}", Color.Bisque);
                        player.SendMessage($"Player x: {args.Player.position.X},\nNpc {args.Npc.netID} x: {args.Npc.position.X}\n Diff x: {args.Player.position.X - args.Npc.position.X}", Color.Bisque);
#endif
                        args.Handled = true;
                    }
                    if (strikes >= strikeCap)
                    {
#if DEBUG
                        player.SendMessage("You've been oofed p hard tbh ngl imho.", Color.BurlyWood);
#endif
                        Punishment();
                    }
                }
                timer.Start();
            }
        }
Beispiel #6
0
        public bool HasPermissionToUseBuff(TSPlayer ply)
        {
            if (ply == null)
            {
                return(false);
            }
            if (ply.HasPermission("komeiji.ignorebuffban"))
            {
                return(true);
            }
            Group        group  = ply.Group;
            List <Group> groups = new List <Group>();

            while (group != null)
            {
                if (this.AllowedGroups.Contains(group.Name))
                {
                    return(true);
                }
                if (groups.Contains(group))
                {
                    object[] name = new object[] { group.Name };
                    throw new InvalidOperationException(StringExt.SFormat("Infinite group parenting ({0})", name));
                }
                groups.Add(group);
                group = group.Parent;
            }
            return(false);
        }
Beispiel #7
0
		public bool HasPermissionToCreateProjectile(TSPlayer ply)
		{
			if (ply == null)
				return false;

			if (ply.HasPermission(Permissions.canusebannedprojectiles))
				return true;

			PermissionHookResult hookResult = PlayerHooks.OnPlayerProjbanPermission(ply, this);
			if (hookResult != PermissionHookResult.Unhandled)
				return hookResult == PermissionHookResult.Granted;

			var cur = ply.Group;
			var traversed = new List<Group>();
			while (cur != null)
			{
				if (AllowedGroups.Contains(cur.Name))
				{
					return true;
				}
				if (traversed.Contains(cur))
				{
					throw new InvalidOperationException("Infinite group parenting ({0})".SFormat(cur.Name));
				}
				traversed.Add(cur);
				cur = cur.Parent;
			}
			return false;
			// could add in the other permissions in this class instead of a giant if switch.
		}
Beispiel #8
0
        private void ThirdPerson(CommandArgs args)
        {
            string   msg = string.Join(" ", args.Parameters);
            TSPlayer plr = args.Player;

            if (string.IsNullOrWhiteSpace(msg))
            {
                plr.SendErrorMessage("Invalid syntax! Proper syntax: /me <text>");
                return;
            }

            if (plr.mute)
            {
                plr.SendErrorMessage("You are muted!");
            }
            else
            {
                if (!plr.HasPermission("antispam.ignore"))
                {
                    msg = RemoveTags(msg);
                    if ((double)msg.Count(Char.IsUpper) / msg.Length >= _config.CapsRatio)
                    {
                        msg = msg.ToLower();
                    }
                }
                TSPlayer.All.SendMessage(string.Format("*{0} {1}", plr.Name, msg), 205, 133, 63);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Determines if a player has permission to use a specific creative power
        /// </summary>
        /// <param name="powerType"></param>
        /// <param name="player"></param>
        /// <returns></returns>
        public static bool HasPermission(CreativePowerTypes powerType, TSPlayer player)
        {
            if (!PowerToPermissionMap.ContainsKey(powerType))
            {
                TShock.Log.ConsoleDebug("CreativePowerHandler received permission check request for unknown creative power");
                return(false);
            }

            string permission = PowerToPermissionMap[powerType];

            //prevent being told about the spawnrate permission on join until relogic fixes
            if (!player.HasReceivedNPCPermissionError && powerType == CreativePowerTypes.SetSpawnRate)
            {
                player.HasReceivedNPCPermissionError = true;
                return(false);
            }

            if (!player.HasPermission(permission))
            {
                player.SendErrorMessage("You do not have permission to {0}.", PermissionToDescriptionMap[permission]);
                return(false);
            }

            return(true);
        }
        public void Execute(TSPlayer executor, params string[] args)
        {
            if (!executor.HasPermission(UsagePermission))
            {
                throw new CommandException(CommandError.NoPermission);
            }

            if (ExpectedParameterCount > args.Length)
            {
                throw new CommandException(CommandError.NotEnoughParameters, ExpectedParameterCount);
            }

            if (Cooldown != 0 && _lastUsed == null)
            {
                _lastUsed = new Dictionary <User, DateTime>();
            }

            if (executor.User != null && Cooldown != 0 &&
                _lastUsed.TryGetValue(executor.User, out DateTime lastUsed) &&
                (DateTime.Now - lastUsed).TotalSeconds < Cooldown)
            {
                throw new CommandException(CommandError.Cooldown,
                                           Math.Round(Cooldown - (DateTime.Now - lastUsed).TotalSeconds));
            }

            if (Commands.Length == 0)
            {
                throw new InvalidOperationException("There are no commands defined in this collection.");
            }

            if (!AllowServer && !executor.ConnectionAlive)
            {
                return;
            }

            if (executor.User != null && Cooldown != 0)
            {
                _lastUsed[executor.User] = DateTime.Now;
            }

            var target = executor.RealPlayer ? new CommandExecutor(executor.Index) : new CommandExecutorServer();

            foreach (var cmd in Commands)
            {
                if (!cmd.TryExecute(target, args))
                {
                    throw new CommandException(CommandError.Unspecified);
                }

                if (cmd.StopOnError && target.LastErrorMessage != null)
                {
                    throw new CommandException(target.LastErrorMessage);
                }

                if (cmd.StopOnInfo && target.LastInfoMessage != null)
                {
                    throw new CommandException(target.LastInfoMessage);
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Handles error messages thrown by erroneous / lack of parameters by checking a player's group permissions.
        /// </summary>
        /// <param name="ply">The player executing the command.</param>
        /// <returns>A string matching the error message.</returns>
        public static string ErrorMessage(TSPlayer ply)
        {
            string error;
            var    list = new List <string>()
            {
                ply.HasPermission("botin.abrir") ? "abrir" : null,
                ply.HasPermission("botin.reload") ? "reload" : null,
                ply.HasPermission("botin.modo") ? "modo" : null,
                "lista"
            };

            string valid = String.Join("/", list.FindAll(i => i != null));

            error = String.Format("Error de uso. Modo de uso: {0}botin <{1}> [tipo]", Commands.Specifier, valid);
            return(error);
        }
Beispiel #12
0
        public bool HasPermissionToPlaceTile(TSPlayer ply)
        {
            if (ply == null)
            {
                return(false);
            }

            if (ply.HasPermission(Permissions.canusebannedtiles))
            {
                return(true);
            }

            var cur       = ply.Group;
            var traversed = new List <Group>();

            while (cur != null)
            {
                if (AllowedGroups.Contains(cur.Name))
                {
                    return(true);
                }
                if (traversed.Contains(cur))
                {
                    throw new InvalidOperationException("Infinite group parenting ({0})".SFormat(cur.Name));
                }
                traversed.Add(cur);
                cur = cur.Parent;
            }
            return(false);
            // could add in the other permissions in this class instead of a giant if switch.
        }
Beispiel #13
0
        /// <summary>
        /// Handles error messages thrown by erroneous / lack of parameters by checking a player's group permissions.
        /// </summary>
        /// <param name="ply">The player executing the command.</param>
        /// <returns>A string matching the error message.</returns>
        public static string ErrorMessage(TSPlayer ply)
        {
            string error;
            var    list = new List <string>()
            {
                ply.HasPermission("key.change") ? "change" : null,
                ply.HasPermission("key.reload") ? "reload" : null,
                ply.HasPermission("key.mode") ? "mode" : null,
                "list"
            };

            string valid = String.Join("/", list.FindAll(i => i != null));

            error = String.Format("Invalid syntax! Proper syntax: {0}key <{1}> [type]", Commands.Specifier, valid);
            return(error);
        }
Beispiel #14
0
        public static Tuple <bool, List <int> > AvailablePrefixes(TSPlayer Player)
        {
            if (Player.HasPermission(BTPermissions.AllowAllPrefixes))
            {
                return(new Tuple <bool, List <int> >(true, null));
            }
            List <int> Allowed = new List <int>();

            foreach (BTPrefix p in Prefixes)
            {
                if (Player.HasPermission(p.Permission))
                {
                    Allowed.AddRange(p.AllowedPrefixes);
                }
            }
            return(new Tuple <bool, List <int> >(false, Allowed));
        }
Beispiel #15
0
        private void PlayerJoin(TerrariaApi.Server.JoinEventArgs args)
        {
            TSPlayer target  = TShock.Players[args.Who];
            String   message = target.Name;

            if (!target.HasPermission("tagblock.allow.name.color"))
            {
                if (message.Contains("[c:") || message.Contains("[c/") && message.Contains("]"))
                {
                    TShock.Utils.ForceKick(target, "Please remove the Color Tag from your username.\n  You can a character editor to do this.", true, true);
                    args.Handled = true;
                }
            }
            ;

            if (!target.HasPermission("tagblock.allow.name.item"))
            {
                if (message.Contains("[i:") || message.Contains("[i/") && message.Contains("]"))
                {
                    TShock.Utils.ForceKick(target, "Please remove the Item Tag from your username.\n  You can a character editor to do this.", true, true);
                    args.Handled = true;
                }
            }
            ;

            if (!target.HasPermission("tagblock.allow.name.achievement"))
            {
                if (message.Contains("[a:") || message.Contains("[a/") && message.Contains("]"))
                {
                    TShock.Utils.ForceKick(target, "Please remove the Achievement Tag from your username.\n  You can a character editor to do this.", true, true);
                    args.Handled = true;
                }
            }
            ;

            if (!target.HasPermission("tagblock.allow.name.player"))
            {
                if (message.Contains("[n:") || message.Contains("[n/") && message.Contains("]"))
                {
                    TShock.Utils.ForceKick(target, "Please remove the Player Name Tag from your username.\n  You can a character editor to do this.", true, true);
                    args.Handled = true;
                }
            }
            ;
        }
Beispiel #16
0
        private void ChatSent(TerrariaApi.Server.ServerChatEventArgs args)
        {
            TSPlayer target  = TShock.Players[args.Who];
            String   message = args.Text.ToLower();

            if (!target.HasPermission("tagblock.allow.text.color"))
            {
                if (message.Contains("[c:") || message.Contains("[c/") && message.Contains("]"))
                {
                    target.SendWarningMessage("[TagBlock] You are not permitted to use the Color Tag. (Detected attempt.)");
                    args.Handled = true;
                }
            }
            ;

            if (!target.HasPermission("tagblock.allow.text.item"))
            {
                if (message.Contains("[i:") || message.Contains("[i/") && message.Contains("]"))
                {
                    target.SendWarningMessage("[TagBlock] You are not permitted to use the Item Tag. (Detected attempt.)");
                    args.Handled = true;
                }
            }
            ;

            if (!target.HasPermission("tagblock.allow.text.achievement"))
            {
                if (message.Contains("[a:") || message.Contains("[a/") && message.Contains("]"))
                {
                    target.SendWarningMessage("[TagBlock] You are not permitted to use the Achievement Tag. (Detected attempt.)");
                    args.Handled = true;
                }
            }
            ;

            if (!target.HasPermission("tagblock.allow.text.player"))
            {
                if (message.Contains("[n:") || message.Contains("[n/") && message.Contains("]"))
                {
                    target.SendWarningMessage("[TagBlock] You are not permitted to use the Player Name Tag. (Detected attempt.)");
                    args.Handled = true;
                }
            }
            ;
        }
        public static void OnServerChat(ServerChatEventArgs args)
        {
            TSPlayer player = TShock.Players[args.Who];

            if (!player.HasPermission(IronPythonConfig.ExecutePermission) || args.Handled)
            {
                return;
            }
            args.Handled = CheckIronPythonInput(player, args.Text);
        }
Beispiel #18
0
 public static int GetMaxCells(this TSPlayer player)
 {
     if (!player.IsLoggedIn)
     {
         return(0);
     }
     if (player.HasPermission("pm.cell.infinite"))
     {
         return(-1);
     }
     for (byte index = 20; index > 0; index++)
     {
         if (player.HasPermission("pm.cell." + index))
         {
             return(index);
         }
     }
     return(PlotMarker.Config.DefaultCellPerPlayer);
 }
Beispiel #19
0
        public static bool IsAdmin(TSPlayer Player)
        {
            bool isAdmin = Player.HasPermission("bindtools.admin");

            if (!isAdmin)
            {
                Player.SendErrorMessage("You do not have access to this command.");
            }
            return(isAdmin);
        }
Beispiel #20
0
        private static void payPlayer(TSPlayer client, string currencyType, string targetName, string money)
        {
            var currency      = BankingPlugin.Instance.Bank.CurrencyManager[currencyType];
            var clientAccount = BankingPlugin.Instance.GetBankAccount(client.Name, currencyType);
            var targetAccount = BankingPlugin.Instance.GetBankAccount(targetName, currencyType);

            if (currency == null)
            {
                client.SendErrorMessage($"Unable to find currency type '{currencyType}'.");
                return;
            }

            if (client != TSPlayer.Server && !string.IsNullOrWhiteSpace(currency.TradePermission))
            {
                //is this player allowed to trade this currency
                if (!client.HasPermission(currency.TradePermission))
                {
                    client.SendErrorMessage($"You are not allowed to trade {currency.InternalName}.");
                    return;
                }
            }

            if (clientAccount == null)
            {
                client.SendErrorMessage($"Unable to find account for currency '{currencyType}'.");
                return;
            }

            if (targetAccount == null)
            {
                client.SendErrorMessage($"Unable to transfer funds, account for {targetName} could not be found.");
                return;
            }

            if (currency.GetCurrencyConverter().TryParse(money, out var amount))
            {
                Debug.Print($"Translated currency to standard units: {amount}.");
                //client.SendInfoMessage($"Translated currency to standard units: {amount}.");

                var result = clientAccount.TryTransferTo(targetAccount, amount);
                if (result)
                {
                    client.SendInfoMessage($"Transferred {amount} to {targetName}'s '{currencyType}' account.");
                }
                else
                {
                    client.SendErrorMessage("Unable to transfer, insufficient funds.");
                }
            }
            else
            {
                client.SendErrorMessage($"Currency format for '{currencyType}' is invalid.");
                return;
            }
        }
 public static IronPythonEnvironment PyEnv(this TSPlayer player)
 {
     if (player.HasPermission(IronPythonConfig.ControlPermission))
     {
         string env = IronPythonPlugin.IronPythonEnv[player.Index >= 0 ? player.Index : Main.maxPlayers];
         if (env != null)
         {
             return(IronPythonConfig.Environments[env]);
         }
         else if (IronPythonConfig.DefaultEnvironment != null)
         {
             return(IronPythonConfig.Environments[IronPythonConfig.DefaultEnvironment]);
         }
     }
     else if (IronPythonConfig.UntrustedEnvironment != null && player.HasPermission(IronPythonConfig.ExecutePermission))
     {
         return(IronPythonConfig.Environments[IronPythonConfig.UntrustedEnvironment]);
     }
     return(null);
 }
Beispiel #22
0
        public bool CanUseCommand(int x, int y, int x2, int y2)
        {
            CanEditEventArgs args = new CanEditEventArgs(plr, x, y, x2, y2);

            WorldEdit.CanEdit.Invoke(args);
            if (args.CanEdit.HasValue)
            {
                if (!args.CanEdit.Value)
                {
                    plr.SendErrorMessage("You do not have permission to use this command in this area.");
                }
                return(args.CanEdit.Value);
            }

            if (plr.HasPermission("worldedit.usage.everywhere"))
            {
                return(true);
            }

            bool noRegion = plr.HasPermission("worldedit.usage.noregion");

            if (!noRegion && !plr.IsLoggedIn)
            {
                plr.SendErrorMessage("You have to be logged in to use this command.");
                return(false);
            }

            Rectangle area = new Rectangle(x, y, x2 - x, y2 - y);

            if ((!noRegion && !TShock.Regions.Regions.Any(r => r.Area.Contains(area))) ||
                !TShock.Regions.CanBuild(x, y, plr) ||
                !TShock.Regions.CanBuild(x2, y, plr) ||
                !TShock.Regions.CanBuild(x2, y2, plr) ||
                !TShock.Regions.CanBuild(x, y2, plr))
            {
                plr.SendErrorMessage("You do not have permission to use this command outside of your regions.");
                return(false);
            }

            return(true);
        }
Beispiel #23
0
 private static void OnCanTouch(CanTouchArgs args)
 {
     if (args.Node.Configuration.Permission is string permission)
     {
         TSPlayer player = args.Touch.Player();
         args.CanTouch = player?.HasPermission(permission) ?? false;
         if (args.Touch.State == TouchState.Begin && player != null && args.CanTouch == false)
         {
             args.Touch.Session.Enabled = false;
             TUI.TUI.TrySetLockForObject(args.Node, args.Touch);
             player.SendErrorMessage("You do not have access to this interface.");
         }
     }
 }
Beispiel #24
0
        /// <summary>
        /// Rejects a pylon teleport request if the player does not have permission
        /// </summary>
        /// <param name="player"></param>
        /// <param name="rejectPacket"></param>
        public void HandlePacket(TSPlayer player, out bool rejectPacket)
        {
            if (PylonEventType == SubPacketType.PlayerRequestsTeleport)
            {
                if (!player.HasPermission(Permissions.pylon))
                {
                    rejectPacket = true;
                    player.SendErrorMessage("You do not have permission to teleport using pylons.");
                    return;
                }
            }

            rejectPacket = false;
        }
Beispiel #25
0
        public bool TryUse(TSPlayer player)
        {
            if (AllPlayerCdSecond <= 0)
            {
                return(true);
            }

            if (_currentCd > 0 && !player.HasPermission("ace.sc.ignorecd"))
            {
                return(false);
            }

            _currentCd = AllPlayerCdSecond;
            return(true);
        }
Beispiel #26
0
        /// <summary>
        ///     Determines if the specified player is allowed.
        /// </summary>
        /// <param name="player">The player, which must not be <c>null</c>.</param>
        /// <returns><c>true</c> if the player is allowed; otherwise, <c>false</c>.</returns>
        public bool IsAllowed(TSPlayer player)
        {
            Debug.Assert(player != null);

            if (player.HasPermission("infchests.admin"))
            {
                return(true);
            }

            var username  = player.User?.Name;
            var groupName = player.Group.Name;

            return(IsPublic || OwnerName == username || AllowedUsernames.Contains(username) ||
                   AllowedGroupNames.Contains(groupName));
        }
Beispiel #27
0
 private void OnGetData(GetDataEventArgs args)
 {
     using (MemoryStream data = new MemoryStream(args.Msg.readBuffer, 3, args.Length - 1))
     {
         if (args.MsgID == PacketTypes.LoadNetModule)
         {
             if (data.ReadByte() == 2)
             {
                 TSPlayer player = TShock.Players[args.Msg.whoAmI];
                 if (player.GetData <bool>("mapteleport") && player.HasPermission("mapteleport.use"))
                 {
                     data.Position++;
                     int X = Math.Min(Main.maxTilesX, Math.Max(0, (int)data.ReadSingle()));
                     int Y = Math.Min(Main.maxTilesY, Math.Max(0, (int)data.ReadSingle()));
                     if (player.HasPermission("mapteleport.solid"))
                     {
                         player.Teleport(X * 16, Y * 16);
                         player.SendSuccessMessage($"Teleported to ({X}, {Y})");
                     }
                     else
                     {
                         if ((Main.tile[X, Y] == null || !Main.tile[X, Y].active() || (!Main.tileSolid[Main.tile[X, Y].type] && Main.tile[X, Y].liquid == 0)) && (Main.tile[X + 1, Y] == null || !Main.tile[X + 1, Y].active() || (!Main.tileSolid[Main.tile[X + 1, Y].type] && Main.tile[X + 1, Y].liquid == 0)) && (Main.tile[X + 1, Y + 1] == null || !Main.tile[X + 1, Y + 1].active() || (!Main.tileSolid[Main.tile[X + 1, Y + 1].type] && Main.tile[X + 1, Y + 1].liquid == 0)) && (Main.tile[X, Y + 1] == null || !Main.tile[X, Y + 1].active() || (!Main.tileSolid[Main.tile[X, Y + 1].type] && Main.tile[X, Y + 1].liquid == 0)) && (Main.tile[X + 1, Y + 2] == null || !Main.tile[X + 1, Y + 2].active() || (!Main.tileSolid[Main.tile[X + 1, Y + 2].type] && Main.tile[X + 1, Y + 2].liquid == 0)) && (Main.tile[X, Y + 2] == null || !Main.tile[X, Y + 2].active() || (!Main.tileSolid[Main.tile[X, Y + 2].type] && Main.tile[X, Y + 2].liquid == 0)))
                         {
                             player.Teleport(X * 16, Y * 16);
                             player.SendSuccessMessage($"Teleported to ({X}, {Y})");
                         }
                         else
                         {
                             player.SendErrorMessage("You do not have permission to teleport into solid tiles.");
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #28
0
        public void ApplyForCell(TSPlayer player, int tileX, int tileY)
        {
            var cell = GetCellByPosition(tileX, tileY);

            if (cell == null)
            {
                player.SendErrorMessage("在选中点位置没有属地.");
                return;
            }
            if (!string.IsNullOrWhiteSpace(cell.Owner) && !player.HasPermission("plotmarker.admin.editall"))
            {
                player.SendErrorMessage("该属地已被占用.");
                return;
            }
            Apply(player, cell);
        }
Beispiel #29
0
        /// <summary>
        /// Inserts player data to the tsCharacter database table
        /// </summary>
        /// <param name="player">player to take data from</param>
        /// <returns>true if inserted successfully</returns>
        public bool InsertPlayerData(TSPlayer player, bool fromCommand = false)
        {
            PlayerData playerData = player.PlayerData;

            if (!player.IsLoggedIn)
            {
                return(false);
            }

            if (player.HasPermission(Permissions.bypassssc) && !fromCommand)
            {
                TShock.Log.ConsoleInfo("Skipping SSC Backup for " + player.Account.Name);                 // Debug code
                return(false);
            }

            if (!GetPlayerData(player, player.Account.ID).exists)
            {
                try
                {
                    database.Query(
                        "INSERT INTO tsCharacter (Account, Health, MaxHealth, Mana, MaxMana, Inventory, extraSlot, spawnX, spawnY, skinVariant, hair, hairDye, hairColor, pantsColor, shirtColor, underShirtColor, shoeColor, hideVisuals, skinColor, eyeColor, questsCompleted, unlockedBiomeTorch) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19, @20, @21);",
                        player.Account.ID, playerData.health, playerData.maxHealth, playerData.mana, playerData.maxMana, String.Join("~", playerData.inventory), playerData.extraSlot, player.TPlayer.SpawnX, player.TPlayer.SpawnY, player.TPlayer.skinVariant, player.TPlayer.hair, player.TPlayer.hairDye, TShock.Utils.EncodeColor(player.TPlayer.hairColor), TShock.Utils.EncodeColor(player.TPlayer.pantsColor), TShock.Utils.EncodeColor(player.TPlayer.shirtColor), TShock.Utils.EncodeColor(player.TPlayer.underShirtColor), TShock.Utils.EncodeColor(player.TPlayer.shoeColor), TShock.Utils.EncodeBoolArray(player.TPlayer.hideVisibleAccessory), TShock.Utils.EncodeColor(player.TPlayer.skinColor), TShock.Utils.EncodeColor(player.TPlayer.eyeColor), player.TPlayer.anglerQuestsFinished, player.TPlayer.unlockedBiomeTorches ? 1 : 0);
                    return(true);
                }
                catch (Exception ex)
                {
                    TShock.Log.Error(ex.ToString());
                }
            }
            else
            {
                try
                {
                    database.Query(
                        "UPDATE tsCharacter SET Health = @0, MaxHealth = @1, Mana = @2, MaxMana = @3, Inventory = @4, spawnX = @6, spawnY = @7, hair = @8, hairDye = @9, hairColor = @10, pantsColor = @11, shirtColor = @12, underShirtColor = @13, shoeColor = @14, hideVisuals = @15, skinColor = @16, eyeColor = @17, questsCompleted = @18, skinVariant = @19, extraSlot = @20, unlockedBiomeTorch = @21 WHERE Account = @5;",
                        playerData.health, playerData.maxHealth, playerData.mana, playerData.maxMana, String.Join("~", playerData.inventory), player.Account.ID, player.TPlayer.SpawnX, player.TPlayer.SpawnY, player.TPlayer.hair, player.TPlayer.hairDye, TShock.Utils.EncodeColor(player.TPlayer.hairColor), TShock.Utils.EncodeColor(player.TPlayer.pantsColor), TShock.Utils.EncodeColor(player.TPlayer.shirtColor), TShock.Utils.EncodeColor(player.TPlayer.underShirtColor), TShock.Utils.EncodeColor(player.TPlayer.shoeColor), TShock.Utils.EncodeBoolArray(player.TPlayer.hideVisibleAccessory), TShock.Utils.EncodeColor(player.TPlayer.skinColor), TShock.Utils.EncodeColor(player.TPlayer.eyeColor), player.TPlayer.anglerQuestsFinished, player.TPlayer.skinVariant, player.TPlayer.extraAccessory ? 1 : 0, player.TPlayer.unlockedBiomeTorches ? 1 : 0);
                    return(true);
                }
                catch (Exception ex)
                {
                    TShock.Log.Error(ex.ToString());
                }
            }
            return(false);
        }
Beispiel #30
0
        /// <summary>
        /// Checks if a given player has permission to build in the region
        /// </summary>
        /// <param name="ply">Player to check permissions with</param>
        /// <returns>Whether the player has permission</returns>
        public bool HasPermissionToBuildInRegion(TSPlayer ply)
        {
            if (!DisableBuild)
            {
                return(true);
            }
            if (!ply.IsLoggedIn)
            {
                if (!ply.HasBeenNaggedAboutLoggingIn)
                {
                    ply.SendMessage("You must be logged in to take advantage of protected regions.", Color.Red);
                    ply.HasBeenNaggedAboutLoggingIn = true;
                }
                return(false);
            }

            return(ply.HasPermission(Permissions.editregion) || AllowedIDs.Contains(ply.Account.ID) || AllowedGroups.Contains(ply.Group.Name) || Owner == ply.Account.Name);
        }
Beispiel #31
0
        /// <summary>
        /// Inserts player data to the tsCharacter database table
        /// </summary>
        /// <param name="player">player to take data from</param>
        /// <returns>true if inserted successfully</returns>
        public bool InsertPlayerData(TSPlayer player)
        {
            PlayerData playerData = player.PlayerData;

            if (!player.IsLoggedIn)
                return false;

            if (player.HasPermission(Permissions.bypassssc))
            {
                TShock.Log.ConsoleInfo("Skipping SSC Backup for " + player.User.Name); // Debug code
                return true;
            }

            if (!GetPlayerData(player, player.User.ID).exists)
            {
                try
                {
                    database.Query(
                        "INSERT INTO tsCharacter (Account, Health, MaxHealth, Mana, MaxMana, Inventory, extraSlot, spawnX, spawnY, skinVariant, hair, hairDye, hairColor, pantsColor, shirtColor, underShirtColor, shoeColor, hideVisuals, skinColor, eyeColor, questsCompleted) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19, @20);",
                        player.User.ID, playerData.health, playerData.maxHealth, playerData.mana, playerData.maxMana, String.Join("~", playerData.inventory), playerData.extraSlot, player.TPlayer.SpawnX, player.TPlayer.SpawnY, player.TPlayer.skinVariant, player.TPlayer.hair, player.TPlayer.hairDye, TShock.Utils.EncodeColor(player.TPlayer.hairColor), TShock.Utils.EncodeColor(player.TPlayer.pantsColor),TShock.Utils.EncodeColor(player.TPlayer.shirtColor), TShock.Utils.EncodeColor(player.TPlayer.underShirtColor), TShock.Utils.EncodeColor(player.TPlayer.shoeColor), TShock.Utils.EncodeBoolArray(player.TPlayer.hideVisual), TShock.Utils.EncodeColor(player.TPlayer.skinColor),TShock.Utils.EncodeColor(player.TPlayer.eyeColor), player.TPlayer.anglerQuestsFinished);
                    return true;
                }
                catch (Exception ex)
                {
                    TShock.Log.Error(ex.ToString());
                }
            }
            else
            {
                try
                {
                    database.Query(
                        "UPDATE tsCharacter SET Health = @0, MaxHealth = @1, Mana = @2, MaxMana = @3, Inventory = @4, spawnX = @6, spawnY = @7, hair = @8, hairDye = @9, hairColor = @10, pantsColor = @11, shirtColor = @12, underShirtColor = @13, shoeColor = @14, hideVisuals = @15, skinColor = @16, eyeColor = @17, questsCompleted = @18, skinVariant = @19, extraSlot = @20 WHERE Account = @5;",
                        playerData.health, playerData.maxHealth, playerData.mana, playerData.maxMana, String.Join("~", playerData.inventory), player.User.ID, player.TPlayer.SpawnX, player.TPlayer.SpawnY, player.TPlayer.hair, player.TPlayer.hairDye, TShock.Utils.EncodeColor(player.TPlayer.hairColor), TShock.Utils.EncodeColor(player.TPlayer.pantsColor), TShock.Utils.EncodeColor(player.TPlayer.shirtColor), TShock.Utils.EncodeColor(player.TPlayer.underShirtColor), TShock.Utils.EncodeColor(player.TPlayer.shoeColor), TShock.Utils.EncodeBoolArray(player.TPlayer.hideVisual), TShock.Utils.EncodeColor(player.TPlayer.skinColor), TShock.Utils.EncodeColor(player.TPlayer.eyeColor), player.TPlayer.anglerQuestsFinished, player.TPlayer.skinVariant, player.TPlayer.extraAccessory ? 1 : 0);
                    return true;
                }
                catch (Exception ex)
                {
                    TShock.Log.Error(ex.ToString());
                }
            }
            return false;
        }
Beispiel #32
0
        /// <summary>
        /// Checks if a given player has permission to build in the region
        /// </summary>
        /// <param name="ply">Player to check permissions with</param>
        /// <returns>Whether the player has permission</returns>
        public bool HasPermissionToBuildInRegion(TSPlayer ply)
        {
            if (!DisableBuild)
            {
                return true;
            }
            if (!ply.IsLoggedIn)
            {
                if (!ply.HasBeenNaggedAboutLoggingIn)
                {
                    ply.SendMessage("You must be logged in to take advantage of protected regions.", Color.Red);
                    ply.HasBeenNaggedAboutLoggingIn = true;
                }
                return false;
            }

            return ply.HasPermission(Permissions.editregion) || AllowedIDs.Contains(ply.User.ID) || AllowedGroups.Contains(ply.Group.Name) || Owner == ply.User.Name;
        }
Beispiel #33
0
        /// <summary>
        /// Checks if a given player can build in a region at the given (x, y) coordinate
        /// </summary>
        /// <param name="x">X coordinate</param>
        /// <param name="y">Y coordinate</param>
        /// <param name="ply">Player to check permissions with</param>
        /// <returns>Whether the player can build at the given (x, y) coordinate</returns>
        public bool CanBuild(int x, int y, TSPlayer ply)
        {
            if (!ply.HasPermission(Permissions.canbuild))
            {
                return false;
            }
            Region top = null;

            foreach (Region region in Regions.ToList())
            {
                if (region.InArea(x, y))
                {
                    if (top == null || region.Z > top.Z)
                        top = region;
                }
            }
            return top == null || top.HasPermissionToBuildInRegion(ply);
        }