public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { if (ClientUser.LevelID != 0) { List <String> playerlist = MinecraftHandler.Player; string match = EasyGuess.GetMatchedString(playerlist, arg1); if (!String.IsNullOrEmpty(match)) { long balance = ClientUser.Balance; long money = 0; try { money = Convert.ToInt64(arg2); } catch { } UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); User u = users.GetUserByName(match); if (u != null) { return(GiveMoney(u, money)); } } else { return(new CommandResult(true, String.Format("User <{0}> not found", arg1))); } } else { return(new CommandResult(true, String.Format("You don't have an account"))); } return(new CommandResult(true, String.Format("{0} execute by {1}", Name, TriggerPlayer))); }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance(); Zone zone = EasyGuess.GetMatchedZone(coll, arg1); if (zone != null) { String match = EasyGuess.GetMatchedString(MinecraftHandler.Player, arg2); if (!String.IsNullOrEmpty(match)) { if (TriggerPlayer == ClientUser.Name || ClientUser.LevelID > zone.LevelID) { zone.Owner = match; coll.Save(); return(new CommandResult(true, String.Format("Zone-Owner of zone {0} is now {1}", zone.Name, match))); } else { return(new CommandResult(true, String.Format("Insufficient permissions to set the owner"))); } } else { return(new CommandResult(true, String.Format("User not found {0}", match))); } } else { return(new CommandResult(true, String.Format("Zone not found: {0}", arg1))); } }
/// <summary> /// this is the execution method which gets executed later /// to get more arguments use the internal regArgs variable /// </summary> /// <param name="arg1">first argument after the command in the string</param> /// <param name="arg2">second argument after the command in the string</param> /// <param name="arg3">third argument after the command in the string</param> /// <param name="arg4">fourth argument after the command in the string</param> /// <returns>remember to set the command result in every return case</returns> public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { if (!String.IsNullOrEmpty(arg1)) { IMinecraftHandler mc = MinecraftHandler; String match = EasyGuess.GetMatchedString(mc.Player, arg1); if (!String.IsNullOrEmpty(match)) { UserCollectionSingletone userCollection = UserCollectionSingletone.GetInstance(); User matchedPlayer = userCollection.GetUserByName(match); if (matchedPlayer != null) { GroupCollectionSingletone groups = GroupCollectionSingletone.GetInstance(); Group group = EasyGuess.GetMatchedGroup(groups, arg2); if (group != null) { if (ClientUser.LevelID >= matchedPlayer.LevelID && ClientUser.LevelID >= group.Id) // checks if the triggered user has a higher group level { matchedPlayer.LevelID = group.Id; // sets the rank to the user :) if (matchedPlayer.Generated) { matchedPlayer.Name = match; if (!userCollection.IsInlist(match)) { userCollection.Add(matchedPlayer); userCollection.Save(); } } return(new CommandResult(true, string.Format("player {0} set to group {1}", matchedPlayer.Name, group.Name))); } else { return(new CommandResult(true, string.Format("group level is too low {0} ID:{1}", ClientUser.Level.Name, ClientUser.LevelID))); } } else { return(new CommandResult(true, string.Format("couldn't find group {0}", arg2))); // give as much informations as you can } } else { return(new CommandResult(true, string.Format("couldn't find the user {0}", match))); // give as much informations as you can } } else { return(new CommandResult(true, string.Format("couldn't find the user {0}", match))); // give as much informations as you can } } else { return(new CommandResult(true, string.Format("couldn't find player {0}", arg1))); } }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { List <String> playerlist = MinecraftHandler.Player; string match = EasyGuess.GetMatchedString(playerlist, arg1); if (!String.IsNullOrEmpty(match)) { MinecraftHandler.ExecuteKick(match, TriggerPlayer); return(new CommandResult(true, string.Format("{0} kicked {1}", TriggerPlayer, match))); } return(new CommandResult()); }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { List <String> playerlist = MinecraftHandler.Player; string match = EasyGuess.GetMatchedString(playerlist, arg1); if (!String.IsNullOrEmpty(match)) { MinecraftHandler.ExecuteCommand("deop", match); return(new CommandResult(true, string.Format("{0} revoked player {1} operator {2}", Name, match, TriggerPlayer))); } return(new CommandResult()); }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { MinecraftHandler mc = (MinecraftHandler)MinecraftHandler; List <String> bans = mc.GetListFromFile(mc.StrBanList); String match = EasyGuess.GetMatchedString(bans, arg1); if (!String.IsNullOrEmpty(match)) { MinecraftHandler.ExecuteRemove(match, TriggerPlayer); return(new CommandResult(true, string.Format("{0} unbanned {1}", TriggerPlayer, match))); } return(new CommandResult()); }
public override CommandResult Execute(String name, String arg2, String arg3, String arg4) { List <String> playerlist = MinecraftHandler.Player; string match = EasyGuess.GetMatchedString(playerlist, name); if (!String.IsNullOrEmpty(match)) { //MinecraftHandler.ExecuteCommand("tell", name, text); Server.SendServerMessage(String.Format("<{0}> Hi {1}", TriggerPlayer, match)); } return(new CommandResult(true, string.Format("{0} executed by {1}", Name, TriggerPlayer))); }
public override CommandResult Execute(String name, String arg2, String arg3, String arg4) { List <String> playerlist = MinecraftHandler.Player; string match = EasyGuess.GetMatchedString(playerlist, name); string text = RegArg.Remove(0, name.Length + 1); if (!String.IsNullOrEmpty(match)) { //MinecraftHandler.ExecuteCommand("tell", match, text); Server.SendMessageToClient(match, string.Format("<{0}> {1}", TriggerPlayer, text), '7'); Server.SendMessageToClient(TriggerPlayer, string.Format("whispers ({0}) to {1}", text, match), '7'); } return(new CommandResult(true, string.Format("{0} executed by {1}", Name, TriggerPlayer))); }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { List <String> playerlist = MinecraftHandler.Player; string match = EasyGuess.GetMatchedString(playerlist, arg1); if (!String.IsNullOrEmpty(match)) { if (!String.IsNullOrEmpty(TriggerPlayer)) { MinecraftHandler.ExecuteTeleport(match, TriggerPlayer); return(new CommandResult(true, string.Format("Player {0} has teleported player {1} to himself", TriggerPlayer, match))); } } return(new CommandResult()); }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance(); Zone zone = EasyGuess.GetMatchedZone(coll, arg1); if (zone != null) { String match = EasyGuess.GetMatchedString(MinecraftHandler.Player, arg2); User user = UserCollectionSingletone.GetInstance().GetUserByName(match); if (!user.Generated) { if (ClientUser.LevelID >= zone.LevelID) { if (TriggerPlayer == zone.Owner || ClientUser.LevelID > zone.LevelID) { if (MinecraftHandler.IsStringInList(user.Name, zone.Whitelist)) { zone.Whitelist.Remove(user.Name); return(new CommandResult(true, String.Format("{0} removed user {1} removed from zone {2}", TriggerPlayer, user.Name, zone.Name))); } else { return(new CommandResult(true, String.Format("User {0} is not in zone {1} whitelist", user.Name, zone.Name))); } } else { return(new CommandResult(true, String.Format("You cannot whitelist, you need to be the owner or have an higher id"))); } } else { return(new CommandResult(true, String.Format("Insufficient permissions to set remove a player from whitelist"))); } } else { return(new CommandResult(true, String.Format("User not found: {0}", arg1))); } } else { return(new CommandResult(true, String.Format("Zone not found: {0}", arg1))); } }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { ServerSocket server = (ServerSocket)Server; String match = EasyGuess.GetMatchedString(MinecraftHandler.Player, arg1); if (!String.IsNullOrEmpty(match)) { User user = UserCollectionSingletone.GetInstance().GetUserByName(match); IClient client = Server.FindPlayer(match); if (client != null) { if (!user.Generated) { String message = RegArg.Substring(arg1.Length + 1); if (!String.IsNullOrEmpty(message)) { char lineColor = 'f'; if (server.FirstLine) { lineColor = MinecraftHandler.Config.LineFirstColorKey; } else { lineColor = MinecraftHandler.Config.LineSecondColorKey; } server.FirstLine = !server.FirstLine; if (MinecraftHandler.Config.ChannelModeChat) { server.SendChannelMessage(String.Format("§f<§{0}{1}§{2}> §{3}{4}", user.Level.GroupColor, user.Name, 'F', lineColor, message), (ClientSocket)client); } else { server.SendServerMessage(String.Format("§f<§{0}{1}§{2}> §{3}{4}", user.Level.GroupColor, user.Name, 'F', lineColor, message)); } } } } } return(new CommandResult(true, string.Format("{0} executed by {1}", Name, TriggerPlayer), true)); }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance(); Zone zone = EasyGuess.GetMatchedZone(coll, arg1); if (zone != null) { String match = EasyGuess.GetMatchedString(MinecraftHandler.Player, arg2); User user = UserCollectionSingletone.GetInstance().GetUserByName(match); if (user.Generated) { user = new User(TriggerPlayer, false); user.LevelID = 0; UserCollectionSingletone.GetInstance().Add(user); UserCollectionSingletone.GetInstance().Save(); } if (TriggerPlayer == zone.Owner || ClientUser.LevelID > zone.LevelID) { if (!MinecraftHandler.IsStringInList(user.Name, zone.Whitelist)) { zone.Whitelist.Add(user.Name); return(new CommandResult(true, String.Format("{0} has added user {1} to Zone {2}", TriggerPlayer, user.Name, zone.Name))); } else { return(new CommandResult(true, String.Format("User {0} is allready in Zone {1}", user.Name, zone.Name))); } } else { return(new CommandResult(true, String.Format("You cannot whitelist, you need to be the owner or have an higher id"))); } } else { return(new CommandResult(true, String.Format("Zone not found: {0}", arg1))); } }
public override CommandResult Execute(String id, String amount, String user, String admin) { int result = 0; bool IsNumber = int.TryParse(id, out result); List <String> playerlist = MinecraftHandler.Player; string match = EasyGuess.GetMatchedString(playerlist, user); MinecraftHandler mc = (MinecraftHandler)MinecraftHandler; string itemName = ""; string idValue = ""; if (!IsNumber) { id = id.Replace('_', ' '); KeyValuePair <String, String> kvp = EasyGuess.GetMatchedKeyValuePair(MinecraftHandler.Items, id); idValue = kvp.Value; itemName = kvp.Key; } else { idValue = id; } if (String.IsNullOrEmpty(id)) { return(new CommandResult()); } string playerMatch = ""; if (String.IsNullOrEmpty(amount)) { if (String.IsNullOrEmpty(match)) { playerMatch = admin; mc.ExecuteGive(admin, idValue); } else { playerMatch = match; mc.ExecuteGive(match, idValue); } } else { if (String.IsNullOrEmpty(match)) { playerMatch = admin; mc.ExecuteGive(admin, idValue, amount); } else { playerMatch = match; mc.ExecuteGive(match, idValue, amount); } } if (String.IsNullOrEmpty(itemName)) { return(new CommandResult(true, string.Format("{0} has given player {1} {2} by amount {3}", TriggerPlayer, playerMatch, idValue, amount))); } else { return(new CommandResult(true, string.Format("{0} has given player {1} {2}[{3}] by amount {4}", TriggerPlayer, playerMatch, itemName, idValue, amount))); } }
public override CommandResult Execute(String id, String amount, String user, String admin) { try { int result = 0; bool IsNumber = int.TryParse(id, out result); List <String> playerlist = MinecraftHandler.Player; string match = EasyGuess.GetMatchedString(playerlist, user); string itemName = ""; string idValue = ""; if (!IsNumber) { id = id.Replace('_', ' '); KeyValuePair <String, String> kvp = EasyGuess.GetMatchedKeyValuePair(MinecraftHandler.Items, id); idValue = kvp.Value; itemName = kvp.Key; } else { idValue = id; } int amountInt = 0; if (!String.IsNullOrEmpty(amount)) { amountInt = Convert.ToInt32(amount); } else { amountInt = 1; } if (!String.IsNullOrEmpty(amount)) { if (amountInt <= 0 || amountInt >= int.MaxValue) { return(new CommandResult(true, string.Format("Invalid amount!"))); } } if (String.IsNullOrEmpty(id)) { return(new CommandResult()); } string playerMatch = ""; if (String.IsNullOrEmpty(amount)) { BlockItem block = MinecraftHandler.PricedBlocks.GetBlockById(idValue); if (block == null) { return(new CommandResult(true, String.Format("Item is not for sale {0}", id))); } int price = block.Price * amountInt; if (String.IsNullOrEmpty(match)) { playerMatch = admin; if (ClientUser.Balance >= block.Price) { ClientUser.Balance -= price; SendTransferre(price, amountInt, ClientUser.Balance); MinecraftHandler.ExecuteGive(admin, idValue, "1"); } else { return(new CommandResult(true, string.Format("You have not enough money"))); } } else { playerMatch = match; if (ClientUser.Balance >= block.Price) { ClientUser.Balance -= price; SendTransferre(price, amountInt, ClientUser.Balance); MinecraftHandler.ExecuteGive(match, idValue, "1"); } else { return(new CommandResult(true, string.Format("You have not enough money"))); } } } else { BlockItem block = MinecraftHandler.PricedBlocks.GetBlockById(idValue); if (block == null) { return(new CommandResult(true, String.Format("Item is not for sale {0}", id))); } int price = block.Price * amountInt; if (amountInt <= 0 || amountInt >= int.MaxValue) { return(new CommandResult(true, string.Format("Invalid amount!"))); } if (String.IsNullOrEmpty(match)) { playerMatch = admin; if (ClientUser.Balance >= price) { ClientUser.Balance -= price; SendTransferre(price, amountInt, ClientUser.Balance); MinecraftHandler.ExecuteGive(admin, idValue, amount); } else { return(new CommandResult(true, string.Format("You have not enough money"))); } } else { playerMatch = match; if (ClientUser.Balance >= price) { ClientUser.Balance -= price; SendTransferre(price, amountInt, ClientUser.Balance); MinecraftHandler.ExecuteGive(match, idValue, amount); } else { return(new CommandResult(true, string.Format("You have not enough money"))); } } } if (String.IsNullOrEmpty(itemName)) { return(new CommandResult(true, string.Format("{0} has bought player {1} {2} by amount {3}", TriggerPlayer, playerMatch, idValue, amount))); } else { return(new CommandResult(true, string.Format("{0} has bought player {1} {2}[{3}] by amount {4}", TriggerPlayer, playerMatch, itemName, idValue, amount))); } } catch { return(new CommandResult(true, String.Format("Something went wrong while executing price ;-)"))); } }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { if (!String.IsNullOrEmpty(arg1)) { UserCollectionSingletone userlist = UserCollectionSingletone.GetInstance(); if (arg1[0] == '*') { if (arg1 == "*true") { foreach (User u in userlist.Items) { if (ClientUser != u) { u.AllowChat = false; } } Server.SendServerMessage(String.Format("Every player has been muted except {0}", TriggerPlayer)); } if (arg1 == "*false") { foreach (User u in userlist.Items) { if (ClientUser != u) { u.AllowChat = true; } } Server.SendServerMessage(String.Format("Every player has been unmuted except {0}", TriggerPlayer)); } } else { List <String> playerlist = MinecraftHandler.Player; string match = EasyGuess.GetMatchedString(playerlist, arg1); if (!String.IsNullOrEmpty(match)) { User user = userlist.GetUserByName(match); if (user.Generated) { user.Generated = false; userlist.Add(user); user.AllowChat = false; userlist.Save(); return(new CommandResult(true, string.Format("{0} has muted {1}", TriggerPlayer, match))); } else { user.AllowChat = !user.AllowChat; userlist.Save(); if (user.AllowChat) { return(new CommandResult(true, string.Format("{0} has unmuted {1}", TriggerPlayer, match))); } else { return(new CommandResult(true, string.Format("{0} has muted {1}", TriggerPlayer, match))); } } } } } return(new CommandResult(true, string.Format("user not found {0}", arg1))); }