diff --git a/Commands/Moderation/CmdP2P.cs b/Commands/Moderation/CmdP2P.cs index a86f1f924..97c0ed2d6 100644 --- a/Commands/Moderation/CmdP2P.cs +++ b/Commands/Moderation/CmdP2P.cs @@ -1,96 +1,54 @@ /* * Written by Jack1312 * - Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy) - - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.opensource.org/licenses/ecl2.php - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - or implied. See the Licenses for the specific language governing - permissions and limitations under the Licenses. -*/ -namespace MCGalaxy.Commands -{ - public sealed class CmdP2P : Command - { + Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy) + + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.opensource.org/licenses/ecl2.php + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the Licenses for the specific language governing + permissions and limitations under the Licenses. + */ +namespace MCGalaxy.Commands { + + public sealed class CmdP2P : Command { + public override string name { get { return "p2p"; } } 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 LevelPermission defaultRank { get { return LevelPermission.Operator; } } - public CmdP2P() { } - public override void Help(Player p) - { - Player.SendMessage(p, "/p2p [Player1] [Player2] - Teleports player 1 to player 2."); - } - public override void Use(Player p, string message) - { + public override void Use(Player p, string message) { if (message == "") { Help(p); return; } - int number = message.Split(' ').Length; - if (number > 2) { Help(p); return; } - if (number == 2) - { - int pos = message.IndexOf(' '); - string t = message.Substring(0, pos).ToLower(); - string s = message.Substring(pos + 1).ToLower(); - Player who = PlayerInfo.Find(t); - Player who2 = PlayerInfo.Find(s); - if (who == null) - { - if (who2 == null) - { - Player.SendMessage(p, "Neither of the players you specified, can be found or exist!"); - return; - } - Player.SendMessage(p, "Player 1 is not online or does not exist!"); - return; - } - if (who2 == null) - { - Player.SendMessage(p, "Player 2 is not online or does not exist!"); - return; - } - if (who == p) - { - if (who2 == p) - { - Player.SendMessage(p, "Why are you trying to teleport yourself to yourself? =S"); - return; - } - Player.SendMessage(p, "Why not, just use /tp " + who2.name + "!"); - } - if (who2 == p) - { - Player.SendMessage(p, "Why not, just use /summon " + who.name + "!"); - } - if (p.group.Permission < who.group.Permission) - { - Player.SendMessage(p, "You cannot force a player of higher rank to tp to another player!"); - return; - } - if (s == "") - { - Player.SendMessage(p, "You did not specify player 2!"); - return; - } - Command.all.Find("tp").Use(who, who2.name); - Player.SendMessage(p, who.name + " has been successfully teleported to " + who2.name + "!"); + string[] args = message.Split(' '); + if (args.Length > 2) { Help(p); return; } + if (args.Length == 1) { Player.SendMessage(p, "You did not specify the target player."); return; } + Player source = PlayerInfo.Find(args[0]), target = PlayerInfo.Find(args[1]); + + if ((source == null || source.hidden) && (target == null || target.hidden)) { + Player.SendMessage(p, "Neither of the players specified are online."); return; } - - if (number == 1) - { - Player.SendMessage(p, "You did not specify player 2!"); - return; + if (source == null || source.hidden) { Player.SendMessage(p, "The source player is not online."); return; } + if (target == null || target.hidden) { Player.SendMessage(p, "The target player is not online."); return; } + + if (p.group.Permission < source.group.Permission) { + Player.SendMessage(p, "You cannot force a player of higher rank to tp to another player."); return; } + Player.SendMessage(p, "Attempting to teleport " + source.name + " to " + target.name + "."); + Command.all.Find("tp").Use(source, target.name); + } + + public override void Help(Player p) { + Player.SendMessage(p, "/p2p [source] [target] - Teleports the source player to the target player."); } } } diff --git a/Commands/other/CmdTp.cs b/Commands/other/CmdTp.cs index a7190fb71..5aaece76d 100644 --- a/Commands/other/CmdTp.cs +++ b/Commands/other/CmdTp.cs @@ -1,110 +1,59 @@ /* - Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy) - - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.osedu.org/licenses/ECL-2.0 - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - or implied. See the Licenses for the specific language governing - permissions and limitations under the Licenses. -*/ -namespace MCGalaxy.Commands -{ - public sealed class CmdTp : Command - { + Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy) + + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.osedu.org/licenses/ECL-2.0 + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the Licenses for the specific language governing + permissions and limitations under the Licenses. + */ +namespace MCGalaxy.Commands { + + public sealed class CmdTp : Command { + public override string name { get { return "tp"; } } public override string shortcut { get { return ""; } } public override string type { get { return CommandTypes.Other; } } public override bool museumUsable { get { return true; } } public override LevelPermission defaultRank { get { return LevelPermission.Builder; } } - public CmdTp() { } - public override void Use(Player p, string message) - { - if (message == "") - { - Command.all.Find("spawn"); - return; + public override void Use(Player p, string message) { + string[] args = message.Split(' '); + if (args.Length > 1) { Help(p); return; } + + Player target = PlayerInfo.Find(message); + if (target == null || target.hidden) { Player.SendMessage(p, "There is no player \"" + message + "\"."); return; } + if (target.level.name.Contains("cMuseum")) { + Player.SendMessage(p, "Player \"" + message + "\" is in a museum!"); return; } - int number = message.Split(' ').Length; - if (number > 2) { Help(p); return; } - if (number == 2) - { - if (!p.group.CanExecute(Command.all.Find("P2P"))) - { - Player.SendMessage(p, "You cannot teleport others!"); - return; - } - Command.all.Find("P2P").Use(p, message); + + if (!Server.higherranktp && p.group.Permission < target.group.Permission) { + Player.SendMessage(p, "You cannot teleport to a player of higher rank!"); return; } - if (number == 1) - { - Player who = PlayerInfo.Find(message); - if (who == null || (who.hidden && p.group.Permission < LevelPermission.Admin)) { Player.SendMessage(p, "There is no player \"" + message + "\"!"); return; } - if (p.level != who.level) - { - if (who.level.name.Contains("cMuseum")) - { - Player.SendMessage(p, "Player \"" + message + "\" is in a museum!"); - return; - } - else - { - if (Server.higherranktp == false) - { - if (p.group.Permission < who.group.Permission) - { - Player.SendMessage(p, "You cannot teleport to a player of higher rank!"); - return; - } - } - p.beforeTeleportMap = p.level.name; - p.beforeTeleportPos = p.pos; - Command.all.Find("goto").Use(p, who.level.name); - if (who.Loading) - { - Player.SendMessage(p, "Waiting for " + who.color + who.DisplayName + Server.DefaultColor + " to spawn..."); - who.BlockUntilLoad(10); - } - p.BlockUntilLoad(10); //Wait for player to spawn in new map - p.SendPos(0xFF, who.pos[0], who.pos[1], who.pos[2], who.rot[0], 0); - } - return; - } - if (p.level == who.level) - { - if (Server.higherranktp == false) - { - if (p.group.Permission < who.group.Permission) - { - Player.SendMessage(p, "You cannot teleport to a player of higher rank!"); - return; - } - } - p.beforeTeleportMap = p.level.name; - p.beforeTeleportPos = p.pos; - if (who.Loading) - { - Player.SendMessage(p, "Waiting for " + who.color + who.DisplayName + Server.DefaultColor + " to spawn..."); - who.BlockUntilLoad(10); - } - p.BlockUntilLoad(10); //Wait for player to spawn in new map - p.SendPos(0xFF, who.pos[0], who.pos[1], who.pos[2], who.rot[0], 0); - } + p.beforeTeleportMap = p.level.name; + p.beforeTeleportPos = p.pos; + + if (p.level != target.level) + Command.all.Find("goto").Use(p, target.level.name); + if (target.Loading) { + Player.SendMessage(p, "Waiting for " + target.color + target.DisplayName + Server.DefaultColor + " to spawn..."); + target.BlockUntilLoad(10); } + p.BlockUntilLoad(10); //Wait for player to spawn in new map + p.SendPos(0xFF, target.pos[0], target.pos[1], target.pos[2], target.rot[0], 0); } - public override void Help(Player p) - { - Player.SendMessage(p, "/tp [player2] - Teleports yourself to a player."); - Player.SendMessage(p, "[player2] is optional but if present will act like /p2p."); - Player.SendMessage(p, "If is blank, /spawn is used."); + + public override void Help(Player p) { + Player.SendMessage(p, "/tp [target] - Teleports yourself to that player."); + Player.SendMessage(p, "Use /p2p to teleport a given player to a different player."); } } }