Merge pull request #297 from mcantor/general-devel
Cleanup: Remove old WarpsManager.cs file
This commit is contained in:
commit
ff24dfaaaf
3 changed files with 6 additions and 214 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
TShock, a server mod for Terraria
|
||||
Copyright (C) 2011 The TShock Team
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ namespace TShockAPI
|
|||
public string Message { get; private set; }
|
||||
public TSPlayer Player { get; private set; }
|
||||
/// <summary>
|
||||
/// Parameters passed to the arguement. Does not include the command name.
|
||||
/// Parameters passed to the arguement. Does not include the command name.
|
||||
/// IE '/kick "jerk face"' will only have 1 argument
|
||||
/// </summary>
|
||||
public List<string> Parameters { get; private set; }
|
||||
|
|
@ -352,7 +352,6 @@ namespace TShockAPI
|
|||
|
||||
private static void PasswordUser(CommandArgs args)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (args.Player.IsLoggedIn && args.Parameters.Count == 2)
|
||||
|
|
@ -901,7 +900,6 @@ namespace TShockAPI
|
|||
Tools.ForceKickAll("Server shutting down for update!");
|
||||
WorldGen.saveWorld();
|
||||
Netplay.disconnect = true;
|
||||
|
||||
}
|
||||
|
||||
#endregion Server Maintenence Commands
|
||||
|
|
@ -1375,7 +1373,6 @@ namespace TShockAPI
|
|||
args.Player.SendMessage("Specified warp not found", Color.Red);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion Teleport Commands
|
||||
|
|
@ -1578,7 +1575,6 @@ namespace TShockAPI
|
|||
|
||||
private static void MaxSpawns(CommandArgs args)
|
||||
{
|
||||
|
||||
if (args.Parameters.Count != 1)
|
||||
{
|
||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /maxspawns <maxspawns>", Color.Red);
|
||||
|
|
@ -1726,7 +1722,6 @@ namespace TShockAPI
|
|||
}
|
||||
switch (cmd)
|
||||
{
|
||||
|
||||
case "name":
|
||||
{
|
||||
{
|
||||
|
|
@ -1735,7 +1730,6 @@ namespace TShockAPI
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "set":
|
||||
{
|
||||
int choice = 0;
|
||||
|
|
@ -2001,7 +1995,6 @@ namespace TShockAPI
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion World Protection Commands
|
||||
|
|
@ -2228,6 +2221,7 @@ namespace TShockAPI
|
|||
(new Thread(ply.Whoopie)).Start(annoy);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion General Commands
|
||||
|
||||
#region Cheat Commands
|
||||
|
|
@ -2608,6 +2602,7 @@ namespace TShockAPI
|
|||
}
|
||||
args.Player.SendMessage("You have grown a " + name, Color.Green);
|
||||
}
|
||||
|
||||
#endregion Cheat Comamnds
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
TShock, a server mod for Terraria
|
||||
Copyright (C) 2011 The TShock Team
|
||||
|
||||
|
|
@ -127,7 +127,6 @@ namespace TShockAPI
|
|||
TSPlayer.All.SendMessage(msg, red, green, blue);
|
||||
TSPlayer.Server.SendMessage(msg, red, green, blue);
|
||||
Log.Info(string.Format("Broadcast: {0}", msg));
|
||||
|
||||
}
|
||||
|
||||
public static void Broadcast(string msg, Color color)
|
||||
|
|
@ -592,4 +591,4 @@ namespace TShockAPI
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,202 +0,0 @@
|
|||
/*
|
||||
TShock, a server mod for Terraria
|
||||
Copyright (C) 2011 The TShock Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Xml;
|
||||
using Terraria;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
class WarpsManager
|
||||
{
|
||||
public static List<Warp> Warps = new List<Warp>();
|
||||
|
||||
public static bool AddWarp(int x, int y, string name, string worldname)
|
||||
{
|
||||
foreach (Warp nametest in Warps)
|
||||
{
|
||||
if (name.ToLower() == nametest.WarpName.ToLower())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Warps.Add(new Warp(new Vector2(x, y), name, worldname));
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool DeleteWarp(string name)
|
||||
{
|
||||
foreach (Warp nametest in Warps)
|
||||
{
|
||||
if (name.ToLower() == nametest.WarpName.ToLower() && nametest.WorldWarpName == Main.worldName)
|
||||
{
|
||||
Warps.Remove(nametest);
|
||||
WriteSettings();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Vector2 FindWarp(string name)
|
||||
{
|
||||
foreach (Warp nametest in Warps)
|
||||
{
|
||||
if (name.ToLower() == nametest.WarpName.ToLower() && nametest.WorldWarpName == Main.worldName)
|
||||
{
|
||||
return nametest.WarpPos;
|
||||
}
|
||||
}
|
||||
return Vector2.Zero;
|
||||
}
|
||||
|
||||
public static void WriteSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
|
||||
xmlWriterSettings.Indent = true;
|
||||
xmlWriterSettings.NewLineChars = Environment.NewLine;
|
||||
|
||||
using (XmlWriter settingsw = XmlWriter.Create(FileTools.WarpsPath, xmlWriterSettings))
|
||||
{
|
||||
settingsw.WriteStartDocument();
|
||||
settingsw.WriteStartElement("Warps");
|
||||
|
||||
foreach (Warp warp in Warps)
|
||||
{
|
||||
settingsw.WriteStartElement("Warp");
|
||||
settingsw.WriteElementString("WarpName", warp.WarpName);
|
||||
settingsw.WriteElementString("X", warp.WarpPos.X.ToString());
|
||||
settingsw.WriteElementString("Y", warp.WarpPos.Y.ToString());
|
||||
settingsw.WriteElementString("WorldName", warp.WorldWarpName);
|
||||
settingsw.WriteEndElement();
|
||||
}
|
||||
|
||||
settingsw.WriteEndElement();
|
||||
settingsw.WriteEndDocument();
|
||||
}
|
||||
Log.Info("Wrote Warps");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Log.Info("Could not write Warps");
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReadAllSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
|
||||
xmlReaderSettings.IgnoreWhitespace = true;
|
||||
|
||||
using (XmlReader settingr = XmlReader.Create(FileTools.WarpsPath, xmlReaderSettings))
|
||||
{
|
||||
while (settingr.Read())
|
||||
{
|
||||
if (settingr.IsStartElement())
|
||||
{
|
||||
switch (settingr.Name)
|
||||
{
|
||||
case "Warps":
|
||||
{
|
||||
break;
|
||||
}
|
||||
case "Warp":
|
||||
{
|
||||
if (settingr.Read())
|
||||
{
|
||||
string name = string.Empty;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
string worldname = string.Empty;
|
||||
|
||||
settingr.Read();
|
||||
if (settingr.Value != "" || settingr.Value != null)
|
||||
name = settingr.Value;
|
||||
else
|
||||
Log.Warn("Warp name is empty, This warp will not work");
|
||||
|
||||
settingr.Read();
|
||||
settingr.Read();
|
||||
settingr.Read();
|
||||
if (settingr.Value != "" || settingr.Value != null)
|
||||
Int32.TryParse(settingr.Value, out x);
|
||||
else
|
||||
Log.Warn("x for warp " + name + " is empty");
|
||||
|
||||
settingr.Read();
|
||||
settingr.Read();
|
||||
settingr.Read();
|
||||
if (settingr.Value != "" || settingr.Value != null)
|
||||
Int32.TryParse(settingr.Value, out y);
|
||||
else
|
||||
Log.Warn("y for warp " + name + " is empty");
|
||||
|
||||
settingr.Read();
|
||||
settingr.Read();
|
||||
settingr.Read();
|
||||
if (settingr.Value != "" || settingr.Value != null)
|
||||
worldname = settingr.Value;
|
||||
else
|
||||
Log.Warn("Worldname for warp " + name + " is empty");
|
||||
|
||||
AddWarp(x, y, name, worldname);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.Info("Read Warps");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Log.Info("Could not read Warps");
|
||||
WriteSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Warp
|
||||
{
|
||||
public Vector2 WarpPos { get; set; }
|
||||
public string WarpName { get; set; }
|
||||
public string WorldWarpName { get; set; }
|
||||
|
||||
public Warp(Vector2 warppos, string name, string worldname)
|
||||
{
|
||||
WarpPos = warppos;
|
||||
WarpName = name;
|
||||
WorldWarpName = worldname;
|
||||
}
|
||||
|
||||
public Warp()
|
||||
{
|
||||
WarpPos = Vector2.Zero;
|
||||
WarpName = null;
|
||||
WorldWarpName = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue