Get rid of those try{} catch{} and instead rely on the generic command try{} catch{} handler which prints more detailed information.

This commit is contained in:
UnknownShadow200 2016-02-11 16:54:42 +11:00
parent 0b8cbfe91f
commit 395a59a182
10 changed files with 818 additions and 868 deletions

View File

@ -28,8 +28,6 @@ namespace MCGalaxy.Commands
public CmdBlocks() { }
public override void Use(Player p, string message)
{
try
{
if (message == "")
{
@ -153,8 +151,7 @@ namespace MCGalaxy.Commands
}
}
}
catch (Exception e) { Server.ErrorLog(e); Help(p); }
}
public override void Help(Player p)
{
Player.SendMessage(p, "/blocks - Lists all basic blocks");

View File

@ -26,8 +26,6 @@ namespace MCGalaxy.Commands
public CmdHelp() { }
public override void Use(Player p, string message)
{
try
{
switch (message.ToLower())
{
@ -211,9 +209,6 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "Could not find command, plugin or block specified.");
break;
}
}
catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "An error occured"); }
}
static void PrintHelpForGroup(Player p, string typeName, string typeTitle) {

View File

@ -30,8 +30,6 @@ namespace MCGalaxy.Commands
public CmdUnloaded() { }
public override void Use(Player p, string message)
{
try
{
List<string> levels = new List<string>(Server.levels.Count);
string unloadedLevels = ""; int currentNum = 0; int maxMaps = 0;
@ -91,8 +89,6 @@ namespace MCGalaxy.Commands
}
else Player.SendMessage(p, "No maps are unloaded");
}
}
catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "An error occured"); }
//Exception catching since it needs to be tested on Ocean Flatgrass
}

View File

@ -16,25 +16,21 @@
permissions and limitations under the Licenses.
*/
using System;
namespace MCGalaxy.Commands
{
public sealed class CmdBotRemove : Command
{
namespace MCGalaxy.Commands {
public sealed class CmdBotRemove : Command {
public override string name { get { return "botremove"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Moderation; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
public string[,] botlist;
public CmdBotRemove() { }
public override void Use(Player p, string message)
{
public override void Use(Player p, string message) {
if (message == "") { Help(p); return; }
if (p == null) { MessageInGameOnly(p); return; }
try
{
if (message.ToLower() == "all") {
PlayerBot.RemoveAllFromLevel(p.level);
} else {
@ -45,13 +41,10 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "Removed bot.");
}
}
catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "Error caught"); }
}
public override void Help(Player p)
{
public override void Help(Player p) {
Player.SendMessage(p, "/botremove <name> - Remove a bot on the same level as you");
// Player.SendMessage(p, "If All is used, all bots on the current level are removed");
Player.SendMessage(p, "If 'all' is used, all bots on the current level are removed");
}
}
}

View File

@ -35,10 +35,8 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "You're currently being &4possessed" + Server.DefaultColor + "!");
return;
}
try
{
bool stealth = false;
bool stealth = false;
if (message != "")
{
if (message == "#")
@ -113,8 +111,7 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "Following " + who.color + who.DisplayName + Server.DefaultColor + ". Use \"/follow\" to stop.");
p.SendDespawn(who.id);
}
catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "Error occured"); }
}
public override void Help(Player p)
{
Player.SendMessage(p, "/follow <name> - Follows <name> until the command is cancelled");

View File

@ -98,8 +98,6 @@ namespace MCGalaxy.Commands
}
}
try
{
DirectoryInfo di;
string[] fileContent;
@ -137,11 +135,6 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "Could not find player specified.");
}
}
catch (Exception e)
{
Server.ErrorLog(e);
}
}
public void highlightStuff(string[] fileContent, Int64 seconds, Player p)
{

View File

@ -32,8 +32,7 @@ namespace MCGalaxy.Commands
{
if (message.Split(' ').Length > 2) { Help(p); return; }
if (p == null) { Player.SendMessage(p, "Console possession? Nope.avi."); return; }
try
{
string skin = (message.Split(' ').Length == 2) ? message.Split(' ')[1] : "";
message = message.Split(' ')[0];
if (message == "")
@ -149,12 +148,6 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, "Successfully possessed " + who.color + who.name + Server.DefaultColor + ".");
}
}
catch (Exception e)
{
Server.ErrorLog(e);
Player.SendMessage(p, "There was an error.");
}
}
public override void Help(Player p)
{

View File

@ -46,8 +46,7 @@ namespace MCGalaxy.Commands
foundLevel.Unload();
try
{
File.Move("levels/" + foundLevel.name + ".lvl", "levels/" + newName + ".lvl");
try
{
@ -116,8 +115,7 @@ namespace MCGalaxy.Commands
catch { }
Player.GlobalMessage("Renamed " + foundLevel.name + " to " + newName);
}
catch (Exception e) { Player.SendMessage(p, "Error when renaming."); Server.ErrorLog(e); }
}
public override void Help(Player p)
{
Player.SendMessage(p, "/renamelvl <level> <new name> - Renames <level> to <new name>");

View File

@ -35,7 +35,6 @@ namespace MCGalaxy.Commands
public override void Use(Player p, string message)
{
string path;
if (message.Split(' ').Length == 1) path = "levels/" + message + ".lvl";
else if (message.Split(' ').Length == 2) try { path = @Server.backupLocation + "/" + message.Split(' ')[0] + "/" + int.Parse(message.Split(' ')[1]) + "/" + message.Split(' ')[0] + ".lvl"; }
@ -43,8 +42,6 @@ namespace MCGalaxy.Commands
else { Help(p); return; }
if (File.Exists(path))
{
try
{
Level level = LvlFile.Load(name, path);
level.setPhysics(0);
@ -84,13 +81,7 @@ namespace MCGalaxy.Commands
level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + " " + message.Split(' ')[1] + ")";
if (!p.hidden)
{
Player.GlobalMessage(p.color + p.prefix + p.name + Server.DefaultColor + " went to the " + level.name);
}
} catch (Exception ex) {
Player.SendMessage(p, "Error loading level.");
Server.ErrorLog(ex);
}
} else {
Player.SendMessage(p, "Level or backup could not be found.");
}

View File

@ -37,8 +37,6 @@ namespace MCGalaxy.Commands
if (!Player.ValidName(foundPath)) { Player.SendMessage(p, "Invalid AI name!"); return; }
if (foundPath == "hunt" || foundPath == "kill") { Player.SendMessage(p, "Reserved for special AI."); return; }
try
{
switch (message.Split(' ')[0])
{
case "add":
@ -94,8 +92,7 @@ namespace MCGalaxy.Commands
default: Help(p); return;
}
}
catch (Exception e) { Server.ErrorLog(e); }
}
public override void Help(Player p)
{
Player.SendMessage(p, "/botai <add/del> [AI name] <extra> - Adds or deletes [AI name]");