示例#1
0
	public override void onPlayerCommand(CommandEvent ev)

	{

	    string[] cmd = ev.getCommandArray();

	    Player player = ev.getPlayer();

	    if ((cmd[0] == "/list" || cmd[0] == "/playerlist" || cmd[0] == "/online" || cmd[0] == "/players") && (player.hasPermissions("terracmd.playerlist")))

	    {

		string str = "";

		for (int i = 0; i < 8; i++)

		{

		    if (Main.player[i].active)

		    {

			if (str == "")

			{

			    str = str + Main.player[i].name;

			}

			else

			{

			    str = str + ", " + Main.player[i].name;

			}

		    }

		}

		player.sendMessage("Current players: " + str + ".", 0xff, 240, 20);

		ev.setState(true);

	    }

	    else if ((cmd[0] == "/terracmd") && (player.isOP || player.hasPermissions("terracmd.reload")))

	    {

		loadSettings();

		player.sendMessage(pluginName + " " + pluginVersion + " -- Reloaded!", 51, 255, 0);

		ev.setState(true);

	    }

	    else if ((cmd[0] == "/password") && (player.isOP || player.hasPermissions("terracmd.password")))

	    {

		if (cmd[1] == null)

		{

		    Netplay.password = "";

		    player.sendMessage("Server password removed!", 51, 255, 0);

		    ev.setState(true);

		}

		else if (cmd[1].Length > 3)

		{

		    Netplay.password = cmd[1];

		    player.sendMessage("Password reset to: " + cmd[1] + "!", 51, 255, 0);

		    ev.setState(true);

		}

		else

		{

		    player.sendMessage("Invalid password!", 255, 0, 0);

		    ev.setState(true);

		}

	    }

	    else if ((cmd[0] == "/meteor") && (player.isOP || player.hasPermissions("terracmd.meteor")))
	    {
		WorldGen.dropMeteor();
		ev.setState(true);
	    }
	    else if ((cmd[0] == "/bloodmoon) && (player.isOP || player.hasPermissions("terracmd.bloodmoon")))
	    {
		if (Main.bloodmoon)
		{
		    Main.bloodmoon = false;
		    ev.setState(true);
		}
		else
		{
		    Main.bloodmoon = true;
		    ev.setState(true);
		}
	}
示例#2
0
文件: RegionProtect.cs 项目: bbf/TOSP
        public override void onPlayerCommand(CommandEvent ev)
        {
            // Check if this command was for us
            string[] cmds = ev.getCommandArray();
            if (cmds[0] != "/region")
            {
                return;
            }

            Player player = ev.getPlayer();
            ev.setState(true);

            // Always check if the player is registered, and loggged in
            if (AuthManager.hasAccount(player) == false || AuthManager.isLoggedIn(player) == false)
            {
                if (player.hasPermissions(PERMISSION_USE))
                {
                    WisperPlayer(player, "Region commands are only available to players who are logged in.");
                }
                return;
            }

            // Only allow players to use the command if the server admin gave the user permission
            if (player.hasPermissions(PERMISSION_USE) == false)
            {
                return;
            }

            if (cmds.Length < 2)
            {
                PrintCommandHelp(player);
                return;
            }

            switch (cmds[1])
            {
                case "help":
                    PrintCommandUsage(player);
                    return;

                case "create":
                    onCreateRegion(player);
                    return;

                case "cancel":
                    onCreateCancel(player);
                    return;

                case "delete":
                    onDeleteRegion(player);
                    return;

                case "list":
                    onListRegion(player);
                    return;

                case "invite":
                    onRegionInvite(player, cmds[2]);
                    return;

                case "ban":
                    onRegionBan(player, cmds[2]);
                    return;

                // TODO: Implement inspect
                //case "inspect":
                //    return;

                default:
                    PrintCommandHelp(player);
                    return;
            }
        }