void ReloadConfig(Player p) { PluginDiscord.ReloadConfig(); p.Message("Discord config reloaded."); }
public override void Help(Player p) { p.Message("%T/ReloadEffects"); p.Message("%HReloads the effects from the config files."); }
public override void Help(Player p) { p.Message("%T/SetSoftwareName [software] - %HSets software name to [software]."); }
void LoopStopwatch(Player p, bool SpecifiedCode) { if (!SpecifiedCode) { p.Message("%SYou have started the stopwatch! Type %b/Stopwatch stop %Sto finish it."); } else { p.Extras["PKR_STARTED_CODE"] = true; } int min = 0; int sec = 0; int ms = 0; int firstLoop = 1; StopwatchPlugin.StopwatchData timer = StopwatchPlugin.Get(p); for (min = 0; ; min++) { for (sec = 0; sec < 60; sec++) { for (ms = 0; ms < 10; ms++) { if (ms == 0) { if (timer.runMS != 9 && timer.runSec != sec - 1 && firstLoop == 0) { // Timer was restarted, so we need to set the min/sec/milli lists to the runnerTime min = timer.runMin; sec = timer.runSec; ms = timer.runMS; } } else { if (timer.runMS != ms - 1 && timer.runSec != sec) { // Same thing here min = timer.runMin; sec = timer.runSec; ms = timer.runMS; } } firstLoop = 0; timer.runMin = min; timer.runSec = sec; timer.runMS = ms; p.SendCpeMessage(CpeMessageType.BottomRight2, "&6Current Time: &c" + min + ":" + sec + ":" + ms); for (int i = 0; i < 10; i++) { Thread.Sleep(10); Player[] players = PlayerInfo.Online.Items; bool isOnline = false; foreach (Player pl in players) { if (pl.truename == p.truename) { isOnline = true; } } if (!isOnline) { timer.runStop = true; } if (timer.runStop) { timer.runStop = false; timer.active = false; return; } } } } sec = 0; } }
public override void Help(Player p) { p.Message("%T/MapHack %H- Lets you bypass hacks restrictions on your own map (e.g. for when making a parkour map with -hax on)"); p.Message("%T/MapHack stop &H- Enables hacks restrictions again"); }
public static bool Handle(Player p, string text) { if (text.Length >= 2 && text[0] == '@' && text[1] == '@') { text = text.Remove(0, 2); DoPM(p, Player.Console, text); return(true); } if (text[0] == '@' || p.whisper) { if (text[0] == '@') { text = text.Remove(0, 1).Trim(); } string target = p.whisperTo; if (target.Length == 0) { text.Separate(out target, out text); if (text.Length == 0) { p.Message("No message entered"); return(true); } } Player who = PlayerInfo.FindMatches(p, target); if (who == null) { return(true); } if (who == p) { p.Message("Trying to talk to yourself, huh?"); return(true); } DoPM(p, who, text); return(true); } if (p.opchat) { MessageOps(p, text); return(true); } else if (p.adminchat) { MessageAdmins(p, text); return(true); } else if (text[0] == '#') { if (text.Length > 1 && text[1] == '#') { MessageOps(p, text.Substring(2)); return(true); } else { p.Message("%HIf you meant to send this to opchat, use %T##" + text.Substring(1)); } } else if (text[0] == '+') { if (text.Length > 1 && text[1] == '+') { MessageAdmins(p, text.Substring(2)); return(true); } else { p.Message("%HIf you meant to send this to adminchat, use %T++" + text.Substring(1)); } } return(false); }
public static void MessageNeedMinPerm(Player p, string action, LevelPermission perm) { p.Message("Only {0}&S{1}", Group.GetColoredName(perm), action); }
void EnableHacksBypass(Player p) { p.Extras[ext_allowed_key] = true; p.SendMapMotd(); p.Message("&aYou are now bypassing hacks restrictions on this map"); }
public override void Help(Player p) { p.Message("%T/Reward [secret code] [amount]"); p.Message("%HGives you rewards after completing a task."); }
public bool Unload(bool silent = false, bool save = true) { if (Server.mainLevel == this || IsMuseum) { return(false); } if (Server.lava.active && Server.lava.map == this) { return(false); } if (LevelUnload != null) { LevelUnload(this); } OnLevelUnloadEvent.Call(this); if (cancelunload) { Server.s.Log("Unload canceled by Plugin! (Map: " + name + ")"); cancelunload = false; return(false); } MovePlayersToMain(); if (save && changed && ShouldSaveChanges()) { Save(false, true); } if (save && ShouldSaveChanges()) { saveChanges(); } if (TntWarsGame.Find(this) != null) { foreach (TntWarsGame.player pl in TntWarsGame.Find(this).Players) { pl.p.CurrentTntGameNumber = -1; Player.Message(pl.p, "TNT Wars: The TNT Wars game you are currently playing has been deleted!"); pl.p.PlayingTntWars = false; pl.p.canBuild = true; TntWarsGame.SetTitlesAndColor(pl, true); } Server.s.Log("TNT Wars: Game deleted on " + name); TntWarsGame.GameList.Remove(TntWarsGame.Find(this)); } MovePlayersToMain(); LevelInfo.Loaded.Remove(this); try { PlayerBot.UnloadFromLevel(this); physThread.Abort(); physThread.Join(); } catch { } finally { Dispose(); GC.Collect(); GC.WaitForPendingFinalizers(); if (!silent) { Chat.MessageOps(ColoredName + " %Swas unloaded."); } Server.s.Log(name + " was unloaded."); } return(true); }
protected internal static void SuperRequiresArgs(string cmd, Player p, string type) { p.Message("When using /{0} from {2}, you must provide a {1}.", cmd, type, p.SuperName); }
public override void Help(Player p) { p.Message("%T/DiscordBot reload - %HReload config files"); p.Message("%T/DiscordBot restart - %HRestart the bot"); p.Message("%HToken or Channel ID changes require a restart after reloading the config"); }
void RestartBot(Player p) { PluginDiscord.dc.Dispose(); PluginDiscord.dc = new Discord.Discord(PluginDiscord.config.Token, PluginDiscord.config.ChannelID); p.Message("Discord bot restarted."); }
public override void Use(Player p, string message, CommandData data) { if (message == "") { Help(p); return; } if (message.CaselessEq("list")) { ListEffects(p); return; } string[] words = message.Split(' '); if (words.Length < 7) { p.Message("%WYou need to provide effect, x, y, z, originX, originY, and originZ."); return; } string effectName = words[0]; float x = 0, y = 0, z = 0; float originX = 0, originY = 0, originZ = 0; bool showToAll = false; if (!CommandParser.GetReal(p, words[1], "x", ref x)) { return; } if (!CommandParser.GetReal(p, words[2], "y", ref y)) { return; } if (!CommandParser.GetReal(p, words[3], "z", ref z)) { return; } if (!CommandParser.GetReal(p, words[4], "originX", ref originX)) { return; } if (!CommandParser.GetReal(p, words[5], "originY", ref originY)) { return; } if (!CommandParser.GetReal(p, words[6], "originZ", ref originZ)) { return; } if (words.Length >= 8) { if (!CommandParser.GetBool(p, words[7], ref showToAll)) { return; } } PluginGoodlyEffects.EffectConfig effect; if (!PluginGoodlyEffects.effectAtEffectName.TryGetValue(effectName, out effect)) { p.Message("%WUnknown effect \"{0}\".", effectName); return; } //default to center of block x += 0.5f; y += 0.5f; z += 0.5f; originX += x; originY += y; originZ += z; if (showToAll) { PluginGoodlyEffects.SpawnEffectAt(p.level, effectName, x, y, z, originX, originY, originZ); } else { PluginGoodlyEffects.SpawnEffectFor(p, effectName, x, y, z, originX, originY, originZ); } }
public override void Help(Player p) { p.Message("%T/Crouch %H- Toggles crouching."); }
static void DoAdd(Player p, string message) { if (SpawnerCount(p.level) >= PluginGoodlyEffects.spawnerLimit) { p.Message("%WThe limit of {0} spawners per level has been reached.", PluginGoodlyEffects.spawnerLimit); p.Message("You may remove spawners with %T/spawner remove%S."); return; } string[] words = message.Split(' '); if (words.Length < 8) { p.Message("%WTo add a spawner you need to provide spawner name, effect, x, y, z, originX, originY, and originZ."); return; } string spawnerName = words[0]; if (SpawnerNameExists(p, spawnerName)) { return; } string effectName = words[1]; PluginGoodlyEffects.EffectConfig effect; if (!PluginGoodlyEffects.effectAtEffectName.TryGetValue(effectName, out effect)) { p.Message("%WUnknown effect \"{0}\".", effectName); return; } float x = 0, y = 0, z = 0; float originX = 0, originY = 0, originZ = 0; int spawnInterval = 0; int spawnTimeOffset = 0; float spawnChance = 1f; if (!GetCoord(p, words[2], p.Pos.BlockX, "x", out x)) { return; } ; if (!GetCoord(p, words[3], p.Pos.FeetBlockCoords.Y, "y", out y)) { return; } ; if (!GetCoord(p, words[4], p.Pos.BlockZ, "z", out z)) { return; } ; if (!GetCoord(p, words[5], p.Pos.BlockX, "originX", out originX)) { return; } ; if (!GetCoord(p, words[6], p.Pos.FeetBlockCoords.Y, "originY", out originY)) { return; } ; if (!GetCoord(p, words[7], p.Pos.BlockZ, "originZ", out originZ)) { return; } ; if (words.Length > 8) { if (!CommandParser.GetInt(p, words[8], "spawn interval", ref spawnInterval, 0, 600)) { return; } } if (words.Length > 9) { if (!CommandParser.GetInt(p, words[9], "spawn time offset", ref spawnTimeOffset, 0, 599)) { return; } } if (words.Length > 10) { if (!CommandParser.GetReal(p, words[10], "spawn chance", ref spawnChance, 0.01f, 100)) { return; } //convert percentage to 0-1 spawnChance /= 100f; } //default to center of block x += 0.5f; y += 0.5f; z += 0.5f; originX += 0.5f; originY += 0.5f; originZ += 0.5f; PluginGoodlyEffects.EffectSpawner spawner = new PluginGoodlyEffects.EffectSpawner(); spawner.name = spawnerName; spawner.effectName = effectName; spawner.owner = p.name; spawner.x = x; spawner.y = y; spawner.z = z; spawner.originX = originX; spawner.originY = originY; spawner.originZ = originZ; spawner.spawnInterval = spawnInterval; spawner.spawnTimeOffset = spawnTimeOffset; spawner.spawnChance = spawnChance; PluginGoodlyEffects.AddSpawner(spawner, p.level, true); p.Message("Successfully added a spawner named {0}.", spawner.name); }
public override void Use(Player p, string message, CommandData data) { if (!(p.group.Permission >= LevelPermission.Operator)) { if (!Hacks.CanUseHacks(p)) { if (data.Context != CommandContext.MessageBlock) { p.Message("%cYou cannot use this command manually when hacks are disabled."); return; } } } BlockID block = p.GetHeldBlock(); string[] parts = message.SplitSpaces(); Vec3S32 pos; pos.X = p.Pos.BlockX; pos.Y = (p.Pos.Y - 32) / 32; pos.Z = p.Pos.BlockZ; switch (parts.Length) { case 1: if (message == "") { break; } if (!CommandParser.GetBlock(p, parts[0], out block)) { return; } break; case 3: if (!CommandParser.GetCoords(p, parts, 0, ref pos)) { return; } break; case 4: if (!CommandParser.GetBlock(p, parts[0], out block)) { return; } if (!CommandParser.GetCoords(p, parts, 1, ref pos)) { return; } break; default: p.Message("Invalid number of parameters"); return; } if (!CommandParser.IsBlockAllowed(p, "place ", block)) { return; } pos = p.level.ClampPos(pos); p.SendBlockchange((ushort)pos.X, (ushort)pos.Y, (ushort)pos.Z, block); //string blockName = Block.GetName(p, block); //p.Message("{3} block was placed at ({0}, {1}, {2}).", P.X, P.Y, P.Z, blockName); }
void DisableHacksBypass(Player p) { p.Extras[ext_allowed_key] = false; p.SendMapMotd(); p.Message("%HHacks bypassing reset, use %T/MapHack %Hto turn on again"); }
public override void Help(Player p) { p.Message("%T/CopyServerMap [old name] <new name>"); p.Message("%HCopies a level across from old server to this server"); p.Message("%HIf <new name> is not given, then [old name] is used as name for the new level"); }
/// <summary> Called when a player does /Help on the plugin. Typically tells the player what this plugin is about. </summary> /// <param name="p"> Player who is doing /Help. </param> public virtual void Help(Player p) { p.Message("No help is available for this plugin."); }
public bool Unload(bool silent = false, bool save = true) { if (Server.mainLevel == this || IsMuseum) { return(false); } if (Server.lava.active && Server.lava.map == this) { return(false); } OnLevelUnloadEvent.Call(this); if (cancelunload) { Logger.Log(LogType.SystemActivity, "Unload canceled by Plugin! (Map: {0})", name); cancelunload = false; return(false); } MovePlayersToMain(); if (save && Changed && ShouldSaveChanges()) { Save(false, true); } if (save && ShouldSaveChanges()) { SaveBlockDBChanges(); } if (TntWarsGame.Find(this) != null) { foreach (TntWarsGame.player pl in TntWarsGame.Find(this).Players) { pl.p.CurrentTntGameNumber = -1; Player.Message(pl.p, "TNT Wars: The TNT Wars game you are currently playing has been deleted!"); pl.p.PlayingTntWars = false; pl.p.canBuild = true; TntWarsGame.SetTitlesAndColor(pl, true); } Logger.Log(LogType.GameActivity, "TNT Wars: Game deleted on " + name); TntWarsGame.GameList.Remove(TntWarsGame.Find(this)); } MovePlayersToMain(); LevelInfo.Loaded.Remove(this); try { if (!unloadedBots) { unloadedBots = true; BotsFile.Save(this); PlayerBot.RemoveLoadedBots(this, false); } physThread.Abort(); physThread.Join(); } catch { } finally { Dispose(); Server.DoGC(); if (!silent) { Chat.MessageOps(ColoredName + " %Swas unloaded."); } Logger.Log(LogType.SystemActivity, name + " was unloaded."); } return(true); }
/// <summary> Finds partial matches of 'name' against the names of the items in the 'items' enumerable. </summary> /// <remarks> Outputs multiple matching entries, as 'items' enumerable may have multiple entries. </remarks> /// <returns> If exactly one match, the matching list of items. </returns> public static List <T> FindMulti <T>(Player p, string name, out int matches, IEnumerable items, Predicate <T> filter, StringFormatter <T> nameGetter, string group, int limit = 5) { List <T> matchItems = null; matches = 0; StringBuilder nameMatches = new StringBuilder(); List <string> outputtedNames = new List <string>(limit); string match = null; const StringComparison comp = StringComparison.OrdinalIgnoreCase; foreach (T item in items) { if (filter != null && !filter(item)) { continue; } string itemName = nameGetter(item); // Found an exact name match - only output items now which exactly match if (itemName.Equals(name, comp)) { if (match == null || !name.Equals(match, comp)) { matchItems = new List <T>(); } matchItems.Add(item); matches = 1; match = name; continue; } if (itemName.IndexOf(name, comp) < 0) { continue; } if (matches == 0) // Found our first partial match - init the list { matchItems = new List <T>(); matchItems.Add(item); match = itemName; } else if (match != null && itemName.Equals(match, comp)) // Found same partial match { matchItems.Add(item); } // We do not want to output the same name multiple times if (outputtedNames.CaselessContains(itemName) || matches > (limit + 1)) { continue; } matches++; if (matches <= limit) { nameMatches.Append(itemName).Append(", "); } else if (matches == limit + 1) { nameMatches.Append("(and more)").Append(", "); } outputtedNames.Add(itemName); } if (matches == 1) { return(matchItems); } if (matches == 0) { Player.Message(p, "No " + group + " found for \"" + name + "\"."); } else { OutputMulti(p, name, nameMatches, matches, "players", limit); } return(null); }
static void DoSummon(Player p, string message) { if (message == "") { p.Message("%WPlease provide the name of a spawner to summon."); return; } string[] args = message.SplitSpaces(2); string spawnerName = args[0]; bool precise = (args.Length > 1) ? args[1].CaselessEq("precise") : false; p.Message("precise is {0}", precise); if (!PluginGoodlyEffects.spawnersAtLevel.ContainsKey(p.level)) { p.Message("There are no spawners in {0}%S.", p.level.ColoredName); return; } int matches; PluginGoodlyEffects.EffectSpawner spawner = Matcher.Find(p, spawnerName, out matches, PluginGoodlyEffects.spawnersAtLevel[p.level], x => true, x => x.name, "effect spawners"); if (matches > 1 || spawner == null) { return; } if (spawner.EditableBy(p, "summon")) { float diffX = spawner.x - spawner.originX; float diffY = spawner.y - spawner.originY; float diffZ = spawner.z - spawner.originZ; if (precise) { spawner.x = (float)(p.Pos.X) / 32f; spawner.y = (float)(p.Pos.Y - Entities.CharacterHeight) / 32f; spawner.z = (float)(p.Pos.Z) / 32f; } else { spawner.x = p.Pos.BlockX; spawner.y = p.Pos.FeetBlockCoords.Y; spawner.z = p.Pos.BlockZ; //center in block spawner.x += 0.5f; spawner.y += 0.5f; spawner.z += 0.5f; } spawner.originX = spawner.x - diffX; spawner.originY = spawner.y - diffY; spawner.originZ = spawner.z - diffZ; if (precise) { p.Message("Summoned spawner {0} to your precise feet position.", spawner.name); } else { p.Message("Summoned spawner {0} to your block position.", spawner.name); } PluginGoodlyEffects.SpawnersFile.Save(p.level); } }
void StopTimer(Player p, bool SpecifiedCode) { if (!SpecifiedCode && p.Extras.GetBoolean("PKR_STARTED_CODE")) { p.Message("%f╒ %c∩αΓ: %7You cannot stop a predefined stopwatch."); return; } StopwatchPlugin.StopwatchData timer = StopwatchPlugin.Get(p); int finishMin = 0; int finishSec = 0; int finishMS = 0; if (timer.active) { finishMin = timer.runMin; finishSec = timer.runSec; finishMS = timer.runMS; } else { return; } string codeMin = ""; string codeSec = ""; string codeMS = ""; if (finishMin < 10) { codeMin = "0" + finishMin.ToString(); } else if (finishMin < 100) { codeMin = finishMin.ToString(); } else { codeMin = "99"; } if (finishSec < 10) { codeSec = "0" + finishSec.ToString(); } else { codeSec = finishSec.ToString(); } codeMS = finishMS.ToString(); timer.runStop = true; string codeTime = codeMin + codeSec + codeMS; int intCodeTime = int.Parse(codeTime); // Create 5 digit code of the time the player finished with if (SpecifiedCode) { Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (pl.level != p.level) { break; } if (pl == p) { p.Message("%aYou finished with a time of: %b" + finishMin + ":" + finishSec + ":" + finishMS + "%a."); } else { pl.Message("%b" + p.truename + " %afinished with a time of %b" + finishMin + ":" + finishSec + ":" + finishMS + "%a."); } } } else { p.Message("%aYou finished with a time of: %b" + finishMin + ":" + finishSec + ":" + finishMS + "%a."); } p.SendCpeMessage(CpeMessageType.BottomRight2, ""); }
public override void Help(Player p, string message) { if (message.CaselessEq("2")) { p.Message("%HSpawner help page 2:"); p.Message("%T/Spawner remove [name] %H- removes a spawner."); p.Message("%HIf [name] is \"all\", all spawners are removed."); p.Message("%T/Spawner tp [name] %H- teleports you to a spawner."); p.Message("%T/Spawner summon [name] <style> %H- summons a spawner to"); p.Message("%Hyour block position. If <style> is \"precise\","); p.Message("%Hthe spawner is summoned to your exact feet position."); p.Message("%T/Spawner list %H- lists spawners in current level."); return; } if (message.CaselessEq("add")) { p.Message("%fRequired arguments for adding a spawner:"); p.Message("%T[name] %His used to identify the spawner."); p.Message("%T[effect] %H- the effect this spawner creates."); p.Message("%HUse %T/effect list %Hto view available effects."); p.Message("%T[x y z] %H- the coords the effect spawns around."); p.Message("%T[origin] %H- the coords the effect moves away from."); p.Message("%HTIP: use ~ for coords relative to you."); p.Message("%HE.G. %T~ ~0.5 ~"); p.Message("%Hwould make coords at the top of the block you're standing in."); p.Message("%HUse %T/help spawner options %Hfor optional arguments"); return; } if (message.CaselessEq("options")) { p.Message("%fOptional arguments for adding a spawner:"); p.Message("%T<interval> %H- how long to wait between spawns."); p.Message("%HAn interval of 10 would spawn once per second."); p.Message("%T<time offset> %Hoffsets when the effect spawns."); p.Message("%HAn offset of 5 means half a second."); p.Message("%T<spawn % chance> %H- chance the effect spawns."); p.Message("%HThe default is 100, which means it always spawns."); return; } p.Message("There is no help page named \"{0}\".", message); }
public override void Help(Player p) { p.Message("%T/StopWatch [start/stop] %H- Toggles the stopwatch."); p.Message("%T/StopWatch reset %H- Resets the stopwatch."); }
/// <summary> Informs the given player that they must first /// verify before they can perform the given action </summary> public virtual void RequiresVerification(Player p, string action) { p.Message("&WYou must first verify with &T/Pass [Password] &Wbefore you can {0}", action); }