Пример #1
0
        static void OnPlayerCommand(Player p, string cmd, string args, CommandData data)
        {
            if (cmd.CaselessEq("skin") && Hacks.CanUseHacks(p))
            {
                var splitArgs = args.Trim().Length == 0 ? new string[] { } : args.SplitSpaces();
                if (splitArgs.Length == 0)
                {
                    // check if we should use default skin
                    var storedModel = new StoredCustomModel(p.Model);
                    if (storedModel.Exists())
                    {
                        storedModel.LoadFromFile();

                        if (
                            !storedModel.usesHumanSkin &&
                            storedModel.defaultSkin != null
                            )
                        {
                            Debug("Setting {0} to defaultSkin {1}", p.name, storedModel.defaultSkin);
                            Command.Find("Skin").Use(
                                p,
                                "-own " + storedModel.defaultSkin,
                                data
                                );
                            p.cancelcommand = true;
                        }
                    }
                    else if (splitArgs.Length > 0)
                    {
                        var last = splitArgs[splitArgs.Length - 1];
                        MemoizedGetSkinType.Invalidate(last);
                    }
                }
            }
        }
Пример #2
0
        static void DoTP(Player p, string message)
        {
            if (!Hacks.CanUseHacks(p))
            {
                p.Message("%WYou can't teleport to spawners because hacks are disabled in {0}", p.level.ColoredName);
                return;
            }
            if (message == "")
            {
                p.Message("%WPlease provide the name of a spawner to teleport to."); return;
            }
            if (!PluginGoodlyEffects.spawnersAtLevel.ContainsKey(p.level))
            {
                p.Message("There are no spawners in {0}%S to teleport to.", p.level.ColoredName);
                return;
            }
            int matches;

            PluginGoodlyEffects.EffectSpawner spawner = Matcher.Find(p, message, out matches,
                                                                     PluginGoodlyEffects.spawnersAtLevel[p.level],
                                                                     x => true,
                                                                     x => x.name,
                                                                     "effect spawners");
            if (matches > 1 || spawner == null)
            {
                return;
            }
            Command.Find("tp").Use(p, "-precise " + (int)(spawner.x * 32) + " " + (int)(spawner.y * 32) + " " + (int)(spawner.z * 32));
        }
		// The possible values of the Enums used in HandlePlayerClick
		//public enum MouseButton { Left, Right, Middle }  
		//public enum MouseAction { Pressed, Released }
		//public enum TargetBlockFace { AwayX, TowardsX, AwayY, TowardsY, AwayZ, TowardsZ, None }
		
		
		static void HandlePlayerClick
		(
		Player p,
		MouseButton button, MouseAction action,
		ushort yaw, ushort pitch,
		byte entity, ushort x, ushort y, ushort z,
		TargetBlockFace face
		)
		{
			//you can uncomment this to make it only work in maps that have both buildable and deletable off
			// if (p.level.Config.Deletable && p.level.Config.Buildable) { return; }
			
			// as an example of using the above enums, you can uncomment this to do nothing and quit if the player just used pick-block button.
			// if (button == MouseButton.Middle) { return; }
			
			
			BlockID clickedBlock;
			clickedBlock = p.level.GetBlock(x, y, z);
			//clickedBlock is now the block ID that was clicked.
			//This ID is MCGalaxy block ID, which means it's not mapped the same as client block ID.
			//However, 0-65 are still identical.
			
			//Example of running /place to put a stone block at the coordinates the player has clicked.
			Command.Find("place").Use(p, "stone "+x+" "+y+" "+z+"");
			
			
		}
        public override void Unload(bool shutdown)
        {
            Command.Unregister(Command.Find("ReloadEffects"));
            Command.Unregister(Command.Find("Effect"));
            Command.Unregister(Command.Find("Spawner"));

            OnPlayerFinishConnectingEvent.Unregister(OnPlayerFinishConnecting);
            OnLevelLoadedEvent.Unregister(OnLevelLoaded);
            OnLevelUnloadEvent.Unregister(OnLevelUnload);
            OnLevelDeletedEvent.Unregister(OnLevelDeleted);
            OnLevelCopiedEvent.Unregister(OnLevelCopied);
            OnLevelRenamedEvent.Unregister(OnLevelRenamed);

            spawnersAtLevel.Clear();
            instance.Cancel(tickSpawners);
        }
Пример #5
0
 public override void Use(Player p, string message, CommandData data)
 {
     if (p.Extras.GetBoolean("IS_CROUCHING"))
     {
         p.Extras["IS_CROUCHING"] = false;
         p.Extras["HAS_CROUCHED"] = true;
         p.SendMapMotd();
         Command.Find("SilentModel").Use(p, "humanoid|1");
     }
     else
     {
         p.Extras["IS_CROUCHING"] = true;
         p.Extras["HAS_CROUCHED"] = true;
         p.SendMapMotd();
         Command.Find("SilentModel").Use(p, "crouch");
     }
 }
