public override void Use(Player p, string message, CommandData data) { GoodlyEffects.effectAtEffectName.Clear(); GoodlyEffects.LoadEffects(); GoodlyEffects.DefineEffectsAll(); p.Message("Reloaded effects!"); }
static void DoRemove(Player p, string message) { if (message.CaselessEq("all")) { if (GoodlyEffects.EffectSpawner.CanEditAny(p)) { GoodlyEffects.RemoveAllSpawners(p.level, true); p.Message("Removed all spawners from {0}&S.", p.level.ColoredName); } else { p.Message("&WYou cannot remove all spawners unless you are the owner of this map."); } return; } if (message == "") { p.Message("&WPlease provide the name of a spawner to remove."); return; } if (!GoodlyEffects.spawnersAtLevel.ContainsKey(p.level)) { p.Message("There are no spawners in {0}&S.", p.level.ColoredName); return; } int matches; GoodlyEffects.EffectSpawner spawner = Matcher.Find(p, message, out matches, GoodlyEffects.spawnersAtLevel[p.level], x => true, x => x.name, "effect spawners"); if (matches > 1 || spawner == null) { return; } if (spawner.EditableBy(p, "remove")) { p.Message("Removed spawner {0}.", spawner.name); GoodlyEffects.RemoveSpawner(spawner, p.level, true); } }
static void DoAdd(Player p, string message) { if (SpawnerCount(p.level) >= GoodlyEffects.spawnerLimit) { p.Message("&WThe limit of {0} spawners per level has been reached.", GoodlyEffects.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]; GoodlyEffects.EffectConfig effect; if (!GoodlyEffects.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; GoodlyEffects.EffectSpawner spawner = new GoodlyEffects.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; GoodlyEffects.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 (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; } } GoodlyEffects.EffectConfig effect; if (!GoodlyEffects.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) { GoodlyEffects.SpawnEffectAt(p.level, effectName, x, y, z, originX, originY, originZ); } else { GoodlyEffects.SpawnEffectFor(p, effectName, x, y, z, originX, originY, originZ); } }