mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-27 15:30:58 -04:00
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:
parent
0b8cbfe91f
commit
395a59a182
@ -14,7 +14,7 @@
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands
|
||||||
{
|
{
|
||||||
@ -28,8 +28,6 @@ namespace MCGalaxy.Commands
|
|||||||
public CmdBlocks() { }
|
public CmdBlocks() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message)
|
public override void Use(Player p, string message)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (message == "")
|
if (message == "")
|
||||||
{
|
{
|
||||||
@ -153,8 +151,7 @@ namespace MCGalaxy.Commands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) { Server.ErrorLog(e); Help(p); }
|
|
||||||
}
|
|
||||||
public override void Help(Player p)
|
public override void Help(Player p)
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "/blocks - Lists all basic blocks");
|
Player.SendMessage(p, "/blocks - Lists all basic blocks");
|
||||||
|
@ -11,7 +11,7 @@ software distributed under the Licenses are distributed on an "AS IS"
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands
|
||||||
@ -26,8 +26,6 @@ namespace MCGalaxy.Commands
|
|||||||
public CmdHelp() { }
|
public CmdHelp() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message)
|
public override void Use(Player p, string message)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
switch (message.ToLower())
|
switch (message.ToLower())
|
||||||
{
|
{
|
||||||
@ -211,9 +209,6 @@ namespace MCGalaxy.Commands
|
|||||||
Player.SendMessage(p, "Could not find command, plugin or block specified.");
|
Player.SendMessage(p, "Could not find command, plugin or block specified.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "An error occured"); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintHelpForGroup(Player p, string typeName, string typeTitle) {
|
static void PrintHelpForGroup(Player p, string typeName, string typeTitle) {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -30,8 +30,6 @@ namespace MCGalaxy.Commands
|
|||||||
public CmdUnloaded() { }
|
public CmdUnloaded() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message)
|
public override void Use(Player p, string message)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
List<string> levels = new List<string>(Server.levels.Count);
|
List<string> levels = new List<string>(Server.levels.Count);
|
||||||
string unloadedLevels = ""; int currentNum = 0; int maxMaps = 0;
|
string unloadedLevels = ""; int currentNum = 0; int maxMaps = 0;
|
||||||
@ -91,8 +89,6 @@ namespace MCGalaxy.Commands
|
|||||||
}
|
}
|
||||||
else Player.SendMessage(p, "No maps are unloaded");
|
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
|
//Exception catching since it needs to be tested on Ocean Flatgrass
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,27 +14,23 @@
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands {
|
||||||
{
|
|
||||||
public sealed class CmdBotRemove : Command
|
public sealed class CmdBotRemove : Command {
|
||||||
{
|
|
||||||
public override string name { get { return "botremove"; } }
|
public override string name { get { return "botremove"; } }
|
||||||
public override string shortcut { get { return ""; } }
|
public override string shortcut { get { return ""; } }
|
||||||
public override string type { get { return CommandTypes.Moderation; } }
|
public override string type { get { return CommandTypes.Moderation; } }
|
||||||
public override bool museumUsable { get { return false; } }
|
public override bool museumUsable { get { return false; } }
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
|
||||||
public string[,] botlist;
|
|
||||||
public CmdBotRemove() { }
|
public CmdBotRemove() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message)
|
public override void Use(Player p, string message) {
|
||||||
{
|
|
||||||
if (message == "") { Help(p); return; }
|
if (message == "") { Help(p); return; }
|
||||||
if (p == null) { MessageInGameOnly(p); return; }
|
if (p == null) { MessageInGameOnly(p); return; }
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (message.ToLower() == "all") {
|
if (message.ToLower() == "all") {
|
||||||
PlayerBot.RemoveAllFromLevel(p.level);
|
PlayerBot.RemoveAllFromLevel(p.level);
|
||||||
} else {
|
} else {
|
||||||
@ -45,13 +41,10 @@ namespace MCGalaxy.Commands
|
|||||||
Player.SendMessage(p, "Removed bot.");
|
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, "/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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands
|
||||||
{
|
{
|
||||||
@ -35,10 +35,8 @@ namespace MCGalaxy.Commands
|
|||||||
Player.SendMessage(p, "You're currently being &4possessed" + Server.DefaultColor + "!");
|
Player.SendMessage(p, "You're currently being &4possessed" + Server.DefaultColor + "!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try
|
|
||||||
{
|
|
||||||
bool stealth = false;
|
|
||||||
|
|
||||||
|
bool stealth = false;
|
||||||
if (message != "")
|
if (message != "")
|
||||||
{
|
{
|
||||||
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.");
|
Player.SendMessage(p, "Following " + who.color + who.DisplayName + Server.DefaultColor + ". Use \"/follow\" to stop.");
|
||||||
p.SendDespawn(who.id);
|
p.SendDespawn(who.id);
|
||||||
}
|
}
|
||||||
catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "Error occured"); }
|
|
||||||
}
|
|
||||||
public override void Help(Player p)
|
public override void Help(Player p)
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "/follow <name> - Follows <name> until the command is cancelled");
|
Player.SendMessage(p, "/follow <name> - Follows <name> until the command is cancelled");
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands
|
||||||
@ -98,8 +98,6 @@ namespace MCGalaxy.Commands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DirectoryInfo di;
|
DirectoryInfo di;
|
||||||
string[] fileContent;
|
string[] fileContent;
|
||||||
|
|
||||||
@ -137,11 +135,6 @@ namespace MCGalaxy.Commands
|
|||||||
Player.SendMessage(p, "Could not find player specified.");
|
Player.SendMessage(p, "Could not find player specified.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Server.ErrorLog(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void highlightStuff(string[] fileContent, Int64 seconds, Player p)
|
public void highlightStuff(string[] fileContent, Int64 seconds, Player p)
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands
|
||||||
@ -32,8 +32,7 @@ namespace MCGalaxy.Commands
|
|||||||
{
|
{
|
||||||
if (message.Split(' ').Length > 2) { Help(p); return; }
|
if (message.Split(' ').Length > 2) { Help(p); return; }
|
||||||
if (p == null) { Player.SendMessage(p, "Console possession? Nope.avi."); return; }
|
if (p == null) { Player.SendMessage(p, "Console possession? Nope.avi."); return; }
|
||||||
try
|
|
||||||
{
|
|
||||||
string skin = (message.Split(' ').Length == 2) ? message.Split(' ')[1] : "";
|
string skin = (message.Split(' ').Length == 2) ? message.Split(' ')[1] : "";
|
||||||
message = message.Split(' ')[0];
|
message = message.Split(' ')[0];
|
||||||
if (message == "")
|
if (message == "")
|
||||||
@ -149,12 +148,6 @@ namespace MCGalaxy.Commands
|
|||||||
Player.SendMessage(p, "Successfully possessed " + who.color + who.name + Server.DefaultColor + ".");
|
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)
|
public override void Help(Player p)
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MCGalaxy.SQL;
|
using MCGalaxy.SQL;
|
||||||
@ -46,8 +46,7 @@ namespace MCGalaxy.Commands
|
|||||||
|
|
||||||
foundLevel.Unload();
|
foundLevel.Unload();
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File.Move("levels/" + foundLevel.name + ".lvl", "levels/" + newName + ".lvl");
|
File.Move("levels/" + foundLevel.name + ".lvl", "levels/" + newName + ".lvl");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -116,8 +115,7 @@ namespace MCGalaxy.Commands
|
|||||||
catch { }
|
catch { }
|
||||||
Player.GlobalMessage("Renamed " + foundLevel.name + " to " + newName);
|
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)
|
public override void Help(Player p)
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "/renamelvl <level> <new name> - Renames <level> to <new name>");
|
Player.SendMessage(p, "/renamelvl <level> <new name> - Renames <level> to <new name>");
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
@ -35,7 +35,6 @@ namespace MCGalaxy.Commands
|
|||||||
|
|
||||||
public override void Use(Player p, string message)
|
public override void Use(Player p, string message)
|
||||||
{
|
{
|
||||||
|
|
||||||
string path;
|
string path;
|
||||||
if (message.Split(' ').Length == 1) path = "levels/" + message + ".lvl";
|
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"; }
|
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; }
|
else { Help(p); return; }
|
||||||
|
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
Level level = LvlFile.Load(name, path);
|
Level level = LvlFile.Load(name, path);
|
||||||
level.setPhysics(0);
|
level.setPhysics(0);
|
||||||
@ -84,13 +81,7 @@ namespace MCGalaxy.Commands
|
|||||||
level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + " " + message.Split(' ')[1] + ")";
|
level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + " " + message.Split(' ')[1] + ")";
|
||||||
|
|
||||||
if (!p.hidden)
|
if (!p.hidden)
|
||||||
{
|
|
||||||
Player.GlobalMessage(p.color + p.prefix + p.name + Server.DefaultColor + " went to the " + level.name);
|
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 {
|
} else {
|
||||||
Player.SendMessage(p, "Level or backup could not be found.");
|
Player.SendMessage(p, "Level or backup could not be found.");
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,6 @@ namespace MCGalaxy.Commands
|
|||||||
if (!Player.ValidName(foundPath)) { Player.SendMessage(p, "Invalid AI name!"); return; }
|
if (!Player.ValidName(foundPath)) { Player.SendMessage(p, "Invalid AI name!"); return; }
|
||||||
if (foundPath == "hunt" || foundPath == "kill") { Player.SendMessage(p, "Reserved for special AI."); return; }
|
if (foundPath == "hunt" || foundPath == "kill") { Player.SendMessage(p, "Reserved for special AI."); return; }
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (message.Split(' ')[0])
|
switch (message.Split(' ')[0])
|
||||||
{
|
{
|
||||||
case "add":
|
case "add":
|
||||||
@ -94,8 +92,7 @@ namespace MCGalaxy.Commands
|
|||||||
default: Help(p); return;
|
default: Help(p); return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) { Server.ErrorLog(e); }
|
|
||||||
}
|
|
||||||
public override void Help(Player p)
|
public override void Help(Player p)
|
||||||
{
|
{
|
||||||
Player.SendMessage(p, "/botai <add/del> [AI name] <extra> - Adds or deletes [AI name]");
|
Player.SendMessage(p, "/botai <add/del> [AI name] <extra> - Adds or deletes [AI name]");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user