Пример #6
0
        public override void Unload(bool shutdown)
        {
            if (dc != null)
            {
                dc.Dispose();
            }
            if (!registered)
            {
                return;
            }
            OnPlayerConnectEvent.Unregister(PlayerConnect);
            OnPlayerDisconnectEvent.Unregister(PlayerDisconnect);
            OnPlayerChatEvent.Unregister(PlayerChat);
            OnPlayerCommandEvent.Unregister(PlayerCommand);

            OnMessageReceivedEvent.Unregister(DiscordMessage);

            Command.Unregister(Command.Find("DiscordBot"));
        }
Пример #7
0
        public void SetUsableCommands()
        {
            List <Command> commands = new List <Command>();

            foreach (CommandPerms perms in CommandPerms.List)
            {
                if (!perms.UsableBy(Permission))
                {
                    continue;
                }

                Command cmd = Command.Find(perms.CmdName);
                if (cmd != null)
                {
                    commands.Add(cmd);
                }
            }
            Commands = commands;
        }
Пример #8
0
        static bool GotoMap(Player p, string name)
        {
            Level lvl = LevelInfo.FindExact(name);

            if (lvl != null)
            {
                return(GotoLevel(p, lvl));
            }

            if (Server.Config.AutoLoadMaps)
            {
                string map = Matcher.FindMaps(p, name);
                if (map == null)
                {
                    return(false);
                }

                lvl = LevelInfo.FindExact(map);
                if (lvl != null)
                {
                    return(GotoLevel(p, lvl));
                }
                return(LoadOfflineLevel(p, map));
            }
            else
            {
                lvl = Matcher.FindLevels(p, name);
                if (lvl == null)
                {
                    p.Message("There is no level \"{0}\" loaded. Did you mean..", name);
                    Command.Find("Search").Use(p, "levels " + name);
                    return(false);
                }
                return(GotoLevel(p, lvl));
            }
        }
Пример #9
0
        Command GetCommand(ref string cmdName, ref string cmdArgs, CommandData data)
        {
            if (!CheckCommand(cmdName))
            {
                return(null);
            }
            Command.Search(ref cmdName, ref cmdArgs);

            byte bindIndex;

            if (byte.TryParse(cmdName, out bindIndex) && bindIndex < CmdBindings.Length)
            {
                if (CmdArgsBindings[bindIndex] == null)
                {
                    Message("No command is bound to: %T/" + cmdName); return(null);
                }

                cmdName = CmdBindings[bindIndex];
                cmdArgs = CmdArgsBindings[bindIndex] + " " + cmdArgs;
                cmdArgs = cmdArgs.TrimEnd(' ');
            }

            OnPlayerCommandEvent.Call(this, cmdName, cmdArgs, data);
            if (cancelcommand)
            {
                cancelcommand = false; return(null);
            }

            Command command = Command.Find(cmdName);

            if (command == null)
            {
                if (Block.Parse(this, cmdName) != Block.Invalid)
                {
                    cmdArgs = cmdName; cmdName = "mode";
                    command = Command.Find("Mode");
                }
                else
                {
                    Logger.Log(LogType.CommandUsage, "{0} tried to use unknown command: /{1} {2}", name, cmdName, cmdArgs);
                    Message("Unknown command \"" + cmdName + "\"."); return(null);
                }
            }

            if (!group.CanExecute(command))
            {
                CommandPerms.Find(command.name).MessageCannotUse(this);
                return(null);
            }

            string reason = Command.GetDisabledReason(command.Enabled);

            if (reason != null)
            {
                Message("Command is disabled as " + reason); return(null);
            }
            if (level.IsMuseum && !command.museumUsable)
            {
                Message("Cannot use this command while in a museum."); return(null);
            }
            if (frozen && !command.UseableWhenFrozen)
            {
                Message("Cannot use this command while frozen."); return(null);
            }
            return(command);
        }
Пример #10
0
 public override void Unload(bool shutdown)
 {
     Command.Unregister(Command.Find("Stopwatch"));
     OnJoinedLevelEvent.Unregister(HandleOnJoinedLevel);
 }
Пример #11
0
 public override void Unload(bool shutdown)
 {
     Command.Unregister(Command.Find("Lottery"));
     OnPlayerDisconnectEvent.Unregister(HandlePlayerDisconnect);
 }
Пример #12
0
 public override void Unload(bool shutdown)
 {
     OnPlayerDisconnectEvent.Unregister(LeaveServer);
     Command.Unregister(Command.Find("Party"));
 }
Пример #13
0
        public bool CanExecute(string cmdName)
        {
            Command cmd = Command.Find(cmdName);

            return(cmd != null && Commands.Contains(cmd));
        }
 public override void Unload(bool shutdown)
 {
     Command.Unregister(Command.Find("FavouriteMap"));
     OnlineStat.Stats.Remove(onlineLine);
     OfflineStat.Stats.Remove(offlineLine);
 }
