public virtual bool HandlePlayerSpawn(TSPlayer player, DPoint spawnTileLocation) { if (this.IsDisposed) return false; bool isBedSpawn = (spawnTileLocation.X != -1 || spawnTileLocation.Y != -1); RemoteClient client = Netplay.Clients[player.Index]; if (!isBedSpawn || client.State <= 3) return false; DPoint bedTileLocation = new DPoint(spawnTileLocation.X, spawnTileLocation.Y - 1); Tile spawnTile = TerrariaUtils.Tiles[bedTileLocation]; bool isInvalidBedSpawn = (!spawnTile.active() || spawnTile.type != TileID.Beds); bool allowNewSpawnSet = true; if (isInvalidBedSpawn) { player.Teleport(Main.spawnTileX * TerrariaUtils.TileSize, (Main.spawnTileY - 3) * TerrariaUtils.TileSize); this.PluginTrace.WriteLineWarning($"Player \"{player.Name}\" tried to spawn on an invalid location."); allowNewSpawnSet = false; } else if (this.Config.EnableBedSpawnProtection) { if (this.CheckProtected(player, bedTileLocation, false)) { player.SendErrorMessage("The bed you have set spawn at is protected, you can not spawn there."); player.SendErrorMessage("You were transported to your last valid spawn location instead."); if (player.TPlayer.SpawnX == -1 && player.TPlayer.SpawnY == -1) player.Teleport(Main.spawnTileX * TerrariaUtils.TileSize, (Main.spawnTileY - 3) * TerrariaUtils.TileSize); else player.Teleport(player.TPlayer.SpawnX * TerrariaUtils.TileSize, (player.TPlayer.SpawnY - 3) * TerrariaUtils.TileSize); allowNewSpawnSet = false; } } if (allowNewSpawnSet) { player.TPlayer.SpawnX = spawnTileLocation.X; player.TPlayer.SpawnY = spawnTileLocation.Y; player.sX = spawnTileLocation.X; player.sY = spawnTileLocation.X; } player.TPlayer.Spawn(); NetMessage.SendData(12, -1, player.Index, string.Empty, player.Index); player.Dead = false; return true; }
public void Update(TSPlayer player) { if ((DateTime.Now - lastDisabled).TotalSeconds > 10) { disabled = false; lastDisabled = DateTime.Now; } bool bypassFlag = BypassFlag(player); bool warning = ((DateTime.Now - lastWarned).TotalSeconds > 1); if (regionStorage.flags.Contains("HEAL")) { if (regionStorage.healinterval < 0 || regionStorage.healamount < 0) return; if ((DateTime.Now - lastHealUpdate).TotalSeconds >= regionStorage.healinterval) { lastHealUpdate = DateTime.Now; player.Heal(regionStorage.healamount); } } if (regionStorage.flags.Contains("MANA")) { if (regionStorage.manainterval < 0 || regionStorage.healamount < 0) return; if ((DateTime.Now - lastManaUpdate).TotalSeconds >= regionStorage.manainterval) { lastManaUpdate = DateTime.Now; var matches = TShock.Utils.GetItemByIdOrName("184"); Item star = matches[0]; player.GiveItem(star.netID, star.name, star.width, star.height, regionStorage.healamount); } } if (regionStorage.flags.Contains("PRIVATE") && !bypassFlag) { if (!gotWarnMessage) { player.Teleport(lastPos.X, lastPos.Y, 1); player.SendErrorMessage("No permission to enter private region!"); gotWarnMessage = true; } } if (regionStorage.flags.Contains("PVP") && !bypassFlag) { if (!player.TPlayer.hostile) { player.SendSuccessMessage("PVP arena entered, pvp enabled."); player.TPlayer.hostile = true; NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index); } } if (regionStorage.flags.Contains("NOPVP") && !bypassFlag) { if (player.TPlayer.hostile) { player.SendSuccessMessage("PVP arena entered, pvp disabled."); player.TPlayer.hostile = false; NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", player.Index); } } if (regionStorage.flags.Contains("TEMPGROUP") && !bypassFlag) { if (!groupset) { player.tempGroup = regionStorage.tempgroup; player.SendSuccessMessage("Your group has been temporarily set to \"{0}\"!", regionStorage.tempgroup.Name); groupset = true; } } if (regionStorage.flags.Contains("DEATH") && !bypassFlag) { if (!killed) { player.DamagePlayer(1200); player.SendErrorMessage("You entered a death zone! RIP"); killed = true; } } if (regionStorage.flags.Contains("HURT") && !bypassFlag) { if (regionStorage.damageinterval < 0 || regionStorage.damageamount< 0) return; if ((DateTime.Now - lastDamageUpdate).TotalSeconds >= regionStorage.damageinterval) { lastDamageUpdate = DateTime.Now; player.DamagePlayer(regionStorage.damageamount); } } if (regionStorage.flags.Contains("COMMAND") && !bypassFlag) { if (!executedcommand) { if (regionStorage.command != null && regionStorage.command != "") { Commands.HandleCommand(TSPlayer.Server, "/" + regionStorage.command); executedcommand = true; } } } if (regionStorage.flags.Contains("PROMOTE") && !bypassFlag) { if (!promoted) { if (player.Group == TShock.Groups.GetGroupByName(regionStorage.fromgroup) || regionStorage.fromgroup == "*") { player.Group = TShock.Groups.GetGroupByName(regionStorage.togroup); player.SendInfoMessage("You have been promoted to group \"{0}\"", regionStorage.togroup); promoted = true; } } } if (regionStorage.flags.Contains("GROUPONLY")) { if (!gotWarnMessage && !regionStorage.groupOnly.Contains(player.Group.Name) && !bypassFlag) { player.Teleport(lastPos.X, lastPos.Y, 1); player.SendErrorMessage("No permission to enter private region!"); gotWarnMessage = true; } } if (regionStorage.flags.Contains("MESSAGE")) { if (!gotmessage) { if (regionStorage.message != null && regionStorage.message != "") { player.SendInfoMessage(regionStorage.message); gotmessage = true; } } } }
public virtual bool HandlePlayerSpawn(TSPlayer player, DPoint spawnTileLocation) { if (this.IsDisposed) return false; if (this.Config.EnableBedSpawnProtection) { DPoint bedTileLocation = new DPoint(spawnTileLocation.X, spawnTileLocation.Y - 1); Tile spawnTile = TerrariaUtils.Tiles[bedTileLocation]; if (!spawnTile.active() || spawnTile.type != (int)BlockType.Bed) return false; if (this.CheckProtected(player, bedTileLocation, false)) { player.SendErrorMessage("The bed you have set spawn at is protected, you can not spawn there."); player.SendErrorMessage("You were transported to your last valid spawn location instead."); if (player.TPlayer.SpawnX == -1 && player.TPlayer.SpawnY == -1) player.Teleport(Main.spawnTileX * TerrariaUtils.TileSize, (Main.spawnTileY - 3) * TerrariaUtils.TileSize); else player.Teleport(player.TPlayer.SpawnX * TerrariaUtils.TileSize, (player.TPlayer.SpawnY - 3) * TerrariaUtils.TileSize); return true; } } return false; }
public static void DoCommand(int id, string cmd, TSPlayer tplayer) { scPlayer doplay = GetscPlayerByID(tplayer.Index); Sign sign = Main.sign[id]; cmd = cmd.ToLower(); if (tplayer == null || doplay == null || sign == null) return; #region Check permissions bool stime = tplayer.Group.HasPermission("usesigntime"); bool sheal = tplayer.Group.HasPermission("usesignheal"); bool smsg = tplayer.Group.HasPermission("usesignmessage"); bool sdmg = tplayer.Group.HasPermission("usesigndamage"); bool sboss = tplayer.Group.HasPermission("usesignspawnboss"); bool smob = tplayer.Group.HasPermission("usesignspawnmob"); bool swarp = tplayer.Group.HasPermission("usesignwarp"); bool sitem = tplayer.Group.HasPermission("usesignitem"); bool sbuff = tplayer.Group.HasPermission("usesignbuff"); bool skit = tplayer.Group.HasPermission("usesignkit"); bool scmd = tplayer.Group.HasPermission("usesigndocommand"); bool nocool = tplayer.Group.HasPermission("nosccooldown"); #endregion #region Time if (cmd.StartsWith("time") && stime && (nocool || ((getConfig.GlobalTimeCooldown && GlobalTimeCooldown <= 0) || (!getConfig.GlobalTimeCooldown && doplay.CooldownTime <= 0)))) { bool done = false; if (cmd.StartsWith("time day")) { TSPlayer.Server.SetTime(true, 150.0); done = true; } else if (cmd.StartsWith("time night")) { TSPlayer.Server.SetTime(false, 0.0); done = true; } else if (cmd.StartsWith("time dusk")) { TSPlayer.Server.SetTime(false, 0.0); done = true; } else if (cmd.StartsWith("time noon")) { TSPlayer.Server.SetTime(true, 27000.0); done = true; } else if (cmd.StartsWith("time midnight")) { TSPlayer.Server.SetTime(false, 16200.0); done = true; } else if (cmd.StartsWith("time fullmoon")) { TSPlayer.Server.SetFullMoon(true); done = true; } else if (cmd.StartsWith("time bloodmoon")) { TSPlayer.Server.SetBloodMoon(true); done = true; } if (done) { if (!nocool && getConfig.GlobalTimeCooldown) GlobalTimeCooldown = getConfig.TimeCooldown; else doplay.CooldownTime = getConfig.TimeCooldown; } } else if (doplay.toldperm <= 0 && !stime && cmd.StartsWith("time ")) { tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed); doplay.toldperm = 5; } else if (doplay.toldcool <= 0 && stime && (!nocool && (!getConfig.GlobalTimeCooldown && doplay.CooldownTime > 0)) && cmd.StartsWith("time ")) { tplayer.SendMessage("You have to wait another " + doplay.CooldownTime + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } else if (doplay.toldcool <= 0 && stime && (!nocool && (getConfig.GlobalTimeCooldown && GlobalTimeCooldown > 0)) && cmd.StartsWith("time ")) { tplayer.SendMessage("Everyone has to wait another " + GlobalTimeCooldown + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } #endregion #region Heal if (cmd.StartsWith("heal") && sheal && (nocool || doplay.CooldownHeal <= 0)) { Item heart = TShock.Utils.GetItemById(58); Item star = TShock.Utils.GetItemById(184); for (int ic = 0; ic < 20; ic++) tplayer.GiveItem(heart.type, heart.name, heart.width, heart.height, heart.maxStack); for (int ic = 0; ic < 10; ic++) tplayer.GiveItem(star.type, star.name, star.width, star.height, star.maxStack); doplay.CooldownHeal = getConfig.HealCooldown; } else if (doplay.toldperm <= 0 && !sheal && cmd.StartsWith("heal")) { tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed); doplay.toldperm = 5; } else if (doplay.toldcool <= 0 && sheal && !nocool && doplay.CooldownHeal > 0 && cmd.StartsWith("heal")) { tplayer.SendMessage("You have to wait another " + doplay.CooldownHeal + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } #endregion #region Message if (cmd.StartsWith("show") && smsg && (nocool || doplay.CooldownMsg <= 0)) { bool done = false; if (cmd.StartsWith("show motd")) { TShock.Utils.ShowFileToUser(tplayer, "motd.txt"); done = true; } else if (cmd.StartsWith("show rules")) { TShock.Utils.ShowFileToUser(tplayer, "rules.txt"); done = true; } else if (cmd.StartsWith("show playing")) { tplayer.SendMessage(string.Format("Current players: {0}.", TShock.Utils.GetPlayers()), 255, 240, 20); done = true; } else if (cmd.StartsWith("show message") && File.Exists("scMeassge.txt")) { TShock.Utils.ShowFileToUser(tplayer, "scMessage.txt"); done = true; } else if (cmd.StartsWith("show message") && !File.Exists("scMeassge.txt")) { tplayer.SendMessage("Could not find message", Color.IndianRed); done = true; } if (done) doplay.CooldownMsg = getConfig.ShowMsgCooldown; } else if (doplay.toldperm <= 0 && !smsg && cmd.StartsWith("show ")) { tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed); doplay.toldperm = 5; } else if (doplay.toldcool <= 0 && smsg && !nocool && doplay.CooldownMsg > 0 && cmd.StartsWith("show ")) { tplayer.SendMessage("You have to wait another " + doplay.CooldownTime + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } #endregion #region Damage if (cmd.StartsWith("damage ") && sdmg && (nocool || doplay.CooldownDamage <= 0)) { try { string[] linesplit = cmd.Split('\'', '\"'); int amtdamage = 0; bool dmgisint = int.TryParse(linesplit[1], out amtdamage); if (dmgisint) { tplayer.DamagePlayer(amtdamage); doplay.CooldownDamage = getConfig.DamageCooldown; } else { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Invalid damage value!", Color.IndianRed); } } } catch (Exception) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Could not parse Damage Amount - Correct Format: \"<Amount to Damage>\"", Color.IndianRed); } } } else if (doplay.toldperm <= 0 && !sdmg && cmd.StartsWith("damage ")) { tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed); doplay.toldperm = 5; } else if (doplay.toldcool <= 0 && sdmg && !nocool && doplay.CooldownDamage > 0 && cmd.StartsWith("damage ")) { tplayer.SendMessage("You have to wait another " + doplay.CooldownDamage + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } #endregion #region Boss if (cmd.StartsWith("boss") && sboss && (nocool || ((getConfig.GlobalBossCooldown && GlobalBossCooldown <= 0) || (!getConfig.GlobalBossCooldown && doplay.CooldownBoss <= 0)))) { bool done = false; if (cmd.StartsWith("boss eater")) { NPC npc = TShock.Utils.GetNPCById(13); TSPlayer.Server.SpawnNPC(npc.type, npc.name, 1, tplayer.TileX, tplayer.TileY); done = true; } else if (cmd.StartsWith("boss eye")) { NPC npc = TShock.Utils.GetNPCById(4); TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, 1, tplayer.TileX, tplayer.TileY); done = true; } else if (cmd.StartsWith("boss king")) { NPC npc = TShock.Utils.GetNPCById(50); TSPlayer.Server.SpawnNPC(npc.type, npc.name, 1, tplayer.TileX, tplayer.TileY); done = true; } else if (cmd.StartsWith("boss skeletron") && !cmd.StartsWith("boss skeletronprime")) { NPC npc = TShock.Utils.GetNPCById(35); TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, 1, tplayer.TileX, tplayer.TileY); done = true; } else if (cmd.StartsWith("boss wof")) { if (Main.wof >= 0 || (tplayer.Y / 16f < (float)(Main.maxTilesY - 205))) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Can't spawn Wall of Flesh!", Color.Red); } return; } NPC.SpawnWOF(new Vector2(tplayer.X, tplayer.Y)); done = true; } else if (cmd.StartsWith("boss twins")) { NPC retinazer = TShock.Utils.GetNPCById(125); NPC spaz = TShock.Utils.GetNPCById(126); TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(retinazer.type, retinazer.name, 1, tplayer.TileX, tplayer.TileY); TSPlayer.Server.SpawnNPC(spaz.type, spaz.name, 1, tplayer.TileX, tplayer.TileY); done = true; } else if (cmd.StartsWith("boss destroyer")) { NPC npc = TShock.Utils.GetNPCById(134); TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, 1, tplayer.TileX, tplayer.TileY); done = true; } else if (cmd.StartsWith("boss skeletronprime")) { NPC npc = TShock.Utils.GetNPCById(127); TSPlayer.Server.SetTime(false, 0.0); TSPlayer.Server.SpawnNPC(npc.type, npc.name, 1, tplayer.TileX, tplayer.TileY); done = true; } if (done) { if (!nocool && getConfig.GlobalBossCooldown) GlobalBossCooldown = getConfig.BossCooldown; else doplay.CooldownBoss = getConfig.BossCooldown; } } else if (doplay.toldperm <= 0 && !sboss && cmd.StartsWith("boss ")) { tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed); doplay.toldperm = 5; } else if (doplay.toldcool <= 0 && sboss && (!nocool && (!getConfig.GlobalBossCooldown && doplay.CooldownBoss > 0)) && cmd.StartsWith("boss ")) { tplayer.SendMessage("You have to wait another " + doplay.CooldownBoss + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } else if (doplay.toldcool <= 0 && sboss && (!nocool && (getConfig.GlobalBossCooldown && GlobalBossCooldown > 0)) && cmd.StartsWith("boss ")) { tplayer.SendMessage("Everyone has to wait another " + GlobalBossCooldown + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } #endregion #region Spawn Mob if ((cmd.StartsWith("spawn mob ") || cmd.StartsWith("spawnmob ") || cmd.StartsWith("spawn ")) && smob && (nocool || ((getConfig.GlobalSpawnMobCooldown && GlobalSpawnMobCooldown <= 0) || (!getConfig.GlobalSpawnMobCooldown && doplay.CooldownSpawnMob <= 0)))) { try { string[] linesplit = cmd.Split('\'', '\"'); for (int i = 1; i < linesplit.Length; i++) { } bool containstime = false; string[] datasplit; if (linesplit[1].Contains(",")) { datasplit = linesplit[1].Split(','); containstime = true; } else datasplit = null; var npcs = new List<NPC>(); int amount = 1; amount = Math.Min(amount, Main.maxNPCs); if (!containstime) { amount = 1; npcs = TShock.Utils.GetNPCByIdOrName(linesplit[1]); } else { int.TryParse(datasplit[1], out amount); npcs = TShock.Utils.GetNPCByIdOrName(datasplit[0]); } if (npcs.Count == 0) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Invalid mob type!", Color.Red); } } else if (npcs.Count > 1) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage(string.Format("More than one ({0}) mob matched!", npcs.Count), Color.Red); } } else { var npc = npcs[0]; if (npc.type >= 1 && npc.type < Main.maxNPCTypes && npc.type != 113) { TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, tplayer.TileX, tplayer.TileY, 50, 20); if (!nocool && getConfig.GlobalSpawnMobCooldown) GlobalSpawnMobCooldown = getConfig.SpawnMobCooldown; else doplay.CooldownSpawnMob = getConfig.SpawnMobCooldown; } else if (npc.type == 113) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Sorry, you can't spawn Wall of Flesh! Try the sign command \"boss wof\""); } } else { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Invalid mob type!", Color.Red); } } } } catch (Exception) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Could not parse Mob / Amount - Correct Format: \"<Mob Name>, <Amount>\"", Color.IndianRed); } } } else if (doplay.toldperm <= 0 && !smob && cmd.StartsWith("spawnmob")) { tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed); doplay.toldperm = 5; } else if (doplay.toldcool <= 0 && smob && (!nocool && (!getConfig.GlobalSpawnMobCooldown && doplay.CooldownSpawnMob > 0)) && (cmd.StartsWith("spawn mob ") || cmd.StartsWith("spawnmob ") || cmd.StartsWith("spawn "))) { tplayer.SendMessage("You have to wait another " + doplay.CooldownSpawnMob + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } else if (doplay.toldcool <= 0 && smob && (!nocool && (getConfig.GlobalSpawnMobCooldown && GlobalSpawnMobCooldown > 0)) && (cmd.StartsWith("spawn mob ") || cmd.StartsWith("spawnmob ") || cmd.StartsWith("spawn "))) { tplayer.SendMessage("Everyone has to wait another " + GlobalSpawnMobCooldown + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } #endregion #region Warp if (swarp && cmd.StartsWith("warp ")) { try { string[] linesplit = cmd.Split('\'', '\"'); var warpxy = TShock.Warps.FindWarp(linesplit[1]); if (warpxy.WarpName == "" || warpxy.WarpPos.X == 0 || warpxy.WarpPos.Y == 0 || warpxy.WorldWarpID == "") { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Could not find warp!", Color.IndianRed); } } else tplayer.Teleport((int)warpxy.WarpPos.X, (int)warpxy.WarpPos.Y); } catch (Exception) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Could not parse Warp - Correct Format: \"<Warp Name>\"", Color.IndianRed); } } } else if (doplay.toldperm <= 0 && !swarp && cmd.StartsWith("warp ")) { tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed); doplay.toldperm = 5; } #endregion #region Item if (cmd.StartsWith("item ") && sitem && (nocool || doplay.CooldownItem <= 0)) { try { string[] linesplit = cmd.Split('\'', '\"'); bool containsamount = false; string[] datasplit; if (linesplit[1].Contains(",")) { datasplit = linesplit[1].Split(','); containsamount = true; } else datasplit = null; int itemAmount = 0; var items = new List<Item>(); if (!containsamount) { itemAmount = 1; items = TShock.Utils.GetItemByIdOrName(linesplit[1]); } else { int.TryParse(datasplit[1], out itemAmount); items = TShock.Utils.GetItemByIdOrName(datasplit[0]); } if (items.Count <= 0) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Invalid item type!", Color.Red); } } else if (items.Count > 1) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage(string.Format("More than one ({0}) item matched!", items.Count), Color.Red); } } else { var item = items[0]; if (item.type >= 1 && item.type < Main.maxItemTypes) { if (tplayer.InventorySlotAvailable || item.name.Contains("Coin")) { if (itemAmount <= 0 || itemAmount > item.maxStack) itemAmount = item.maxStack; tplayer.GiveItem(item.type, item.name, item.width, item.height, itemAmount, 0); if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount, item.name)); } doplay.CooldownItem = getConfig.ItemCooldown; } else { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("You don't have free slots!", Color.Red); } } } else { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Invalid item type!", Color.Red); } } } } catch (Exception) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Could not parse Item / Amount - Correct Format: \"<Item Name>, <Amount>\"", Color.IndianRed); } } } else if (doplay.toldperm <= 0 && !sitem && cmd.StartsWith("item ")) { tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed); doplay.toldperm = 5; } else if (doplay.toldcool <= 0 && sitem && !nocool && doplay.CooldownItem > 0 && cmd.StartsWith("item ")) { tplayer.SendMessage("You have to wait another " + doplay.CooldownItem + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } #endregion #region Buff if (cmd.StartsWith("buff ") && sbuff && (nocool || doplay.CooldownItem <= 0)) { try { string[] linesplit = cmd.Split('\'', '\"'); int count = 0; int c1bid = 1; int c1tme = 1; for (int i = 1; i < linesplit.Length - 1; i++) { int bid = 0; int time = 0; bool containstime = false; string[] datasplit; if (linesplit[i].Contains(",")) { datasplit = linesplit[i].Split(','); containstime = true; } else datasplit = null; string buffvalue = ""; if (!containstime) { time = 60; buffvalue = linesplit[i]; } else { int.TryParse(datasplit[1], out time); buffvalue = datasplit[0]; } if (!int.TryParse(buffvalue, out bid)) { var found = TShock.Utils.GetBuffByName(buffvalue); if (found.Count == 0) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; doplay.TSPlayer.SendMessage("Invalid buff name in buff " + i, Color.Red); } return; } else if (found.Count > 1) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; doplay.TSPlayer.SendMessage(string.Format("More than one ({0}) buffs matched in buff " + i, found.Count), Color.Red); } return; } bid = found[0]; } if (bid > 0 && bid < Main.maxBuffs) { if (time < 0 || time > short.MaxValue) time = 60; doplay.TSPlayer.SetBuff(bid, time * 60); count++; c1bid = bid; c1tme = time; } else { if (doplay.toldalert <= 0) { doplay.toldalert = 3; doplay.TSPlayer.SendMessage("Invalid buff ID in buff " + i, Color.Red); } } } if (doplay.toldalert <= 0) { doplay.toldalert = 3; if (count == 1) doplay.TSPlayer.SendMessage(string.Format("You have buffed yourself with {0}({1}) for {2} seconds!", TShock.Utils.GetBuffName(c1bid), TShock.Utils.GetBuffDescription(c1bid), (c1tme)), Color.Green); else doplay.TSPlayer.SendMessage("You have buffed yourself with multiple buffs!", Color.Green); } if (count > 0) doplay.CooldownBuff = getConfig.BuffCooldown; } catch (Exception) { tplayer.SendMessage("Could not parse Buff / Duration - Correct Format: \"<Buff Name>, <Duration>\"", Color.IndianRed); tplayer.SendMessage("Or for more than one buff: \"<Name>, <Duration>\"<Name>, <Duration>\"", Color.IndianRed); return; } } else if (doplay.toldperm <= 0 && !sbuff && cmd.StartsWith("buff ")) { tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed); doplay.toldperm = 5; } else if (doplay.toldcool <= 0 && sbuff && !nocool && doplay.CooldownBuff > 0 && cmd.StartsWith("buff ")) { tplayer.SendMessage("You have to wait another " + doplay.CooldownBuff + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } #endregion #region Kit if (cmd.StartsWith("kit ") && skit && (nocool || ((getConfig.GlobalKitCooldown && GlobalKitCooldown <= 0) || (!getConfig.GlobalKitCooldown && doplay.CooldownKit <= 0)))) { string kitnme = ""; try { string[] linesplit = cmd.Split('\'', '\"'); kitnme = linesplit[1]; } catch { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Could not parse Kit - Correct Format: \"<Kit Name>\"", Color.IndianRed); } return; } try { HandleKits(tplayer, doplay, kitnme); } catch { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Kits.dll must be present to use Kit Sign Commands!", Color.IndianRed); } return; } } else if (doplay.toldperm <= 0 && !skit && cmd.StartsWith("kit ")) { tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed); doplay.toldperm = 5; } else if (doplay.toldcool <= 0 && skit && !nocool && doplay.CooldownKit > 0 && cmd.StartsWith("kit ")) { tplayer.SendMessage("You have to wait another " + doplay.CooldownKit + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } #endregion #region Do Command if ((cmd.StartsWith("command ") || cmd.StartsWith("cmd ")) && scmd && (nocool || ((getConfig.GlobalDoCommandCooldown && GlobalCommandCooldown <= 0) || (!getConfig.GlobalDoCommandCooldown && doplay.CooldownCommand <= 0)))) { try { string[] linesplit = cmd.Split('\'', '\"'); if (doplay.handlecmd == 0) { TShockAPI.Commands.HandleCommand(tplayer, "/" + linesplit[1]); doplay.handlecmd = 2; } } catch (Exception) { if (doplay.toldalert <= 0) { doplay.toldalert = 3; tplayer.SendMessage("Could not parse Command - Correct Format: \"<Command>\"", Color.IndianRed); } } } else if (doplay.toldperm <= 0 && !scmd && (cmd.StartsWith("Command ") || cmd.StartsWith("Cmd "))) { tplayer.SendMessage("You do not have permission to use this sign command!", Color.IndianRed); doplay.toldperm = 5; } else if (doplay.toldcool <= 0 && scmd && (!nocool && (!getConfig.GlobalDoCommandCooldown && doplay.CooldownCommand > 0)) && (cmd.StartsWith("command ") || cmd.StartsWith("cmd "))) { tplayer.SendMessage("You have to wait another " + doplay.CooldownCommand + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } else if (doplay.toldcool <= 0 && scmd && (!nocool && (getConfig.GlobalDoCommandCooldown && GlobalCommandCooldown > 0)) && (cmd.StartsWith("command ") || cmd.StartsWith("cmd "))) { tplayer.SendMessage("Everyone has to wait another " + GlobalCommandCooldown + " seconds before using this sign", Color.IndianRed); doplay.toldcool = 5; } #endregion }