Пример #15
0
        public override bool Execute(PlayerBot bot, InstructionData data)
        {
            Metadata meta = (Metadata)data.Metadata;

            if (bot.Model == "skeleton" || bot.Model == "creeper")
            {
                bot.movementSpeed = (int)Math.Round(3m * (short)97 / 100m);
            }
            if (bot.Model == "zombie")
            {
                bot.movementSpeed = (int)Math.Round(3m * (short)94 / 100m);
            }

            if (bot.movementSpeed == 0)
            {
                bot.movementSpeed = 1;
            }

            int search = 12;

            Player closest = MobAI.ClosestPlayer(bot, search);

            if (closest == null)
            {
                if (bot.Model == "creeper")
                {
                    meta.explodeTime = 0;
                }

                if (meta.walkTime > 0)
                {
                    meta.walkTime--;
                    bot.movement = true;
                    return(true);
                }
                if (meta.waitTime > 0)
                {
                    meta.waitTime--;
                    return(true);
                }

                DoStuff(bot, meta);

                bot.movement = false;
                bot.NextInstruction();
            }

            else
            {
                if (bot.Model == "creeper")
                {
                    if (meta.explodeTime > 0)
                    {
                        meta.explodeTime--;

                        if (meta.explodeTime == 1)
                        {
                            if (closest.level.physics > 1 && closest.level.physics != 5)
                            {
                                closest.level.MakeExplosion((ushort)(bot.Pos.X / 32), (ushort)(bot.Pos.Y / 32), (ushort)(bot.Pos.Z / 32), 0);
                            }
                            Command.Find("Effect").Use(closest, "explosion " + (bot.Pos.X / 32) + " " + (bot.Pos.Y / 32) + " " + (bot.Pos.Z / 32) + " 0 0 0 true");

                            Orientation rot = bot.Rot;

                            HitPlayer(bot, closest, rot);
                            meta.explodeTime = 0;
                            PlayerBot.Remove(bot);
                            return(true);
                        }

                        bot.movement = true;
                        return(true);
                    }
                }
            }

            bool overlapsPlayer = MoveTowards(bot, closest, meta);

            if (overlapsPlayer && closest != null)
            {
                bot.NextInstruction(); return(false);
            }


            return(true);
        }
Пример #16
0
        Command GetCommand(ref string cmdName, ref string cmdArgs, CommandData data)
        {
            if (!CheckCommand(cmdName))
            {
                return(null);
            }

            string bound;
            byte   bindIndex;

            if (CmdBindings.TryGetValue(cmdName, out bound))
            {
                // user defined command shortcuts take priority
                bound.Separate(out cmdName, out cmdArgs);
            }
            else if (byte.TryParse(cmdName, out bindIndex) && bindIndex < 10)
            {
                // backwards compatibility for old /cmdbind behaviour
                Message("No command is bound to: &T/" + cmdName);
                return(null);
            }

            Command.Search(ref cmdName, ref cmdArgs);
            OnPlayerCommandEvent.Call(this, cmdName, cmdArgs, data);
            if (cancelcommand)
            {
                cancelcommand = false; return(null);
            }

            Command command = Command.Find(cmdName);

            if (command == null)
            {
                if (Block.Parse(this, cmdName) != Block.Invalid)
                {
                    cmdArgs = cmdName; cmdName = "mode";
                    command = Command.Find("Mode");
                }
                else
                {
                    Logger.Log(LogType.CommandUsage, "{0} tried to use unknown command: /{1} {2}", name, cmdName, cmdArgs);
                    Message("Unknown command \"{0}\".", cmdName); return(null);
                }
            }

            if (!CanUse(command))
            {
                CommandPerms.Find(command.name).MessageCannotUse(this);
                return(null);
            }

            string reason = Command.GetDisabledReason(command.Enabled);

            if (reason != null)
            {
                Message("Command is disabled as " + reason); return(null);
            }
            if (level != null && level.IsMuseum && !command.museumUsable)
            {
                Message("Cannot use &T/{0} &Swhile in a museum.", command.name); return(null);
            }
            if (frozen && !command.UseableWhenFrozen)
            {
                Message("Cannot use &T/{0} &Swhile frozen.", command.name); return(null);
            }
            return(command);
        }
Пример #17
0
        public override void Unload(bool shutdown)
        {
            OnGettingMotdEvent.Unregister(HandleGettingMOTD);

            Command.Unregister(Command.Find("Crouch"));
        }
Пример #18
0
 public override void Unload(bool shutdown)
 {
     Command.Unregister(Command.Find("XP"));
 }
 public override void Unload(bool shutdown)
 {
     Command.Unregister(Command.Find("SetSoftwareName"));
 }
Пример #20
0
        public bool CanUse(string cmdName)
        {
            Command cmd = Command.Find(cmdName);

            return(cmd != null && CanUse(cmd));
        }
Пример #21
0
 public Command FindByName(string name)
 {
     return(Command.Find(name));
 }